From d7526a2de025eff104f58c78082af623b26e1d2f Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Wed, 24 Jan 2024 11:04:45 +0000 Subject: [PATCH] Deploy mate-desktop/mate-system-monitor to github.com/mate-desktop/mate-system-monitor.git:gh-pages --- .../index.html | 136 + .../report-22e004.html | 1116 +++++++ .../report-491eb3.html | 1340 +++++++++ .../report-4d889d.html | 1340 +++++++++ .../report-633ebf.html | 737 +++++ .../report-6c54e6.html | 1340 +++++++++ .../report-6c8186.html | 886 ++++++ .../report-77634b.html | 1340 +++++++++ .../report-7bbc8c.html | 1340 +++++++++ .../report-7ce786.html | 1340 +++++++++ .../report-802eaf.html | 737 +++++ .../report-8e6c9c.html | 1200 ++++++++ .../report-c673b5.html | 1340 +++++++++ .../report-d507c5.html | 1116 +++++++ .../report-e8ff80.html | 1340 +++++++++ .../scanview.css | 62 + .../sorttable.js | 492 +++ .../0.html | 763 +++++ .../1.html | 435 +++ .../10.html | 1067 +++++++ .../11.html | 1039 +++++++ .../12.html | 385 +++ .../13.html | 1417 +++++++++ .../14.html | 1109 +++++++ .../15.html | 671 +++++ .../16.html | 913 ++++++ .../17.html | 2635 +++++++++++++++++ .../18.html | 405 +++ .../19.html | 2359 +++++++++++++++ .../2.html | 489 +++ .../3.html | 645 ++++ .../4.html | 1277 ++++++++ .../5.html | 2141 ++++++++++++++ .../6.html | 1599 ++++++++++ .../7.html | 1939 ++++++++++++ .../8.html | 1075 +++++++ .../9.html | 1197 ++++++++ .../index.html | 323 ++ .../stats.html | 189 ++ .../style.css | 177 ++ .../index.html | 136 + .../report-22e004.html | 1116 +++++++ .../report-491eb3.html | 1340 +++++++++ .../report-4d889d.html | 1340 +++++++++ .../report-633ebf.html | 737 +++++ .../report-6c54e6.html | 1340 +++++++++ .../report-6c8186.html | 886 ++++++ .../report-77634b.html | 1340 +++++++++ .../report-7bbc8c.html | 1340 +++++++++ .../report-7ce786.html | 1340 +++++++++ .../report-802eaf.html | 737 +++++ .../report-8e6c9c.html | 1200 ++++++++ .../report-c673b5.html | 1340 +++++++++ .../report-d507c5.html | 1116 +++++++ .../report-e8ff80.html | 1340 +++++++++ .../scanview.css | 62 + .../sorttable.js | 492 +++ .../0.html | 763 +++++ .../1.html | 435 +++ .../10.html | 1067 +++++++ .../11.html | 1039 +++++++ .../12.html | 385 +++ .../13.html | 1417 +++++++++ .../14.html | 1109 +++++++ .../15.html | 671 +++++ .../16.html | 913 ++++++ .../17.html | 2635 +++++++++++++++++ .../18.html | 405 +++ .../19.html | 2359 +++++++++++++++ .../2.html | 489 +++ .../3.html | 645 ++++ .../4.html | 1277 ++++++++ .../5.html | 2141 ++++++++++++++ .../6.html | 1599 ++++++++++ .../7.html | 1939 ++++++++++++ .../8.html | 1075 +++++++ .../9.html | 1197 ++++++++ .../index.html | 323 ++ .../stats.html | 189 ++ .../style.css | 177 ++ .../index.html | 136 + .../report-22e004.html | 1116 +++++++ .../report-491eb3.html | 1340 +++++++++ .../report-4d889d.html | 1340 +++++++++ .../report-633ebf.html | 737 +++++ .../report-6c54e6.html | 1340 +++++++++ .../report-6c8186.html | 886 ++++++ .../report-77634b.html | 1340 +++++++++ .../report-7bbc8c.html | 1340 +++++++++ .../report-7ce786.html | 1340 +++++++++ .../report-802eaf.html | 737 +++++ .../report-8e6c9c.html | 1200 ++++++++ .../report-c673b5.html | 1340 +++++++++ .../report-d507c5.html | 1116 +++++++ .../report-e8ff80.html | 1340 +++++++++ .../scanview.css | 62 + .../sorttable.js | 492 +++ .../0.html | 763 +++++ .../1.html | 435 +++ .../10.html | 1067 +++++++ .../11.html | 1039 +++++++ .../12.html | 385 +++ .../13.html | 1417 +++++++++ .../14.html | 1109 +++++++ .../15.html | 671 +++++ .../16.html | 913 ++++++ .../17.html | 2635 +++++++++++++++++ .../18.html | 405 +++ .../19.html | 2359 +++++++++++++++ .../2.html | 489 +++ .../3.html | 645 ++++ .../4.html | 1277 ++++++++ .../5.html | 2141 ++++++++++++++ .../6.html | 1599 ++++++++++ .../7.html | 1939 ++++++++++++ .../8.html | 1075 +++++++ .../9.html | 1197 ++++++++ .../index.html | 323 ++ .../stats.html | 189 ++ .../style.css | 177 ++ .../index.html | 136 + .../report-22e004.html | 1116 +++++++ .../report-491eb3.html | 1340 +++++++++ .../report-4d889d.html | 1340 +++++++++ .../report-633ebf.html | 737 +++++ .../report-6c54e6.html | 1340 +++++++++ .../report-6c8186.html | 886 ++++++ .../report-77634b.html | 1340 +++++++++ .../report-7bbc8c.html | 1340 +++++++++ .../report-7ce786.html | 1340 +++++++++ .../report-802eaf.html | 737 +++++ .../report-8e6c9c.html | 1200 ++++++++ .../report-c673b5.html | 1340 +++++++++ .../report-d507c5.html | 1116 +++++++ .../report-e8ff80.html | 1340 +++++++++ .../scanview.css | 62 + .../sorttable.js | 492 +++ .../0.html | 763 +++++ .../1.html | 435 +++ .../10.html | 1067 +++++++ .../11.html | 1039 +++++++ .../12.html | 385 +++ .../13.html | 1417 +++++++++ .../14.html | 1109 +++++++ .../15.html | 671 +++++ .../16.html | 913 ++++++ .../17.html | 2635 +++++++++++++++++ .../18.html | 405 +++ .../19.html | 2359 +++++++++++++++ .../2.html | 489 +++ .../3.html | 645 ++++ .../4.html | 1277 ++++++++ .../5.html | 2141 ++++++++++++++ .../6.html | 1599 ++++++++++ .../7.html | 1939 ++++++++++++ .../8.html | 1075 +++++++ .../9.html | 1197 ++++++++ .../index.html | 323 ++ .../stats.html | 189 ++ .../style.css | 177 ++ .../index.html | 136 + .../report-22e004.html | 1116 +++++++ .../report-491eb3.html | 1340 +++++++++ .../report-4d889d.html | 1340 +++++++++ .../report-633ebf.html | 737 +++++ .../report-6c54e6.html | 1340 +++++++++ .../report-6c8186.html | 886 ++++++ .../report-77634b.html | 1340 +++++++++ .../report-7bbc8c.html | 1340 +++++++++ .../report-7ce786.html | 1340 +++++++++ .../report-802eaf.html | 737 +++++ .../report-8e6c9c.html | 1200 ++++++++ .../report-c673b5.html | 1340 +++++++++ .../report-d507c5.html | 1116 +++++++ .../report-e8ff80.html | 1340 +++++++++ .../scanview.css | 62 + .../sorttable.js | 492 +++ .../0.html | 763 +++++ .../1.html | 435 +++ .../10.html | 1067 +++++++ .../11.html | 1039 +++++++ .../12.html | 385 +++ .../13.html | 1417 +++++++++ .../14.html | 1109 +++++++ .../15.html | 671 +++++ .../16.html | 913 ++++++ .../17.html | 2635 +++++++++++++++++ .../18.html | 405 +++ .../19.html | 2359 +++++++++++++++ .../2.html | 489 +++ .../3.html | 645 ++++ .../4.html | 1277 ++++++++ .../5.html | 2141 ++++++++++++++ .../6.html | 1599 ++++++++++ .../7.html | 1939 ++++++++++++ .../8.html | 1075 +++++++ .../9.html | 1197 ++++++++ .../index.html | 323 ++ .../stats.html | 189 ++ .../style.css | 177 ++ .../index.html | 136 + .../report-22e004.html | 1116 +++++++ .../report-491eb3.html | 1340 +++++++++ .../report-4d889d.html | 1340 +++++++++ .../report-633ebf.html | 737 +++++ .../report-6c54e6.html | 1340 +++++++++ .../report-6c8186.html | 886 ++++++ .../report-77634b.html | 1340 +++++++++ .../report-7bbc8c.html | 1340 +++++++++ .../report-7ce786.html | 1340 +++++++++ .../report-802eaf.html | 737 +++++ .../report-8e6c9c.html | 1200 ++++++++ .../report-c673b5.html | 1340 +++++++++ .../report-d507c5.html | 1116 +++++++ .../report-e8ff80.html | 1340 +++++++++ .../scanview.css | 62 + .../sorttable.js | 492 +++ .../0.html | 763 +++++ .../1.html | 435 +++ .../10.html | 1067 +++++++ .../11.html | 1039 +++++++ .../12.html | 385 +++ .../13.html | 1417 +++++++++ .../14.html | 1109 +++++++ .../15.html | 671 +++++ .../16.html | 913 ++++++ .../17.html | 2635 +++++++++++++++++ .../18.html | 405 +++ .../19.html | 2359 +++++++++++++++ .../2.html | 489 +++ .../3.html | 645 ++++ .../4.html | 1277 ++++++++ .../5.html | 2141 ++++++++++++++ .../6.html | 1599 ++++++++++ .../7.html | 1939 ++++++++++++ .../8.html | 1075 +++++++ .../9.html | 1197 ++++++++ .../index.html | 323 ++ .../stats.html | 189 ++ .../style.css | 177 ++ .../index.html | 136 + .../report-22e004.html | 1116 +++++++ .../report-491eb3.html | 1340 +++++++++ .../report-4d889d.html | 1340 +++++++++ .../report-633ebf.html | 737 +++++ .../report-6c54e6.html | 1340 +++++++++ .../report-6c8186.html | 886 ++++++ .../report-77634b.html | 1340 +++++++++ .../report-7bbc8c.html | 1340 +++++++++ .../report-7ce786.html | 1340 +++++++++ .../report-802eaf.html | 737 +++++ .../report-8e6c9c.html | 1200 ++++++++ .../report-c673b5.html | 1340 +++++++++ .../report-d507c5.html | 1116 +++++++ .../report-e8ff80.html | 1340 +++++++++ .../scanview.css | 62 + .../sorttable.js | 492 +++ .../0.html | 325 ++ .../1.html | 279 ++ .../10.html | 391 +++ .../11.html | 499 ++++ .../12.html | 341 +++ .../13.html | 255 ++ .../14.html | 257 ++ .../15.html | 299 ++ .../16.html | 489 +++ .../17.html | 255 ++ .../18.html | 645 ++++ .../19.html | 261 ++ .../2.html | 1289 ++++++++ .../20.html | 1277 ++++++++ .../21.html | 2141 ++++++++++++++ .../22.html | 351 +++ .../23.html | 1599 ++++++++++ .../24.html | 1939 ++++++++++++ .../25.html | 1075 +++++++ .../26.html | 1197 ++++++++ .../27.html | 1067 +++++++ .../28.html | 1039 +++++++ .../29.html | 271 ++ .../3.html | 395 +++ .../30.html | 899 ++++++ .../31.html | 331 +++ .../32.html | 621 ++++ .../33.html | 1417 +++++++++ .../34.html | 261 ++ .../35.html | 261 ++ .../36.html | 1109 +++++++ .../37.html | 283 ++ .../38.html | 671 +++++ .../39.html | 303 ++ .../4.html | 763 +++++ .../40.html | 303 ++ .../41.html | 913 ++++++ .../42.html | 2635 +++++++++++++++++ .../43.html | 279 ++ .../44.html | 265 ++ .../45.html | 323 ++ .../46.html | 405 +++ .../47.html | 553 ++++ .../48.html | 2359 +++++++++++++++ .../49.html | 1557 ++++++++++ .../5.html | 435 +++ .../50.html | 275 ++ .../6.html | 385 +++ .../7.html | 287 ++ .../8.html | 385 +++ .../9.html | 305 ++ .../index.html | 663 +++++ .../stats.html | 201 ++ .../style.css | 177 ++ .../index.html | 136 + .../report-22e004.html | 1116 +++++++ .../report-491eb3.html | 1340 +++++++++ .../report-4d889d.html | 1340 +++++++++ .../report-633ebf.html | 737 +++++ .../report-6c54e6.html | 1340 +++++++++ .../report-6c8186.html | 886 ++++++ .../report-77634b.html | 1340 +++++++++ .../report-7bbc8c.html | 1340 +++++++++ .../report-7ce786.html | 1340 +++++++++ .../report-802eaf.html | 737 +++++ .../report-8e6c9c.html | 1200 ++++++++ .../report-c673b5.html | 1340 +++++++++ .../report-d507c5.html | 1116 +++++++ .../report-e8ff80.html | 1340 +++++++++ .../scanview.css | 62 + .../sorttable.js | 492 +++ .../0.html | 325 ++ .../1.html | 279 ++ .../10.html | 391 +++ .../11.html | 499 ++++ .../12.html | 341 +++ .../13.html | 255 ++ .../14.html | 257 ++ .../15.html | 299 ++ .../16.html | 489 +++ .../17.html | 255 ++ .../18.html | 645 ++++ .../19.html | 261 ++ .../2.html | 1289 ++++++++ .../20.html | 1277 ++++++++ .../21.html | 2141 ++++++++++++++ .../22.html | 351 +++ .../23.html | 1599 ++++++++++ .../24.html | 1939 ++++++++++++ .../25.html | 1075 +++++++ .../26.html | 1197 ++++++++ .../27.html | 1067 +++++++ .../28.html | 1039 +++++++ .../29.html | 271 ++ .../3.html | 395 +++ .../30.html | 899 ++++++ .../31.html | 331 +++ .../32.html | 621 ++++ .../33.html | 1417 +++++++++ .../34.html | 261 ++ .../35.html | 261 ++ .../36.html | 1109 +++++++ .../37.html | 283 ++ .../38.html | 671 +++++ .../39.html | 303 ++ .../4.html | 763 +++++ .../40.html | 303 ++ .../41.html | 913 ++++++ .../42.html | 2635 +++++++++++++++++ .../43.html | 279 ++ .../44.html | 265 ++ .../45.html | 323 ++ .../46.html | 405 +++ .../47.html | 553 ++++ .../48.html | 2359 +++++++++++++++ .../49.html | 1557 ++++++++++ .../5.html | 435 +++ .../50.html | 275 ++ .../6.html | 385 +++ .../7.html | 287 ++ .../8.html | 385 +++ .../9.html | 305 ++ .../index.html | 663 +++++ .../stats.html | 201 ++ .../style.css | 177 ++ .../index.html | 136 + .../report-22e004.html | 1116 +++++++ .../report-491eb3.html | 1340 +++++++++ .../report-4d889d.html | 1340 +++++++++ .../report-633ebf.html | 737 +++++ .../report-6c54e6.html | 1340 +++++++++ .../report-6c8186.html | 886 ++++++ .../report-77634b.html | 1340 +++++++++ .../report-7bbc8c.html | 1340 +++++++++ .../report-7ce786.html | 1340 +++++++++ .../report-802eaf.html | 737 +++++ .../report-8e6c9c.html | 1200 ++++++++ .../report-c673b5.html | 1340 +++++++++ .../report-d507c5.html | 1116 +++++++ .../report-e8ff80.html | 1340 +++++++++ .../scanview.css | 62 + .../sorttable.js | 492 +++ .../0.html | 325 ++ .../1.html | 279 ++ .../10.html | 391 +++ .../11.html | 499 ++++ .../12.html | 341 +++ .../13.html | 255 ++ .../14.html | 257 ++ .../15.html | 299 ++ .../16.html | 489 +++ .../17.html | 255 ++ .../18.html | 645 ++++ .../19.html | 261 ++ .../2.html | 1289 ++++++++ .../20.html | 1277 ++++++++ .../21.html | 2141 ++++++++++++++ .../22.html | 351 +++ .../23.html | 1599 ++++++++++ .../24.html | 1939 ++++++++++++ .../25.html | 1075 +++++++ .../26.html | 1197 ++++++++ .../27.html | 1067 +++++++ .../28.html | 1039 +++++++ .../29.html | 271 ++ .../3.html | 395 +++ .../30.html | 899 ++++++ .../31.html | 331 +++ .../32.html | 621 ++++ .../33.html | 1417 +++++++++ .../34.html | 261 ++ .../35.html | 261 ++ .../36.html | 1109 +++++++ .../37.html | 283 ++ .../38.html | 671 +++++ .../39.html | 303 ++ .../4.html | 763 +++++ .../40.html | 303 ++ .../41.html | 913 ++++++ .../42.html | 2635 +++++++++++++++++ .../43.html | 279 ++ .../44.html | 265 ++ .../45.html | 323 ++ .../46.html | 405 +++ .../47.html | 553 ++++ .../48.html | 2359 +++++++++++++++ .../49.html | 1557 ++++++++++ .../5.html | 435 +++ .../50.html | 275 ++ .../6.html | 385 +++ .../7.html | 287 ++ .../8.html | 385 +++ .../9.html | 305 ++ .../index.html | 663 +++++ .../stats.html | 201 ++ .../style.css | 177 ++ .../index.html | 136 + .../report-22e004.html | 1116 +++++++ .../report-491eb3.html | 1340 +++++++++ .../report-4d889d.html | 1340 +++++++++ .../report-633ebf.html | 737 +++++ .../report-6c54e6.html | 1340 +++++++++ .../report-6c8186.html | 886 ++++++ .../report-77634b.html | 1340 +++++++++ .../report-7bbc8c.html | 1340 +++++++++ .../report-7ce786.html | 1340 +++++++++ .../report-802eaf.html | 737 +++++ .../report-8e6c9c.html | 1200 ++++++++ .../report-c673b5.html | 1340 +++++++++ .../report-d507c5.html | 1116 +++++++ .../report-e8ff80.html | 1340 +++++++++ .../scanview.css | 62 + .../sorttable.js | 492 +++ .../0.html | 325 ++ .../1.html | 279 ++ .../10.html | 391 +++ .../11.html | 499 ++++ .../12.html | 341 +++ .../13.html | 255 ++ .../14.html | 257 ++ .../15.html | 299 ++ .../16.html | 489 +++ .../17.html | 255 ++ .../18.html | 645 ++++ .../19.html | 261 ++ .../2.html | 1289 ++++++++ .../20.html | 1277 ++++++++ .../21.html | 2141 ++++++++++++++ .../22.html | 351 +++ .../23.html | 1599 ++++++++++ .../24.html | 1939 ++++++++++++ .../25.html | 1075 +++++++ .../26.html | 1197 ++++++++ .../27.html | 1071 +++++++ .../28.html | 1039 +++++++ .../29.html | 271 ++ .../3.html | 395 +++ .../30.html | 899 ++++++ .../31.html | 331 +++ .../32.html | 621 ++++ .../33.html | 1417 +++++++++ .../34.html | 261 ++ .../35.html | 261 ++ .../36.html | 1109 +++++++ .../37.html | 283 ++ .../38.html | 671 +++++ .../39.html | 303 ++ .../4.html | 763 +++++ .../40.html | 303 ++ .../41.html | 913 ++++++ .../42.html | 2635 +++++++++++++++++ .../43.html | 279 ++ .../44.html | 265 ++ .../45.html | 323 ++ .../46.html | 405 +++ .../47.html | 553 ++++ .../48.html | 2359 +++++++++++++++ .../49.html | 1557 ++++++++++ .../5.html | 435 +++ .../50.html | 275 ++ .../6.html | 385 +++ .../7.html | 287 ++ .../8.html | 385 +++ .../9.html | 305 ++ .../index.html | 670 +++++ .../stats.html | 205 ++ .../style.css | 177 ++ CNAME | 1 + index.html | 47 + 526 files changed, 467817 insertions(+) create mode 100644 2023-05-15-084858-6149-1@d2839764fa8b_help-translations/index.html create mode 100644 2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-22e004.html create mode 100644 2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-491eb3.html create mode 100644 2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-4d889d.html create mode 100644 2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-633ebf.html create mode 100644 2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-6c54e6.html create mode 100644 2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-6c8186.html create mode 100644 2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-77634b.html create mode 100644 2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-7bbc8c.html create mode 100644 2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-7ce786.html create mode 100644 2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-802eaf.html create mode 100644 2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-8e6c9c.html create mode 100644 2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-c673b5.html create mode 100644 2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-d507c5.html create mode 100644 2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-e8ff80.html create mode 100644 2023-05-15-084858-6149-1@d2839764fa8b_help-translations/scanview.css create mode 100644 2023-05-15-084858-6149-1@d2839764fa8b_help-translations/sorttable.js create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/0.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/1.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/10.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/11.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/12.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/13.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/14.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/15.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/16.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/17.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/18.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/19.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/2.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/3.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/4.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/5.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/6.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/7.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/8.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/9.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/index.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/stats.html create mode 100644 2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/style.css create mode 100644 2023-05-15-174418-6156-1@e1533eb204f2_master/index.html create mode 100644 2023-05-15-174418-6156-1@e1533eb204f2_master/report-22e004.html create mode 100644 2023-05-15-174418-6156-1@e1533eb204f2_master/report-491eb3.html create mode 100644 2023-05-15-174418-6156-1@e1533eb204f2_master/report-4d889d.html create mode 100644 2023-05-15-174418-6156-1@e1533eb204f2_master/report-633ebf.html create mode 100644 2023-05-15-174418-6156-1@e1533eb204f2_master/report-6c54e6.html create mode 100644 2023-05-15-174418-6156-1@e1533eb204f2_master/report-6c8186.html create mode 100644 2023-05-15-174418-6156-1@e1533eb204f2_master/report-77634b.html create mode 100644 2023-05-15-174418-6156-1@e1533eb204f2_master/report-7bbc8c.html create mode 100644 2023-05-15-174418-6156-1@e1533eb204f2_master/report-7ce786.html create mode 100644 2023-05-15-174418-6156-1@e1533eb204f2_master/report-802eaf.html create mode 100644 2023-05-15-174418-6156-1@e1533eb204f2_master/report-8e6c9c.html create mode 100644 2023-05-15-174418-6156-1@e1533eb204f2_master/report-c673b5.html create mode 100644 2023-05-15-174418-6156-1@e1533eb204f2_master/report-d507c5.html create mode 100644 2023-05-15-174418-6156-1@e1533eb204f2_master/report-e8ff80.html create mode 100644 2023-05-15-174418-6156-1@e1533eb204f2_master/scanview.css create mode 100644 2023-05-15-174418-6156-1@e1533eb204f2_master/sorttable.js create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/0.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/1.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/10.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/11.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/12.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/13.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/14.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/15.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/16.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/17.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/18.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/19.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/2.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/3.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/4.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/5.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/6.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/7.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/8.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/9.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/index.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/stats.html create mode 100644 2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/style.css create mode 100644 2023-09-04-185402-6123-1@d0fc4b9c7899_master/index.html create mode 100644 2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-22e004.html create mode 100644 2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-491eb3.html create mode 100644 2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-4d889d.html create mode 100644 2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-633ebf.html create mode 100644 2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-6c54e6.html create mode 100644 2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-6c8186.html create mode 100644 2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-77634b.html create mode 100644 2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-7bbc8c.html create mode 100644 2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-7ce786.html create mode 100644 2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-802eaf.html create mode 100644 2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-8e6c9c.html create mode 100644 2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-c673b5.html create mode 100644 2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-d507c5.html create mode 100644 2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-e8ff80.html create mode 100644 2023-09-04-185402-6123-1@d0fc4b9c7899_master/scanview.css create mode 100644 2023-09-04-185402-6123-1@d0fc4b9c7899_master/sorttable.js create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/0.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/1.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/10.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/11.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/12.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/13.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/14.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/15.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/16.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/17.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/18.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/19.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/2.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/3.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/4.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/5.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/6.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/7.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/8.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/9.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/index.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/stats.html create mode 100644 2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/style.css create mode 100644 2023-09-05-135451-6126-1@c439634163d9_test-ci/index.html create mode 100644 2023-09-05-135451-6126-1@c439634163d9_test-ci/report-22e004.html create mode 100644 2023-09-05-135451-6126-1@c439634163d9_test-ci/report-491eb3.html create mode 100644 2023-09-05-135451-6126-1@c439634163d9_test-ci/report-4d889d.html create mode 100644 2023-09-05-135451-6126-1@c439634163d9_test-ci/report-633ebf.html create mode 100644 2023-09-05-135451-6126-1@c439634163d9_test-ci/report-6c54e6.html create mode 100644 2023-09-05-135451-6126-1@c439634163d9_test-ci/report-6c8186.html create mode 100644 2023-09-05-135451-6126-1@c439634163d9_test-ci/report-77634b.html create mode 100644 2023-09-05-135451-6126-1@c439634163d9_test-ci/report-7bbc8c.html create mode 100644 2023-09-05-135451-6126-1@c439634163d9_test-ci/report-7ce786.html create mode 100644 2023-09-05-135451-6126-1@c439634163d9_test-ci/report-802eaf.html create mode 100644 2023-09-05-135451-6126-1@c439634163d9_test-ci/report-8e6c9c.html create mode 100644 2023-09-05-135451-6126-1@c439634163d9_test-ci/report-c673b5.html create mode 100644 2023-09-05-135451-6126-1@c439634163d9_test-ci/report-d507c5.html create mode 100644 2023-09-05-135451-6126-1@c439634163d9_test-ci/report-e8ff80.html create mode 100644 2023-09-05-135451-6126-1@c439634163d9_test-ci/scanview.css create mode 100644 2023-09-05-135451-6126-1@c439634163d9_test-ci/sorttable.js create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/0.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/1.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/10.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/11.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/12.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/13.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/14.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/15.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/16.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/17.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/18.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/19.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/2.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/3.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/4.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/5.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/6.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/7.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/8.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/9.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/index.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/stats.html create mode 100644 2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/style.css create mode 100644 2023-09-11-094458-6134-1@4954edb594c8_master/index.html create mode 100644 2023-09-11-094458-6134-1@4954edb594c8_master/report-22e004.html create mode 100644 2023-09-11-094458-6134-1@4954edb594c8_master/report-491eb3.html create mode 100644 2023-09-11-094458-6134-1@4954edb594c8_master/report-4d889d.html create mode 100644 2023-09-11-094458-6134-1@4954edb594c8_master/report-633ebf.html create mode 100644 2023-09-11-094458-6134-1@4954edb594c8_master/report-6c54e6.html create mode 100644 2023-09-11-094458-6134-1@4954edb594c8_master/report-6c8186.html create mode 100644 2023-09-11-094458-6134-1@4954edb594c8_master/report-77634b.html create mode 100644 2023-09-11-094458-6134-1@4954edb594c8_master/report-7bbc8c.html create mode 100644 2023-09-11-094458-6134-1@4954edb594c8_master/report-7ce786.html create mode 100644 2023-09-11-094458-6134-1@4954edb594c8_master/report-802eaf.html create mode 100644 2023-09-11-094458-6134-1@4954edb594c8_master/report-8e6c9c.html create mode 100644 2023-09-11-094458-6134-1@4954edb594c8_master/report-c673b5.html create mode 100644 2023-09-11-094458-6134-1@4954edb594c8_master/report-d507c5.html create mode 100644 2023-09-11-094458-6134-1@4954edb594c8_master/report-e8ff80.html create mode 100644 2023-09-11-094458-6134-1@4954edb594c8_master/scanview.css create mode 100644 2023-09-11-094458-6134-1@4954edb594c8_master/sorttable.js create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/0.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/1.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/10.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/11.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/12.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/13.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/14.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/15.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/16.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/17.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/18.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/19.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/2.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/3.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/4.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/5.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/6.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/7.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/8.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/9.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/index.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/stats.html create mode 100644 2023-09-11-094648-2277-cppcheck@4954edb594c8_master/style.css create mode 100644 2023-09-11-112139-6130-1@3d354f8f4fd2_master/index.html create mode 100644 2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-22e004.html create mode 100644 2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-491eb3.html create mode 100644 2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-4d889d.html create mode 100644 2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-633ebf.html create mode 100644 2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-6c54e6.html create mode 100644 2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-6c8186.html create mode 100644 2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-77634b.html create mode 100644 2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-7bbc8c.html create mode 100644 2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-7ce786.html create mode 100644 2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-802eaf.html create mode 100644 2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-8e6c9c.html create mode 100644 2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-c673b5.html create mode 100644 2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-d507c5.html create mode 100644 2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-e8ff80.html create mode 100644 2023-09-11-112139-6130-1@3d354f8f4fd2_master/scanview.css create mode 100644 2023-09-11-112139-6130-1@3d354f8f4fd2_master/sorttable.js create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/0.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/1.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/10.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/11.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/12.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/13.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/14.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/15.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/16.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/17.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/18.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/19.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/2.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/3.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/4.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/5.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/6.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/7.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/8.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/9.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/index.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/stats.html create mode 100644 2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/style.css create mode 100644 2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/index.html create mode 100644 2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-22e004.html create mode 100644 2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-491eb3.html create mode 100644 2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-4d889d.html create mode 100644 2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-633ebf.html create mode 100644 2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-6c54e6.html create mode 100644 2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-6c8186.html create mode 100644 2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-77634b.html create mode 100644 2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-7bbc8c.html create mode 100644 2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-7ce786.html create mode 100644 2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-802eaf.html create mode 100644 2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-8e6c9c.html create mode 100644 2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-c673b5.html create mode 100644 2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-d507c5.html create mode 100644 2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-e8ff80.html create mode 100644 2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/scanview.css create mode 100644 2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/sorttable.js create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/0.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/1.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/10.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/11.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/12.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/13.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/14.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/15.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/16.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/17.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/18.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/19.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/2.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/20.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/21.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/22.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/23.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/24.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/25.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/26.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/27.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/28.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/29.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/3.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/30.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/31.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/32.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/33.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/34.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/35.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/36.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/37.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/38.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/39.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/4.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/40.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/41.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/42.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/43.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/44.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/45.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/46.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/47.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/48.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/49.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/5.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/50.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/6.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/7.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/8.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/9.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/index.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/stats.html create mode 100644 2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/style.css create mode 100644 2023-10-16-145104-6166-1@382528349dca_fix-build/index.html create mode 100644 2023-10-16-145104-6166-1@382528349dca_fix-build/report-22e004.html create mode 100644 2023-10-16-145104-6166-1@382528349dca_fix-build/report-491eb3.html create mode 100644 2023-10-16-145104-6166-1@382528349dca_fix-build/report-4d889d.html create mode 100644 2023-10-16-145104-6166-1@382528349dca_fix-build/report-633ebf.html create mode 100644 2023-10-16-145104-6166-1@382528349dca_fix-build/report-6c54e6.html create mode 100644 2023-10-16-145104-6166-1@382528349dca_fix-build/report-6c8186.html create mode 100644 2023-10-16-145104-6166-1@382528349dca_fix-build/report-77634b.html create mode 100644 2023-10-16-145104-6166-1@382528349dca_fix-build/report-7bbc8c.html create mode 100644 2023-10-16-145104-6166-1@382528349dca_fix-build/report-7ce786.html create mode 100644 2023-10-16-145104-6166-1@382528349dca_fix-build/report-802eaf.html create mode 100644 2023-10-16-145104-6166-1@382528349dca_fix-build/report-8e6c9c.html create mode 100644 2023-10-16-145104-6166-1@382528349dca_fix-build/report-c673b5.html create mode 100644 2023-10-16-145104-6166-1@382528349dca_fix-build/report-d507c5.html create mode 100644 2023-10-16-145104-6166-1@382528349dca_fix-build/report-e8ff80.html create mode 100644 2023-10-16-145104-6166-1@382528349dca_fix-build/scanview.css create mode 100644 2023-10-16-145104-6166-1@382528349dca_fix-build/sorttable.js create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/0.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/1.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/10.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/11.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/12.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/13.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/14.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/15.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/16.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/17.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/18.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/19.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/2.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/20.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/21.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/22.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/23.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/24.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/25.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/26.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/27.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/28.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/29.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/3.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/30.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/31.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/32.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/33.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/34.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/35.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/36.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/37.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/38.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/39.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/4.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/40.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/41.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/42.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/43.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/44.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/45.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/46.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/47.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/48.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/49.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/5.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/50.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/6.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/7.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/8.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/9.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/index.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/stats.html create mode 100644 2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/style.css create mode 100644 2023-10-16-150431-6168-1@71c61020bc59_master/index.html create mode 100644 2023-10-16-150431-6168-1@71c61020bc59_master/report-22e004.html create mode 100644 2023-10-16-150431-6168-1@71c61020bc59_master/report-491eb3.html create mode 100644 2023-10-16-150431-6168-1@71c61020bc59_master/report-4d889d.html create mode 100644 2023-10-16-150431-6168-1@71c61020bc59_master/report-633ebf.html create mode 100644 2023-10-16-150431-6168-1@71c61020bc59_master/report-6c54e6.html create mode 100644 2023-10-16-150431-6168-1@71c61020bc59_master/report-6c8186.html create mode 100644 2023-10-16-150431-6168-1@71c61020bc59_master/report-77634b.html create mode 100644 2023-10-16-150431-6168-1@71c61020bc59_master/report-7bbc8c.html create mode 100644 2023-10-16-150431-6168-1@71c61020bc59_master/report-7ce786.html create mode 100644 2023-10-16-150431-6168-1@71c61020bc59_master/report-802eaf.html create mode 100644 2023-10-16-150431-6168-1@71c61020bc59_master/report-8e6c9c.html create mode 100644 2023-10-16-150431-6168-1@71c61020bc59_master/report-c673b5.html create mode 100644 2023-10-16-150431-6168-1@71c61020bc59_master/report-d507c5.html create mode 100644 2023-10-16-150431-6168-1@71c61020bc59_master/report-e8ff80.html create mode 100644 2023-10-16-150431-6168-1@71c61020bc59_master/scanview.css create mode 100644 2023-10-16-150431-6168-1@71c61020bc59_master/sorttable.js create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/0.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/1.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/10.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/11.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/12.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/13.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/14.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/15.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/16.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/17.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/18.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/19.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/2.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/20.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/21.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/22.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/23.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/24.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/25.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/26.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/27.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/28.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/29.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/3.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/30.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/31.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/32.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/33.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/34.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/35.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/36.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/37.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/38.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/39.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/4.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/40.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/41.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/42.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/43.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/44.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/45.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/46.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/47.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/48.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/49.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/5.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/50.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/6.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/7.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/8.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/9.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/index.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/stats.html create mode 100644 2023-10-16-150621-7841-cppcheck@71c61020bc59_master/style.css create mode 100644 2024-01-24-110103-6148-1@4d3102f305d3_master/index.html create mode 100644 2024-01-24-110103-6148-1@4d3102f305d3_master/report-22e004.html create mode 100644 2024-01-24-110103-6148-1@4d3102f305d3_master/report-491eb3.html create mode 100644 2024-01-24-110103-6148-1@4d3102f305d3_master/report-4d889d.html create mode 100644 2024-01-24-110103-6148-1@4d3102f305d3_master/report-633ebf.html create mode 100644 2024-01-24-110103-6148-1@4d3102f305d3_master/report-6c54e6.html create mode 100644 2024-01-24-110103-6148-1@4d3102f305d3_master/report-6c8186.html create mode 100644 2024-01-24-110103-6148-1@4d3102f305d3_master/report-77634b.html create mode 100644 2024-01-24-110103-6148-1@4d3102f305d3_master/report-7bbc8c.html create mode 100644 2024-01-24-110103-6148-1@4d3102f305d3_master/report-7ce786.html create mode 100644 2024-01-24-110103-6148-1@4d3102f305d3_master/report-802eaf.html create mode 100644 2024-01-24-110103-6148-1@4d3102f305d3_master/report-8e6c9c.html create mode 100644 2024-01-24-110103-6148-1@4d3102f305d3_master/report-c673b5.html create mode 100644 2024-01-24-110103-6148-1@4d3102f305d3_master/report-d507c5.html create mode 100644 2024-01-24-110103-6148-1@4d3102f305d3_master/report-e8ff80.html create mode 100644 2024-01-24-110103-6148-1@4d3102f305d3_master/scanview.css create mode 100644 2024-01-24-110103-6148-1@4d3102f305d3_master/sorttable.js create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/0.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/1.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/10.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/11.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/12.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/13.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/14.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/15.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/16.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/17.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/18.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/19.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/2.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/20.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/21.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/22.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/23.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/24.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/25.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/26.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/27.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/28.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/29.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/3.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/30.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/31.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/32.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/33.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/34.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/35.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/36.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/37.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/38.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/39.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/4.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/40.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/41.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/42.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/43.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/44.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/45.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/46.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/47.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/48.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/49.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/5.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/50.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/6.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/7.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/8.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/9.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/index.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/stats.html create mode 100644 2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/style.css create mode 100644 CNAME create mode 100644 index.html diff --git a/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/index.html b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/index.html new file mode 100644 index 00000000..3e6e8f3b --- /dev/null +++ b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/index.html @@ -0,0 +1,136 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@e0d6701afb77
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 16.0.2 (Fedora 16.0.2-1.fc38) +
Date:Mon May 15 08:48:58 2023
+

Bug Summary

+ + + + + + + +
Bug TypeQuantityDisplay?
All Bugs14
Logic error
Use of identical expressions1
Unused code
Dead assignment1
Unreachable code12
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
Unused codeDead assignmentrootdir/src/disks.cppget_mount_opt2011View Report
Unused codeUnreachable coderootdir/src/procman-app.cppon_command_line3811View Report
Unused codeUnreachable coderootdir/src/util.cppio_rate_cell_data_func4941View Report
Unused codeUnreachable coderootdir/src/util.cppstatus_cell_data_func5911View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_gicon421View Report
Unused codeUnreachable coderootdir/src/util.cppduration_cell_data_func5351View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_na_cell_data_func3841View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_na_cell_data_func4561View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_cell_data_func4221View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_icon131View Report
Unused codeUnreachable coderootdir/src/util.cpptime_cell_data_func5641View Report
Unused codeUnreachable coderootdir/src/procman-app.cpptimeouts_changed_cb1511View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_cell_data_func3501View Report
Logic errorUse of identical expressionsusr/include/sigc++-2.0/sigc++/visit_each.hoperator()981View Report
+ + diff --git a/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-22e004.html b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-22e004.html new file mode 100644 index 00000000..e79b1917 --- /dev/null +++ b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-22e004.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 381, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-084858-6149-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
This statement is never executed
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-491eb3.html b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-491eb3.html new file mode 100644 index 00000000..993a22b6 --- /dev/null +++ b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-491eb3.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 494, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-084858-6149-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-4d889d.html b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-4d889d.html new file mode 100644 index 00000000..e875b6b8 --- /dev/null +++ b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-4d889d.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 591, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-084858-6149-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-633ebf.html b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-633ebf.html new file mode 100644 index 00000000..a66f9e3c --- /dev/null +++ b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-633ebf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 42, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-084858-6149-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
This statement is never executed
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-6c54e6.html b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-6c54e6.html new file mode 100644 index 00000000..430c9f0a --- /dev/null +++ b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-6c54e6.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 535, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-084858-6149-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-6c8186.html b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-6c8186.html new file mode 100644 index 00000000..67f2676c --- /dev/null +++ b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-6c8186.html @@ -0,0 +1,886 @@ + + + +/usr/include/sigc++-2.0/sigc++/visit_each.h + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:usr/include/sigc++-2.0/sigc++/visit_each.h
Warning:line 98, column 64
identical expressions on both sides of logical operator
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-084858-6149-1 -x c++ procman.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright 2002, The libsigc++ Development Team
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18#ifndef _SIGC_VISIT_EACH_HPP_
19#define _SIGC_VISIT_EACH_HPP_
20
21#include <sigc++/type_traits.h>
22#include <type_traits>
23
24namespace sigc {
25
26#ifndef DOXYGEN_SHOULD_SKIP_THIS
27namespace internal {
28
29//This should really be an inner class of limit_derived_target, without the T_limit template type,
30//But the SUN CC 5.7 (not earlier versions) compiler finds it ambiguous when we specify a particular specialization of it.
31//and does not seem to allow us to tell it explicitly that it's an inner class.
32template <bool I_derived, class T_type, class T_limit>
33struct with_type;
34
35//Specialization for I_derived = false
36template <class T_type, class T_limit> struct
37with_type<false, T_type, T_limit>
38{
39 static void execute_(const T_type&, const T_limit&) {}
40};
41
42//Specialization for I_derived = true
43template <class T_type, class T_limit>
44struct with_type<true, T_type, T_limit>
45{
46 static void execute_(const T_type& _A_type, const T_limit& _A_action)
47 { _A_action.action_(_A_type); }
48};
49
50
51/// Helper struct for visit_each_type().
52template <class T_target, class T_action>
53struct limit_derived_target
54{
55 typedef limit_derived_target<T_target, T_action> T_self;
56
57 template <class T_type>
58 void operator()(const T_type& _A_type) const
59 {
60 with_type<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
61 }
62
63 limit_derived_target(const T_action& _A_action)
64 : action_(_A_action)
65 {}
66
67 T_action action_;
68};
69
70// Specialization for T_target pointer types, to provide a slightly different execute_() implementation.
71
72template <bool I_derived, class T_type, class T_limit>
73struct with_type_pointer;
74
75//Specialization for I_derived = false
76template <class T_type, class T_limit>
77struct with_type_pointer<false, T_type, T_limit>
78{
79 static void execute_(const T_type&, const T_limit&) {}
80};
81
82//Specialization for I_derived = true
83template <class T_type, class T_limit>
84struct with_type_pointer<true, T_type, T_limit>
85{
86 static void execute_(const T_type& _A_type, const T_limit& _A_action)
87 { _A_action.action_(&_A_type); }
88};
89
90template <class T_target, class T_action>
91struct limit_derived_target<T_target*, T_action>
92{
93 typedef limit_derived_target<T_target*, T_action> T_self;
94
95 template <class T_type>
96 void operator()(const T_type& _A_type) const
97 {
98 with_type_pointer<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
identical expressions on both sides of logical operator
99 }
100
101 limit_derived_target(const T_action& _A_action)
102 : action_(_A_action)
103 {}
104
105 T_action action_;
106};
107
108} /* namespace internal */
109#endif // DOXYGEN_SHOULD_SKIP_THIS
110
111// struct visitor was introduced as a result of https://bugzilla.gnome.org/show_bug.cgi?id=724496
112// The advantage of using specializations of a template struct instead of overloads of
113// a template function is described by Herb Sutter in http://www.gotw.ca/publications/mill17.htm
114// In libsigc++ the main reason for using this technique is that we can avoid using ADL
115// (argument-dependent lookup), and therefore there is no risk that a visit_each() overload
116// in e.g. Boost is selected by mistake.
117
118/** sigc::visitor<T_functor>::do_visit_each() performs a functor on each of the targets of a functor.
119 * All unknown types just call @a _A_action on them.
120 * Add specializations that specialize the @a T_functor argument for your own
121 * functor types, so that subobjects get visited. This is needed to enable
122 * auto-disconnection support for your functor types.
123 *
124 * @par Example:
125 * @code
126 * namespace some_ns
127 * {
128 * struct some_functor
129 * {
130 * void operator()() {}
131 * some_possibly_sigc_trackable_derived_type some_data_member;
132 * some_other_functor_type some_other_functor;
133 * };
134 * }
135 *
136 * namespace sigc
137 * {
138 * template <>
139 * struct visitor<some_ns::some_functor>
140 * {
141 * template <class T_action>
142 * static void do_visit_each(const T_action& _A_action,
143 * const some_ns::some_functor& _A_target)
144 * {
145 * sigc::visit_each(_A_action, _A_target.some_data_member);
146 * sigc::visit_each(_A_action, _A_target.some_other_functor);
147 * }
148 * };
149 * }
150 * @endcode
151 *
152 * @ingroup sigcfunctors
153 */
154template <class T_functor>
155struct visitor
156{
157 template <class T_action>
158 static void do_visit_each(const T_action& _A_action, const T_functor& _A_functor)
159 {
160 _A_action(_A_functor);
161 }
162};
163
164/** This function performs a functor on each of the targets of a functor.
165 *
166 * @ingroup sigcfunctors
167 */
168template <class T_action, class T_functor>
169void visit_each(const T_action& _A_action, const T_functor& _A_functor)
170{ sigc::visitor<T_functor>::do_visit_each(_A_action, _A_functor); }
171
172/** This function performs a functor on each of the targets
173 * of a functor limited to a restricted type.
174 *
175 * @ingroup sigcfunctors
176 */
177template <class T_type, class T_action, class T_functor>
178void visit_each_type(const T_action& _A_action, const T_functor& _A_functor)
179{
180 typedef internal::limit_derived_target<T_type, T_action> type_limited_action;
181
182 type_limited_action limited_action(_A_action);
183
184 //specifying the types of the template specialization prevents disconnection of bound trackable references (such as with std::ref()),
185 //probably because the visit_each<> specializations take various different template types,
186 //in various sequences, and we are probably specifying only a subset of them with this.
187 //
188 //But this is required by the AIX (and maybe IRIX MipsPro and Tru64) compilers.
189 //I guess that std::ref() therefore does not work on those platforms. murrayc
190 // sigc::visit_each<type_limited_action, T_functor>(limited_action, _A_functor);
191
192 //g++ (even slightly old ones) is our primary platform, so we could use the non-crashing version.
193 //However, the explicit version also fixes a crash in a slightly more common case: http://bugzilla.gnome.org/show_bug.cgi?id=169225
194 //Users (and distributors) of libsigc++ on AIX (and maybe IRIX MipsPro and Tru64) do
195 //need to use the version above instead, to allow compilation.
196
197 //Added 2014-03-20: The preceding comment probably does not apply any more,
198 //now when the visit_each<>() overloads have been replaced by visitor<> specializations.
199 //It's probably safe to add explicit template parameters on calls to visit_each(),
200 //visit_each_type() and visitor::do_visit_each(), if necessary.
201
202 sigc::visit_each(limited_action, _A_functor);
203}
204
205} /* namespace sigc */
206#endif
diff --git a/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-77634b.html b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-77634b.html new file mode 100644 index 00000000..075bfb5f --- /dev/null +++ b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-77634b.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 384, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-084858-6149-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-7bbc8c.html b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-7bbc8c.html new file mode 100644 index 00000000..2a2e341a --- /dev/null +++ b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-7bbc8c.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 456, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-084858-6149-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-7ce786.html b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-7ce786.html new file mode 100644 index 00000000..abd758cb --- /dev/null +++ b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-7ce786.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 422, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-084858-6149-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-802eaf.html b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-802eaf.html new file mode 100644 index 00000000..abde0c24 --- /dev/null +++ b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-802eaf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 13, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-084858-6149-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
This statement is never executed
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-8e6c9c.html b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-8e6c9c.html new file mode 100644 index 00000000..63add696 --- /dev/null +++ b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-8e6c9c.html @@ -0,0 +1,1200 @@ + + + +disks.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/disks.cpp
Warning:line 201, column 13
Value stored to 'res' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name disks.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-084858-6149-1 -x c++ disks.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#ifdef __linux__1
4#include <mntent.h>
5#endif // __linux__
6
7#include <giomm.h>
8#include <giomm/themedicon.h>
9#include <gtk/gtk.h>
10#include <glibtop/mountlist.h>
11#include <glibtop/fsusage.h>
12#include <glib/gi18n.h>
13
14#include "procman.h"
15#include "disks.h"
16#include "util.h"
17#include "interface.h"
18#include "iconthemewrapper.h"
19
20namespace
21{
22 const unsigned DISK_ICON_SIZE = 24;
23}
24
25enum DiskColumns
26{
27 /* string columns* */
28 DISK_DEVICE,
29 DISK_DIR,
30 DISK_TYPE,
31 DISK_SUBVOLUME,
32 DISK_TOTAL,
33 DISK_FREE,
34 DISK_AVAIL,
35 /* USED has to be the last column */
36 DISK_USED,
37 // then unvisible columns
38 /* Surface column */
39 DISK_ICON,
40 /* numeric columns */
41 DISK_USED_PERCENTAGE,
42 DISK_N_COLUMNS
43};
44
45
46
47static void
48fsusage_stats(const glibtop_fsusage *buf,
49 guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
50 gint *percentage)
51{
52 guint64 total = buf->blocks * buf->block_size;
53
54 if (!total) {
55 /* not a real device */
56 *btotal = *bfree = *bavail = *bused = 0ULL;
57 *percentage = 0;
58 } else {
59 int percent;
60 *btotal = total;
61 *bfree = buf->bfree * buf->block_size;
62 *bavail = buf->bavail * buf->block_size;
63 *bused = *btotal - *bfree;
64 /* percent = 100.0f * *bused / *btotal; */
65 percent = 100 * *bused / (*bused + *bavail);
66 *percentage = CLAMP(percent, 0, 100)(((percent) > (100)) ? (100) : (((percent) < (0)) ? (0)
: (percent)))
;
67 }
68}
69
70
71namespace
72{
73 string get_icon_for_path(const std::string& path)
74 {
75 using namespace Glib;
76 using namespace Gio;
77
78 // FIXME: I don't know whether i should use Volume or Mount or UnixMount
79 // all i need an icon name.
80 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
81
82 std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
83
84 for (size_t i = 0; i != mounts.size(); ++i) {
85 if (mounts[i]->get_name() != path)
86 continue;
87
88 RefPtr<Icon> icon = mounts[i]->get_icon();
89 RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
90
91 if (themed_icon) {
92 char* name = 0;
93 // FIXME: not wrapped yet
94 g_object_get(G_OBJECT(themed_icon->gobj())((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((themed_icon->gobj())), (((GType) ((20) << (2)))
)))))
, "name", &name, NULL__null);
95 return make_string(name);
96 }
97 }
98
99 return "";
100 }
101}
102
103
104static Glib::RefPtr<Gdk::Pixbuf>
105get_icon_for_device(const char *mountpoint)
106{
107 procman::IconThemeWrapper icon_theme;
108 string icon_name = get_icon_for_path(mountpoint);
109 if (icon_name == "")
110 // FIXME: defaults to a safe value
111 icon_name = "drive-harddisk"; // get_icon_for_path("/");
112 return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
113}
114
115
116static gboolean
117find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
118 GtkTreeIter *result)
119{
120 GtkTreeIter iter;
121 gboolean found = FALSE(0);
122
123 if (gtk_tree_model_get_iter_first(model, &iter)) {
124 do {
125 char *dir;
126
127 gtk_tree_model_get(model, &iter,
128 DISK_DIR, &dir,
129 -1);
130
131 if (dir && !strcmp(dir, mountpoint)) {
132 *result = iter;
133 found = TRUE(!(0));
134 }
135
136 g_free(dir);
137
138 } while (!found && gtk_tree_model_iter_next(model, &iter));
139 }
140
141 return found;
142}
143
144
145
146static void
147remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
148{
149 GtkTreeIter iter;
150
151 if (!gtk_tree_model_get_iter_first(model, &iter))
152 return;
153
154 while (true) {
155 char *dir;
156 guint i;
157 gboolean found = FALSE(0);
158
159 gtk_tree_model_get(model, &iter,
160 DISK_DIR, &dir,
161 -1);
162
163 for (i = 0; i != n; ++i) {
164 if (!strcmp(dir, entries[i].mountdir)) {
165 found = TRUE(!(0));
166 break;
167 }
168 }
169
170 g_free(dir);
171
172 if (!found) {
173 if (!gtk_list_store_remove(GTK_LIST_STORE(model)((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_list_store_get_type ()))))))
, &iter))
174 break;
175 else
176 continue;
177 }
178
179 if (!gtk_tree_model_iter_next(model, &iter))
180 break;
181 }
182}
183
184#ifdef __linux__1
185static char *
186get_mount_opt(const glibtop_mountentry *entry, const char* opt)
187{
188 char *opt_value = NULL__null;
189 const struct mntent *mnt;
190 FILE *fp;
191
192 if (!(fp = setmntent(MOUNTED"/etc/mtab", "r"))) {
193 goto out;
194 }
195
196 while ((mnt = getmntent(fp))) {
197 if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
198 (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
199 char *res;
200
201 res = hasmntopt(mnt, "subvol");
Value stored to 'res' is never read
202 if ((res = hasmntopt(mnt, "subvol")) != NULL__null) {
203 char **strs = g_strsplit_set(res, "=", 2);
204
205 if (g_strv_length(strs) == 2) {
206 char *value = strs[1];
207 if (g_strcmp0 (value,"/root") == 0)
208 opt_value = g_strdup("/")g_strdup_inline ("/");
209 else
210 opt_value = g_strdup(strs[1])g_strdup_inline (strs[1]);
211 g_strfreev(strs);
212 }
213 }
214 break;
215 }
216 }
217
218 endmntent(fp);
219
220 out:
221 return opt_value;
222}
223#endif // __linux__
224
225
226static void
227add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
228{
229 Glib::RefPtr<Gdk::Pixbuf> pixbuf;
230 cairo_surface_t *surface;
231 GtkTreeIter iter;
232 glibtop_fsusage usage;
233 guint64 bused, bfree, bavail, btotal;
234 gint percentage;
235#ifdef __linux__1
236 char *subvol = NULL__null;
237#endif // __linux__
238
239 glibtop_get_fsusage(&usage, entry->mountdir);
240
241 if (not show_all_fs and usage.blocks == 0) {
242 if (find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
243 gtk_list_store_remove(list, &iter);
244 return;
245 }
246
247 fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
248#ifdef __linux__1
249 subvol = get_mount_opt(entry, "subvol");
250#endif // __linux__
251 pixbuf = get_icon_for_device(entry->mountdir);
252 surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL__null);
253
254 /* if we can find a row with the same mountpoint, we get it but we
255 still need to update all the fields.
256 This makes selection persistent.
257 */
258 if (!find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
259 gtk_list_store_append(list, &iter);
260
261 gtk_list_store_set(list, &iter,
262 DISK_ICON, surface,
263 DISK_DEVICE, entry->devname,
264 DISK_DIR, entry->mountdir,
265 DISK_TYPE, entry->type,
266#ifdef __linux__1
267
268 DISK_SUBVOLUME, subvol != NULL__null ? subvol : "",
269#else
270 DISK_SUBVOLUME, "",
271#endif // __linux__
272 DISK_USED_PERCENTAGE, percentage,
273 DISK_TOTAL, btotal,
274 DISK_FREE, bfree,
275 DISK_AVAIL, bavail,
276 DISK_USED, bused,
277 -1);
278#ifdef __linux__1
279 g_free (subvol);
280#endif // __linux__
281}
282
283
284
285int
286cb_update_disks(gpointer data)
287{
288 ProcData *const procdata = static_cast<ProcData*>(data);
289
290 GtkListStore *list;
291 glibtop_mountentry * entries;
292 glibtop_mountlist mountlist;
293 guint i;
294
295 list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)))((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_tree_view_get_model(((((GtkTreeView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((procdata->disk_list)), ((gtk_tree_view_get_type
()))))))))), ((gtk_list_store_get_type ()))))))
;
296
297 entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
298
299 remove_old_disks(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entries, mountlist.number);
300
301 for (i = 0; i < mountlist.number; i++)
302 add_disk(list, &entries[i], procdata->config.show_all_fs);
303
304 g_free(entries);
305
306 return TRUE(!(0));
307}
308
309
310static void
311cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
312{
313 ProcData * const procdata = static_cast<ProcData*>(user_data);
314
315 procman_save_tree_state(procdata->settings,
316 GTK_WIDGET(treeview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_widget_get_type ()))))))
,
317 "disktreenew");
318}
319
320
321static void
322open_dir(GtkTreeView *tree_view,
323 GtkTreePath *path,
324 GtkTreeViewColumn *column,
325 gpointer user_data)
326{
327 GtkTreeIter iter;
328 GtkTreeModel *model;
329 char *dir, *url;
330
331 model = gtk_tree_view_get_model(tree_view);
332
333 if (!gtk_tree_model_get_iter(model, &iter, path)) {
334 char *p;
335 p = gtk_tree_path_to_string(path);
336 g_warning("Cannot get iter for path '%s'\n", p);
337 g_free(p);
338 return;
339 }
340
341 gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
342
343 url = g_strdup_printf("file://%s", dir);
344
345 GError* error = 0;
346 if (!g_app_info_launch_default_for_uri(url, NULL__null, &error)) {
347 g_warning("Cannot open '%s' : %s\n", url, error->message);
348 g_error_free(error);
349 }
350
351 g_free(url);
352 g_free(dir);
353}
354
355static guint timeout_id = 0;
356static GtkTreeViewColumn *current_column;
357
358static gboolean
359save_column_width (gpointer data)
360{
361 gint width;
362 gchar *key;
363 int id;
364 GSettings *settings;
365
366 settings = g_settings_get_child (G_SETTINGS (data)((((GSettings*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((g_settings_get_type ()))))))
, "disktreenew");
367 id = gtk_tree_view_column_get_sort_column_id (current_column);
368 width = gtk_tree_view_column_get_width (current_column);
369
370 key = g_strdup_printf ("col-%d-width", id);
371 g_settings_set_int(settings, key, width);
372 g_free (key);
373
374 if (timeout_id) {
375 g_source_remove (timeout_id);
376 timeout_id = 0;
377 }
378
379 return FALSE(0);
380}
381
382static void
383cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
384{
385 current_column = GTK_TREE_VIEW_COLUMN(widget)((((GtkTreeViewColumn*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((widget)), ((gtk_tree_view_column_get_type (
)))))))
;
386
387 if (timeout_id)
388 g_source_remove (timeout_id);
389
390 timeout_id = g_timeout_add (250, save_column_width, data);
391}
392
393void
394create_disk_view(ProcData *procdata, GtkBuilder *builder)
395{
396 GtkWidget *scrolled;
397 GtkWidget *disk_tree;
398 GtkListStore *model;
399 GtkTreeViewColumn *col;
400 GtkCellRenderer *cell;
401 guint i;
402
403 const gchar * const titles[] = {
404 N_("Device")("Device"),
405 N_("Directory")("Directory"),
406 N_("Type")("Type"),
407 N_("SubVolume")("SubVolume"),
408 N_("Total")("Total"),
409 N_("Free")("Free"),
410 N_("Available")("Available"),
411 N_("Used")("Used")
412 };
413
414 scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "disks_scrolled"))), ((
gtk_widget_get_type ()))))))
;
415
416 model = gtk_list_store_new(DISK_N_COLUMNS, /* n columns */
417 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DEVICE */
418 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DIR */
419 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_TYPE */
420 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_SUBVOLUME */
421 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_TOTAL */
422 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_FREE */
423 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_AVAIL */
424 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_USED */
425 CAIRO_GOBJECT_TYPE_SURFACEcairo_gobject_surface_get_type (), /* DISK_ICON */
426 G_TYPE_INT((GType) ((6) << (2)))); /* DISK_USED_PERCENTAGE */
427
428 disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_model_get_type ()))))))
);
429 g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("row-activated"), (((GCallback) (open_dir))), (__null
), __null, (GConnectFlags) 0)
;
430 procdata->disk_list = disk_tree;
431 gtk_container_add(GTK_CONTAINER(scrolled)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((scrolled)), ((gtk_container_get_type ()))))))
, disk_tree);
432 g_object_unref(G_OBJECT(model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
);
433
434 /* icon + device */
435
436 col = gtk_tree_view_column_new();
437 cell = gtk_cell_renderer_pixbuf_new();
438 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
439 gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
440 NULL__null);
441
442 cell = gtk_cell_renderer_text_new();
443 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
444 gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
445 NULL__null);
446 gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE])gettext (titles[DISK_DEVICE]));
447 gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
448 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
449 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
450 gtk_tree_view_column_set_min_width (col, 30);
451 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
452 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
453 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
454
455 /* sizes - used */
456
457 for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
458 cell = gtk_cell_renderer_text_new();
459 col = gtk_tree_view_column_new();
460 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
461 gtk_tree_view_column_set_title(col, _(titles[i])gettext (titles[i]));
462 gtk_tree_view_column_set_sort_column_id(col, i);
463 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
464 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
465 gtk_tree_view_column_set_min_width (col, 30);
466 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
467 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
468 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
469
470 switch (i) {
471 case DISK_TOTAL:
472 case DISK_FREE:
473 case DISK_AVAIL:
474 g_object_set(cell, "xalign", 1.0f, NULL__null);
475 gtk_tree_view_column_set_cell_data_func(col, cell,
476 &procman::storage_size_cell_data_func,
477 GUINT_TO_POINTER(i)((gpointer) (gulong) (i)),
478 NULL__null);
479 break;
480
481 default:
482 gtk_tree_view_column_set_attributes(col, cell,
483 "text", i,
484 NULL__null);
485 break;
486 }
487 }
488
489 /* used + percentage */
490
491 col = gtk_tree_view_column_new();
492 cell = gtk_cell_renderer_text_new();
493 g_object_set(cell, "xalign", 1.0f, NULL__null);
494 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
495 gtk_tree_view_column_set_cell_data_func(col, cell,
496 &procman::storage_size_cell_data_func,
497 GUINT_TO_POINTER(DISK_USED)((gpointer) (gulong) (DISK_USED)),
498 NULL__null);
499
500 cell = gtk_cell_renderer_progress_new();
501 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
502 gtk_tree_view_column_set_attributes(col, cell, "value",
503 DISK_USED_PERCENTAGE, NULL__null);
504 gtk_tree_view_column_set_title(col, _(titles[DISK_USED])gettext (titles[DISK_USED]));
505 gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
506 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
507 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
508 gtk_tree_view_column_set_min_width (col, 150);
509 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
510 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
511 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
512
513 /* numeric sort */
514
515 procman_get_tree_state(procdata->settings, disk_tree,
516 "disktreenew");
517
518 g_signal_connect (G_OBJECT(disk_tree), "columns-changed",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
519 G_CALLBACK(cb_disk_columns_changed), procdata)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
;
520}
diff --git a/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-c673b5.html b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-c673b5.html new file mode 100644 index 00000000..6b3b932e --- /dev/null +++ b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-c673b5.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 564, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-084858-6149-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-d507c5.html b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-d507c5.html new file mode 100644 index 00000000..c05933a0 --- /dev/null +++ b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-d507c5.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 151, column 9
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-084858-6149-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
This statement is never executed
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-e8ff80.html b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-e8ff80.html new file mode 100644 index 00000000..8c9719d0 --- /dev/null +++ b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/report-e8ff80.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 350, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-084858-6149-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/scanview.css b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/scanview.css new file mode 100644 index 00000000..cf8a5a6a --- /dev/null +++ b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/sorttable.js b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/sorttable.js new file mode 100644 index 00000000..32faa078 --- /dev/null +++ b/2023-05-15-084858-6149-1@d2839764fa8b_help-translations/sorttable.js @@ -0,0 +1,492 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse',''); + cell.className = cell.className.replace('sorttable_sorted',''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j=0; j 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } + else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } + else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i=0; i=0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a,b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); + if (isNaN(bb)) bb = 0; + return aa-bb; + }, + sort_alpha: function(a,b) { + if (a[0]==b[0]) return 0; + if (a[0] 0 ) { + var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for(var i = t; i > b; --i) { + if ( comp_func(list[i], list[i-1]) < 0 ) { + var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write(" + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef _PROCMAN_PROCMAN_H_
+#define _PROCMAN_PROCMAN_H_
+
+#include <glibmm/refptr.h>
+#include <cairo-gobject.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+#include <glibtop/cpu.h>
+
+#include <time.h>
+#include <sys/types.h>
+
+#include <map>
+#include <string>
+
+struct ProcInfo;
+struct ProcData;
+struct LoadGraph;
+
+#include "smooth_refresh.h"
+#include "prettytable.h"
+
+#define GSM_GSETTINGS_SCHEMA "org.mate.system-monitor"
+
+enum
+{
+    ALL_PROCESSES,
+    MY_PROCESSES,
+    ACTIVE_PROCESSES
+};
+
+enum
+{
+    VERY_HIGH_PRIORITY,
+    HIGH_PRIORITY,
+    NORMAL_PRIORITY,
+    LOW_PRIORITY,
+    VERY_LOW_PRIORITY,
+    CUSTOM_PRIORITY
+};
+
+static const unsigned MIN_UPDATE_INTERVAL =   1 * 1000;
+static const unsigned MAX_UPDATE_INTERVAL = 100 * 1000;
+
+enum ProcmanTab
+{
+    PROCMAN_TAB_SYSINFO,
+    PROCMAN_TAB_PROCESSES,
+    PROCMAN_TAB_RESOURCES,
+    PROCMAN_TAB_DISKS
+};
+
+struct ProcConfig
+{
+    gint        width;
+    gint        height;
+    gint        xpos;
+    gint        ypos;
+    gboolean    maximized;
+    gboolean    show_kill_warning;
+    gboolean    show_tree;
+    gboolean    show_all_fs;
+    int         update_interval;
+    int         graph_update_interval;
+    int         disks_update_interval;
+    gint        whose_process;
+    gint        current_tab;
+    GdkRGBA     cpu_color[GLIBTOP_NCPU];
+    GdkRGBA     mem_color;
+    GdkRGBA     swap_color;
+    GdkRGBA     net_in_color;
+    GdkRGBA     net_out_color;
+    GdkRGBA     bg_color;
+    GdkRGBA     frame_color;
+    gint        num_cpus;
+    bool solaris_mode;
+    bool network_in_bits;
+};
+
+struct MutableProcInfo
+{
+MutableProcInfo()<--- Member variable 'MutableProcInfo::cgroup_name' is not initialized in the constructor.<--- Member variable 'MutableProcInfo::unit' is not initialized in the constructor.<--- Member variable 'MutableProcInfo::session' is not initialized in the constructor.<--- Member variable 'MutableProcInfo::seat' is not initialized in the constructor.
+  : disk_write_bytes_current(0ULL),
+    disk_read_bytes_current(0ULL),
+    disk_write_bytes_total(0ULL),
+    disk_read_bytes_total(0ULL),
+    status(0U)
+    { }
+
+    std::string user;
+
+    gchar wchan[40];
+
+    // all these members are filled with libgtop which uses
+    // guint64 (to have fixed size data) but we don't need more
+    // than an unsigned long (even for 32bit apps on a 64bit
+    // kernel) as these data are amounts, not offsets.
+    gulong vmsize;
+    gulong memres;
+    gulong memshared;
+    gulong memwritable;
+    gulong mem;
+
+#ifdef HAVE_WNCK
+    // wnck gives an unsigned long
+    gulong memxserver;
+#endif
+
+    gulong start_time;
+    guint64 cpu_time;
+    guint64 disk_write_bytes_current;
+    guint64 disk_read_bytes_current;
+    guint64 disk_write_bytes_total;
+    guint64 disk_read_bytes_total;
+    guint status;
+    guint pcpu;
+    gint nice;
+    gchar *cgroup_name;
+
+    gchar *unit;
+    gchar *session;
+    gchar *seat;
+
+    std::string owner;
+};
+
+class ProcInfo
+: public MutableProcInfo
+{
+    /* undefined */ ProcInfo& operator=(const ProcInfo&);
+    /* undefined */ ProcInfo(const ProcInfo&);
+
+    typedef std::map<guint, std::string> UserMap;
+    /* cached username */
+    static UserMap users;
+
+  public:
+
+    // TODO: use a set instead
+    // sorted by pid. The map has a nice property : it is sorted
+    // by pid so this helps a lot when looking for the parent node
+    // as ppid is nearly always < pid.
+    typedef std::map<pid_t, ProcInfo*> List;
+    typedef List::iterator Iterator;
+
+    static List all;
+
+    static ProcInfo* find(pid_t pid);
+    static Iterator begin() { return ProcInfo::all.begin(); }
+    static Iterator end() { return ProcInfo::all.end(); }
+
+    ProcInfo(pid_t pid);
+    ~ProcInfo();
+    // adds one more ref to icon
+    void set_icon(Glib::RefPtr<Gdk::Pixbuf> icon);
+    void set_user(guint uid);
+    std::string lookup_user(guint uid);
+
+    GtkTreeIter      node;
+    cairo_surface_t *surface;
+    gchar           *tooltip;
+    gchar           *name;
+    gchar           *arguments;
+    gchar           *security_context;
+
+    const pid_t      pid;
+    pid_t            ppid;
+    guint            uid;
+
+// private:
+    // tracks cpu time per process keeps growing because if a
+    // ProcInfo is deleted this does not mean that the process is
+    // not going to be recreated on the next update.  For example,
+    // if dependencies + (My or Active), the proclist is cleared
+    // on each update.  This is a workaround
+    static std::map<pid_t, guint64> cpu_times;
+};
+
+struct ProcData
+{
+    // lazy initialization
+    static ProcData* get_instance();
+
+    GtkUIManager    *uimanager;
+    GtkActionGroup    *action_group;
+    GtkWidget    *statusbar;
+    gint        tip_message_cid;
+    GtkWidget    *tree;
+    GtkWidget    *loadavg;
+    GtkWidget    *endprocessbutton;
+    GtkWidget    *popup_menu;
+    GtkWidget    *disk_list;
+    GtkWidget    *notebook;
+    ProcConfig    config;
+    LoadGraph    *cpu_graph;
+    LoadGraph    *mem_graph;
+    LoadGraph    *net_graph;
+    gint        cpu_label_fixed_width;
+    gint        net_label_fixed_width;
+    ProcInfo    *selected_process;
+    GtkTreeSelection *selection;
+    guint        timeout;
+    guint        disk_timeout;
+
+    PrettyTable    pretty_table;
+
+    GSettings       *settings;
+    GtkWidget        *app;
+    GtkUIManager    *menu;
+
+    unsigned    frequency;
+
+    SmoothRefresh  *smooth_refresh;
+
+    guint64 cpu_total_time;
+    guint64 cpu_total_time_last;
+
+    gboolean terminating;
+
+private:
+    ProcData();
+    /* undefined */ ProcData(const ProcData &);
+    /* undefined */ ProcData& operator=(const ProcData &);
+};
+
+void        procman_save_config (ProcData *data);
+void        procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+gboolean    procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+
+struct ReniceArgs
+{
+    ProcData *procdata;
+    int nice_value;
+};
+
+struct KillArgs
+{
+    ProcData *procdata;
+    int signal;
+};
+
+#endif /* _PROCMAN_PROCMAN_H_ */
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/1.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/1.html new file mode 100644 index 00000000..b83a4070 --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/1.html @@ -0,0 +1,435 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
#ifndef _PROCMAN_SMOOTH_REFRESH
+#define _PROCMAN_SMOOTH_REFRESH
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <string>
+
+using std::string;
+
+class SmoothRefresh
+{
+  public:
+
+    /*
+      smooth_refresh_new
+
+      @config_interval : pointer to config_interval so we can observe
+      config_interval changes.
+
+      @return : initialized SmoothRefresh
+    */
+    SmoothRefresh(GSettings *a_settings);
+
+    ~SmoothRefresh();
+
+    /*
+      smooth_refresh_reset
+
+      Resets state and re-read config_interval
+    */
+    void reset();
+
+    /*
+      smooth_refresh_get
+
+      Computes the new refresh_interval so that CPU usage is lower than
+      SMOOTH_REFRESH_PCPU.
+
+      @new_interval : where the new refresh_interval is stored.
+
+      @return : TRUE is refresh_interval has changed. The new refresh_interval
+      is stored in @new_interval. Else FALSE;
+    */
+    bool get(guint &new_interval);
+
+    static const string KEY;
+    static const bool KEY_DEFAULT_VALUE;
+
+  private:
+
+    unsigned get_own_cpu_usage();
+
+    static void status_changed(GSettings *settings,
+                               const gchar *key,
+                               gpointer user_data);
+
+    void load_settings_value(const gchar *key);
+
+    /*
+      fuzzy logic:
+      - decrease refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_LO
+      - increase refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_HI
+
+    */
+
+    enum
+    {
+        PCPU_HI = 22,
+        PCPU_LO = 18
+    };
+
+    /*
+      -self : procman's PID (so we call getpid() only once)
+
+      -interval : current refresh interval
+
+      -config_interval : pointer to the configuration refresh interval.
+      Used to watch configuration changes
+
+      -interval >= -config_interval
+
+      -last_pcpu : to avoid spikes, the last CPU%. See PCPU_{LO,HI}
+
+      -last_total_time:
+      -last_cpu_time: Save last cpu and process times to compute CPU%
+    */
+
+    GSettings *settings;
+    bool active;
+    guint connection;
+    guint interval;
+    unsigned  last_pcpu;
+    guint64 last_total_time;
+    guint64 last_cpu_time;
+};
+
+#endif /* _PROCMAN_SMOOTH_REFRESH */
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/10.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/10.html new file mode 100644 index 00000000..cb5e0f54 --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/10.html @@ -0,0 +1,1067 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
#include <gio/gio.h>
+
+#if defined (__ELF__) && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
+# define SECTION __attribute__ ((section (".gresource.msm"), aligned (8)))
+#else
+# define SECTION
+#endif
+
+static const SECTION union { const guint8 data[3353]; const double alignment; void * const ptr;}  msm_resource_data = { {<--- union member 'Anonymous0::alignment' is never used.<--- union member 'Anonymous0::ptr' is never used.
+  0107, 0126, 0141, 0162, 0151, 0141, 0156, 0164, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0030, 0000, 0000, 0000, 0310, 0000, 0000, 0000, 0000, 0000, 0000, 0050, 0006, 0000, 0000, 0000, 
+  0000, 0000, 0000, 0000, 0001, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0005, 0000, 0000, 0000, 0376, 0236, 0033, 0101, 0005, 0000, 0000, 0000, 
+  0310, 0000, 0000, 0000, 0024, 0000, 0114, 0000, 0334, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 
+  0113, 0120, 0220, 0013, 0002, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 0004, 0000, 0114, 0000, 
+  0350, 0000, 0000, 0000, 0354, 0000, 0000, 0000, 0324, 0265, 0002, 0000, 0377, 0377, 0377, 0377, 
+  0354, 0000, 0000, 0000, 0001, 0000, 0114, 0000, 0360, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 
+  0173, 0250, 0316, 0037, 0000, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 0014, 0000, 0166, 0000, 
+  0000, 0001, 0000, 0000, 0034, 0006, 0000, 0000, 0234, 0164, 0275, 0021, 0000, 0000, 0000, 0000, 
+  0034, 0006, 0000, 0000, 0016, 0000, 0166, 0000, 0060, 0006, 0000, 0000, 0017, 0015, 0000, 0000, 
+  0201, 0321, 0040, 0031, 0001, 0000, 0000, 0000, 0017, 0015, 0000, 0000, 0005, 0000, 0114, 0000, 
+  0024, 0015, 0000, 0000, 0030, 0015, 0000, 0000, 0155, 0141, 0164, 0145, 0055, 0163, 0171, 0163, 
+  0164, 0145, 0155, 0055, 0155, 0157, 0156, 0151, 0164, 0157, 0162, 0057, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0157, 0162, 0147, 0057, 0005, 0000, 0000, 0000, 0057, 0000, 0000, 0000, 
+  0001, 0000, 0000, 0000, 0151, 0156, 0164, 0145, 0162, 0146, 0141, 0143, 0145, 0056, 0165, 0151, 
+  0242, 0073, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0133, 0133, 0163, 0352, 0066, 
+  0020, 0176, 0317, 0257, 0160, 0375, 0332, 0161, 0010, 0227, 0320, 0164, 0006, 0070, 0323, 0166, 
+  0232, 0364, 0241, 0347, 0114, 0046, 0344, 0114, 0037, 0031, 0331, 0136, 0260, 0212, 0054, 0271, 
+  0222, 0314, 0345, 0337, 0237, 0065, 0066, 0004, 0002, 0370, 0102, 0210, 0061, 0224, 0067, 0154, 
+  0257, 0054, 0355, 0267, 0253, 0335, 0317, 0253, 0245, 0363, 0145, 0346, 0063, 0143, 0002, 0122, 
+  0121, 0301, 0273, 0146, 0375, 0366, 0316, 0064, 0200, 0073, 0302, 0245, 0174, 0324, 0065, 0277, 
+  0277, 0076, 0132, 0017, 0346, 0227, 0336, 0115, 0347, 0047, 0313, 0062, 0236, 0200, 0203, 0044, 
+  0032, 0134, 0143, 0112, 0265, 0147, 0214, 0030, 0161, 0301, 0150, 0336, 0066, 0037, 0156, 0033, 
+  0206, 0145, 0241, 0020, 0345, 0032, 0344, 0220, 0070, 0320, 0353, 0110, 0370, 0057, 0244, 0022, 
+  0224, 0301, 0250, 0335, 0065, 0107, 0172, 0374, 0263, 0371, 0066, 0113, 0363, 0266, 0321, 0062, 
+  0153, 0275, 0216, 0260, 0377, 0005, 0107, 0033, 0016, 0043, 0112, 0165, 0315, 0047, 0075, 0376, 
+  0207, 0162, 0127, 0114, 0115, 0203, 0272, 0135, 0323, 0047, 0224, 0017, 0246, 0361, 0215, 0136, 
+  0047, 0220, 0042, 0000, 0251, 0347, 0006, 0047, 0076, 0164, 0115, 0207, 0160, 0153, 0050, 0234, 
+  0120, 0231, 0275, 0107, 0302, 0024, 0164, 0152, 0113, 0201, 0055, 0121, 0115, 0065, 0003, 0323, 
+  0320, 0222, 0160, 0305, 0210, 0046, 0066, 0303, 0233, 0163, 0300, 0221, 0375, 0271, 0322, 0340, 
+  0033, 0137, 0005, 0247, 0132, 0310, 0224, 0127, 0270, 0060, 0044, 0041, 0323, 0326, 0224, 0272, 
+  0332, 0063, 0173, 0255, 0326, 0135, 0016, 0141, 0017, 0350, 0310, 0323, 0050, 0375, 0353, 0375, 
+  0272, 0264, 0343, 0121, 0346, 0356, 0120, 0375, 0167, 0061, 0133, 0323, 0333, 0306, 0253, 0255, 
+  0067, 0117, 0250, 0242, 0270, 0172, 0263, 0367, 0052, 0303, 0064, 0215, 0013, 0200, 0043, 0044, 
+  0005, 0256, 0211, 0106, 0263, 0230, 0075, 0264, 0217, 0246, 0016, 0141, 0073, 0226, 0033, 0060, 
+  0264, 0252, 0047, 0230, 0013, 0022, 0355, 0126, 0113, 0356, 0356, 0323, 0345, 0233, 0320, 0140, 
+  0013, 0061, 0216, 0025, 0342, 0313, 0253, 0143, 0050, 0224, 0041, 0351, 0023, 0071, 0242, 0334, 
+  0122, 0232, 0110, 0204, 0276, 0336, 0310, 0026, 0005, 0356, 0346, 0023, 0324, 0042, 0170, 0057, 
+  0230, 0151, 0113, 0065, 0127, 0224, 0017, 0105, 0151, 0346, 0364, 0140, 0026, 0220, 0110, 0241, 
+  0214, 0127, 0116, 0162, 0312, 0331, 0102, 0242, 0305, 0227, 0176, 0237, 0212, 0222, 0012, 0210, 
+  0203, 0061, 0143, 0017, 0104, 0251, 0376, 0263, 0373, 0141, 0055, 0206, 0365, 0235, 0264, 0241, 
+  0347, 0101, 0264, 0251, 0211, 0155, 0356, 0000, 0376, 0157, 0142, 0003, 0333, 0204, 0236, 0055, 
+  0156, 0225, 0001, 0176, 0074, 0323, 0376, 0100, 0263, 0076, 0164, 0245, 0034, 0242, 0066, 0106, 
+  0330, 0266, 0243, 0026, 0261, 0255, 0041, 0145, 0154, 0307, 0264, 0265, 0325, 0230, 0254, 0175, 
+  0270, 0362, 0103, 0034, 0354, 0374, 0037, 0234, 0060, 0063, 0234, 0355, 0165, 0332, 0207, 0074, 
+  0373, 0172, 0315, 0275, 0230, 0040, 0356, 0200, 0114, 0106, 0045, 0372, 0227, 0107, 0030, 0035, 
+  0241, 0136, 0213, 0340, 0126, 0310, 0231, 0226, 0100, 0147, 0315, 0020, 0073, 0134, 0306, 0212, 
+  0003, 0241, 0150, 0014, 0360, 0335, 0141, 0136, 0331, 0167, 0244, 0140, 0014, 0334, 0365, 0144, 
+  0037, 0071, 0050, 0050, 0005, 0152, 0240, 0222, 0247, 0145, 0144, 0213, 0143, 0173, 0252, 0362, 
+  0010, 0152, 0144, 0105, 0041, 0312, 0354, 0121, 0236, 0073, 0016, 0236, 0312, 0200, 0365, 0003, 
+  0303, 0112, 0250, 0065, 0016, 0137, 0030, 0016, 0323, 0147, 0142, 0073, 0073, 0276, 0133, 0040, 
+  0054, 0376, 0311, 0135, 0143, 0360, 0034, 0217, 0116, 0131, 0157, 0250, 0300, 0042, 0116, 0264, 
+  0142, 0213, 0004, 0001, 0020, 0174, 0221, 0003, 0331, 0130, 0034, 0337, 0135, 0044, 0070, 0100, 
+  0047, 0240, 0254, 0204, 0342, 0145, 0373, 0127, 0262, 0143, 0021, 0244, 0014, 0375, 0102, 0216, 
+  0036, 0301, 0050, 0337, 0261, 0334, 0123, 0071, 0107, 0043, 0335, 0071, 0062, 0227, 0125, 0314, 
+  0315, 0162, 0347, 0365, 0105, 0052, 0253, 0102, 0122, 0177, 0136, 0206, 0254, 0102, 0306, 0332, 
+  0203, 0312, 0247, 0146, 0177, 0374, 0014, 0273, 0046, 0377, 0242, 0214, 0165, 0077, 0234, 0116, 
+  0020, 0126, 0347, 0373, 0154, 0257, 0116, 0167, 0005, 0011, 0115, 0244, 0125, 0025, 0266, 0325, 
+  0037, 0317, 0337, 0215, 0277, 0250, 0302, 0017, 0362, 0171, 0312, 0370, 0131, 0022, 0131, 0067, 
+  0264, 0044, 0132, 0113, 0212, 0151, 0010, 0324, 0332, 0357, 0144, 0300, 0064, 0376, 0032, 0067, 
+  0046, 0204, 0205, 0013, 0267, 0142, 0156, 0124, 0201, 0250, 0255, 0217, 0071, 0063, 0036, 0265, 
+  0341, 0220, 0043, 0111, 0002, 0357, 0154, 0167, 0371, 0301, 0156, 0336, 0376, 0160, 0255, 0342, 
+  0221, 0211, 0351, 0006, 0222, 0103, 0274, 0121, 0032, 0220, 0223, 0175, 0234, 0076, 0265, 0256, 
+  0161, 0377, 0113, 0332, 0354, 0202, 0205, 0076, 0212, 0056, 0041, 0112, 0013, 0231, 0022, 0331, 
+  0152, 0056, 0101, 0037, 0047, 0137, 0040, 0050, 0201, 0133, 0370, 0300, 0212, 0271, 0112, 0063, 
+  0165, 0311, 0263, 0135, 0103, 0322, 0213, 0010, 0300, 0040, 0146, 0172, 0276, 0160, 0121, 0230, 
+  0013, 0176, 0112, 0056, 0204, 0223, 0044, 0144, 0076, 0235, 0301, 0345, 0246, 0072, 0025, 0045, 
+  0372, 0347, 0032, 0370, 0174, 0360, 0057, 0060, 0023, 0107, 0132, 0125, 0041, 0023, 0177, 0005, 
+  0037, 0223, 0260, 0201, 0206, 0067, 0372, 0123, 0022, 0134, 0263, 0162, 0161, 0347, 0274, 0146, 
+  0345, 0174, 0131, 0071, 0072, 0135, 0302, 0004, 0263, 0310, 0134, 0252, 0333, 0302, 0337, 0230, 
+  0231, 0124, 0167, 0161, 0254, 0264, 0015, 0361, 0223, 0244, 0356, 0033, 0306, 0013, 0227, 0055, 
+  0005, 0337, 0002, 0111, 0070, 0257, 0051, 0066, 0022, 0160, 0273, 0100, 0126, 0157, 0147, 0274, 
+  0324, 0023, 0276, 0030, 0001, 0007, 0261, 0253, 0256, 0221, 0043, 0010, 0051, 0334, 0361, 0145, 
+  0326, 0066, 0163, 0342, 0225, 0122, 0143, 0307, 0005, 0027, 0015, 0115, 0231, 0241, 0205, 0301, 
+  0120, 0133, 0030, 0214, 0210, 0343, 0245, 0223, 0035, 0055, 0202, 0225, 0334, 0201, 0201, 0143, 
+  0063, 0003, 0140, 0240, 0075, 0053, 0370, 0343, 0144, 0361, 0271, 0006, 0250, 0037, 0325, 0000, 
+  0007, 0034, 0111, 0235, 0342, 0341, 0225, 0362, 0136, 0024, 0345, 0255, 0177, 0220, 0125, 0160, 
+  0320, 0027, 0110, 0171, 0043, 0255, 0252, 0100, 0171, 0277, 0201, 0236, 0012, 0071, 0276, 0122, 
+  0335, 0342, 0116, 0171, 0245, 0272, 0173, 0330, 0154, 0073, 0067, 0233, 0215, 0140, 0074, 0031, 
+  0233, 0155, 0345, 0154, 0225, 0151, 0076, 0134, 0062, 0355, 0215, 0217, 0370, 0160, 0252, 0263, 
+  0042, 0137, 0057, 0313, 0125, 0237, 0023, 0377, 0112, 0063, 0203, 0026, 0232, 0260, 0101, 0162, 
+  0336, 0352, 0236, 0225, 0055, 0136, 0243, 0245, 0033, 0057, 0311, 0322, 0253, 0141, 0220, 0372, 
+  0207, 0015, 0242, 0160, 0357, 0237, 0333, 0256, 0350, 0143, 0104, 0377, 0134, 0374, 0357, 0113, 
+  0336, 0020, 0150, 0005, 0175, 0206, 0233, 0241, 0072, 0206, 0070, 0302, 0106, 0300, 0101, 0040, 
+  0267, 0341, 0137, 0034, 0120, 0133, 0121, 0327, 0063, 0050, 0235, 0221, 0045, 0077, 0215, 0322, 
+  0366, 0156, 0112, 0256, 0156, 0154, 0071, 0114, 0334, 0362, 0334, 0070, 0014, 0346, 0337, 0042, 
+  0077, 0360, 0321, 0131, 0336, 0347, 0342, 0200, 0072, 0143, 0220, 0003, 0262, 0172, 0136, 0006, 
+  0244, 0233, 0235, 0007, 0355, 0343, 0065, 0163, 0155, 0300, 0176, 0127, 0071, 0330, 0227, 0241, 
+  0376, 0202, 0101, 0157, 0225, 0016, 0372, 0045, 0026, 0176, 0076, 0122, 0146, 0313, 0255, 0134, 
+  0306, 0262, 0057, 0243, 0050, 0164, 0274, 0126, 0273, 0306, 0061, 0133, 0355, 0242, 0276, 0261, 
+  0052, 0124, 0145, 0136, 0100, 0211, 0120, 0072, 0007, 0167, 0332, 0065, 0112, 0353, 0264, 0033, 
+  0226, 0327, 0150, 0127, 0106, 0143, 0134, 0073, 0317, 0327, 0363, 0256, 0166, 0156, 0227, 0252, 
+  0361, 0265, 0225, 0273, 0102, 0045, 0274, 0002, 0273, 0245, 0171, 0314, 0020, 0062, 0254, 0106, 
+  0004, 0171, 0244, 0014, 0214, 0370, 0137, 0070, 0207, 0006, 0221, 0346, 0261, 0202, 0310, 0231, 
+  0235, 0074, 0364, 0061, 0160, 0204, 0312, 0046, 0062, 0141, 0207, 0253, 0313, 0112, 0237, 0100, 
+  0064, 0076, 0261, 0153, 0054, 0113, 0252, 0170, 0136, 0337, 0276, 0361, 0366, 0117, 0332, 0233, 
+  0037, 0325, 0360, 0311, 0023, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0160, 0162, 0145, 0146, 
+  0145, 0162, 0145, 0156, 0143, 0145, 0163, 0056, 0165, 0151, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0065, 0123, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0134, 0335, 0162, 0342, 0066, 
+  0024, 0276, 0357, 0123, 0250, 0276, 0355, 0050, 0004, 0262, 0155, 0167, 0072, 0301, 0073, 0335, 
+  0335, 0046, 0335, 0231, 0266, 0263, 0323, 0354, 0266, 0227, 0036, 0331, 0076, 0140, 0155, 0204, 
+  0344, 0112, 0002, 0102, 0257, 0372, 0054, 0175, 0264, 0076, 0111, 0217, 0177, 0010, 0140, 0300, 
+  0066, 0004, 0210, 0041, 0334, 0331, 0346, 0110, 0072, 0072, 0377, 0237, 0216, 0206, 0353, 0067, 
+  0017, 0003, 0101, 0106, 0240, 0015, 0127, 0262, 0353, 0264, 0057, 0056, 0035, 0002, 0062, 0120, 
+  0041, 0227, 0375, 0256, 0363, 0371, 0323, 0015, 0175, 0355, 0274, 0161, 0277, 0272, 0376, 0232, 
+  0122, 0162, 0013, 0022, 0064, 0263, 0020, 0222, 0061, 0267, 0021, 0351, 0013, 0026, 0002, 0271, 
+  0272, 0270, 0172, 0175, 0321, 0041, 0224, 0042, 0021, 0227, 0026, 0164, 0217, 0005, 0340, 0136, 
+  0153, 0370, 0153, 0310, 0065, 0030, 0042, 0270, 0337, 0165, 0372, 0366, 0376, 0033, 0147, 0266, 
+  0312, 0325, 0105, 0347, 0225, 0323, 0162, 0257, 0225, 0377, 0005, 0002, 0113, 0002, 0301, 0214, 
+  0351, 0072, 0267, 0366, 0376, 0303, 0200, 0365, 0301, 0041, 0074, 0354, 0072, 0074, 0171, 0154, 
+  0073, 0356, 0165, 0254, 0125, 0014, 0332, 0116, 0210, 0144, 0003, 0350, 0072, 0043, 0156, 0270, 
+  0057, 0300, 0161, 0077, 0351, 0041, 0134, 0267, 0246, 0277, 0056, 0321, 0005, 0114, 0322, 0236, 
+  0012, 0206, 0306, 0161, 0157, 0230, 0060, 0145, 0244, 0074, 0120, 0222, 0046, 0217, 0216, 0073, 
+  0346, 0062, 0124, 0143, 0032, 0010, 0265, 0070, 0242, 0225, 0261, 0132, 0203, 0345, 0316, 0241, 
+  0131, 0216, 0100, 0304, 0324, 0327, 0152, 0154, 0100, 0327, 0143, 0371, 0075, 0147, 0102, 0365, 
+  0063, 0236, 0143, 0015, 0075, 0320, 0250, 0161, 0060, 0136, 0230, 0175, 0177, 0012, 0137, 0276, 
+  0322, 0041, 0150, 0072, 0346, 0241, 0215, 0034, 0367, 0333, 0022, 0112, 0313, 0055, 0212, 0204, 
+  0130, 0315, 0244, 0021, 0314, 0062, 0024, 0120, 0327, 0231, 0000, 0256, 0161, 0067, 0061, 0026, 
+  0006, 0344, 0127, 0045, 0271, 0125, 0232, 0174, 0234, 0161, 0130, 0062, 0135, 0010, 0075, 0066, 
+  0024, 0166, 0272, 0362, 0253, 0313, 0313, 0032, 0304, 0021, 0360, 0176, 0144, 0221, 0272, 0123, 
+  0116, 0155, 0254, 0126, 0023, 0232, 0030, 0075, 0215, 0031, 0262, 0142, 0053, 0125, 0151, 0047, 
+  0061, 0320, 0210, 0047, 0224, 0231, 0124, 0347, 0151, 0203, 0210, 0213, 0220, 0244, 0316, 0042, 
+  0231, 0240, 0351, 0053, 0132, 0211, 0257, 0036, 0234, 0025, 0332, 0172, 0213, 0237, 0123, 0125, 
+  0145, 0023, 0171, 0202, 0115, 0324, 0320, 0076, 0111, 0113, 0003, 0246, 0373, 0134, 0122, 0253, 
+  0342, 0162, 0035, 0345, 0164, 0276, 0262, 0126, 0015, 0312, 0111, 0225, 0346, 0050, 0027, 0146, 
+  0321, 0277, 0035, 0027, 0035, 0335, 0362, 0200, 0211, 0022, 0172, 0023, 0263, 0000, 0103, 0214, 
+  0343, 0166, 0252, 0045, 0303, 0202, 0144, 0132, 0017, 0045, 0317, 0126, 0012, 0150, 0210, 0354, 
+  0311, 0242, 0230, 0026, 0007, 0155, 0040, 0253, 0164, 0321, 0265, 0313, 0144, 0153, 0044, 0076, 
+  0347, 0371, 0331, 0207, 0245, 0311, 0005, 0363, 0101, 0070, 0356, 0317, 0110, 0123, 0042, 0200, 
+  0241, 0001, 0232, 0361, 0110, 0131, 0034, 0003, 0103, 0077, 0010, 0240, 0132, 0165, 0133, 0304, 
+  0222, 0012, 0112, 0015, 0001, 0360, 0021, 0030, 0232, 0173, 0105, 0345, 0200, 0064, 0314, 0071, 
+  0156, 0026, 0355, 0126, 0106, 0034, 0324, 0355, 0075, 0052, 0167, 0151, 0044, 0074, 0304, 0114, 
+  0206, 0325, 0233, 0354, 0161, 0041, 0052, 0331, 0210, 0225, 0341, 0231, 0271, 0055, 0070, 0157, 
+  0353, 0161, 0361, 0126, 0256, 0311, 0072, 0012, 0115, 0003, 0176, 0225, 0106, 0337, 0025, 0263, 
+  0302, 0111, 0252, 0264, 0335, 0004, 0225, 0266, 0313, 0125, 0172, 0140, 0266, 0160, 0021, 0232, 
+  0104, 0164, 0307, 0005, 0031, 0356, 0320, 0044, 0223, 0242, 0112, 0322, 0100, 0211, 0341, 0100, 
+  0232, 0156, 0033, 0237, 0223, 0064, 0216, 0017, 0130, 0115, 0055, 0333, 0353, 0255, 0346, 0141, 
+  0156, 0255, 0012, 0043, 0244, 0264, 0136, 0077, 0371, 0162, 0210, 0162, 0143, 0323, 0350, 0236, 
+  0155, 0211, 0226, 0004, 0371, 0025, 0373, 0373, 0115, 0131, 0360, 0225, 0272, 0317, 0366, 0050, 
+  0247, 0157, 0007, 0360, 0227, 0150, 0152, 0056, 0025, 0164, 0243, 0232, 0164, 0045, 0125, 0120, 
+  0271, 0346, 0073, 0125, 0232, 0307, 0211, 0260, 0016, 0062, 0130, 0254, 0141, 0305, 0344, 0345, 
+  0166, 0160, 0020, 0023, 0330, 0257, 0214, 0332, 0235, 0035, 0132, 0037, 0212, 0162, 0146, 0172, 
+  0355, 0327, 0173, 0021, 0277, 0017, 0021, 0033, 0161, 0245, 0017, 0042, 0373, 0205, 0015, 0175, 
+  0127, 0307, 0227, 0176, 0111, 0063, 0326, 0032, 0236, 0275, 0074, 0237, 0035, 0302, 0152, 0230, 
+  0340, 0175, 0324, 0232, 0261, 0114, 0333, 0022, 0272, 0214, 0243, 0125, 0150, 0340, 0155, 0316, 
+  0164, 0131, 0055, 0211, 0162, 0021, 0100, 0005, 0227, 0100, 0007, 0052, 0134, 0261, 0001, 0146, 
+  0255, 0346, 0230, 0335, 0301, 0314, 0075, 0347, 0243, 0307, 0031, 0010, 0040, 0043, 0046, 0206, 
+  0251, 0135, 0212, 0060, 0301, 0246, 0255, 0371, 0061, 0225, 0371, 0106, 0100, 0317, 0122, 0034, 
+  0301, 0202, 0250, 0020, 0374, 0213, 0300, 0100, 0305, 0253, 0351, 0066, 0115, 0022, 0257, 0066, 
+  0267, 0125, 0317, 0100, 0220, 0071, 0321, 0001, 0064, 0237, 0143, 0207, 0124, 0361, 0025, 0376, 
+  0135, 0151, 0336, 0213, 0042, 0350, 0324, 0316, 0223, 0303, 0070, 0144, 0026, 0274, 0024, 0117, 
+  0240, 0172, 0017, 0227, 0057, 0353, 0006, 0313, 0142, 0236, 0154, 0167, 0266, 0166, 0356, 0307, 
+  0115, 0036, 0316, 0271, 0327, 0073, 0255, 0367, 0071, 0225, 0074, 0231, 0062, 0205, 0017, 0004, 
+  0215, 0117, 0311, 0320, 0374, 0120, 0121, 0100, 0017, 0045, 0246, 0205, 0304, 0225, 0053, 0071, 
+  0035, 0110, 0030, 0050, 0311, 0203, 0044, 0207, 0364, 0001, 0215, 0154, 0205, 0060, 0114, 0314, 
+  0245, 0134, 0163, 0056, 0362, 0014, 0276, 0274, 0244, 0312, 0073, 0344, 0157, 0036, 0207, 0254, 
+  0337, 0302, 0041, 0352, 0040, 0056, 0363, 0071, 0021, 0171, 0063, 0134, 0361, 0277, 0177, 0376, 
+  0055, 0233, 0127, 0360, 0201, 0117, 0223, 0003, 0301, 0102, 0275, 0136, 0074, 0077, 0341, 0175, 
+  0156, 0115, 0241, 0010, 0334, 0114, 0013, 0355, 0335, 0150, 0241, 0121, 0252, 0177, 0027, 0101, 
+  0260, 0200, 0101, 0315, 0100, 0051, 0033, 0125, 0200, 0320, 0125, 0336, 0366, 0223, 0114, 0136, 
+  0210, 0227, 0115, 0100, 0064, 0364, 0064, 0230, 0350, 0070, 0201, 0152, 0025, 0017, 0233, 0205, 
+  0210, 0120, 0263, 0061, 0345, 0062, 0304, 0202, 0321, 0046, 0265, 0132, 0221, 0174, 0077, 0006, 
+  0321, 0336, 0221, 0101, 0004, 0311, 0207, 0055, 0354, 0341, 0107, 0201, 0144, 0304, 0207, 0236, 
+  0322, 0100, 0020, 0261, 0342, 0352, 0104, 0151, 0342, 0335, 0043, 0330, 0115, 0236, 0037, 0203, 
+  0314, 0331, 0104, 0236, 0313, 0104, 0072, 0273, 0212, 0031, 0112, 0060, 0315, 0315, 0026, 0106, 
+  0342, 0275, 0347, 0043, 0036, 0002, 0171, 0367, 0361, 0063, 0031, 0032, 0326, 0007, 0342, 0117, 
+  0322, 0227, 0100, 0015, 0245, 0075, 0133, 0306, 0163, 0131, 0306, 0325, 0163, 0244, 0260, 0166, 
+  0163, 0363, 0346, 0323, 0241, 0172, 0217, 0203, 0010, 0315, 0121, 0036, 0222, 0354, 0010, 0370, 
+  0147, 0022, 0150, 0004, 0062, 0370, 0040, 0061, 0053, 0015, 0322, 0263, 0034, 0162, 0223, 0262, 
+  0125, 0062, 0315, 0227, 0241, 0261, 0274, 0067, 0161, 0334, 0344, 0230, 0266, 0204, 0016, 0060, 
+  0257, 0305, 0206, 0377, 0135, 0171, 0100, 0133, 0175, 0122, 0120, 0030, 0360, 0220, 0237, 0137, 
+  0134, 0236, 0370, 0151, 0302, 0306, 0356, 0324, 0074, 0054, 0135, 0327, 0247, 0052, 0117, 0023, 
+  0267, 0161, 0255, 0324, 0304, 0033, 0341, 0140, 0037, 0063, 0326, 0010, 0367, 0346, 0074, 0315, 
+  0104, 0152, 0054, 0023, 0020, 0056, 0270, 0261, 0173, 0106, 0340, 0126, 0003, 0170, 0271, 0201, 
+  0155, 0352, 0131, 0315, 0302, 0346, 0201, 0126, 0102, 0100, 0370, 0147, 0172, 0047, 0244, 0250, 
+  0170, 0223, 0377, 0172, 0214, 0375, 0011, 0023, 0261, 0344, 0226, 0113, 0326, 0322, 0342, 0262, 
+  0216, 0361, 0177, 0102, 0255, 0376, 0301, 0141, 0116, 0014, 0363, 0172, 0076, 0214, 0020, 0030, 
+  0332, 0245, 0241, 0217, 0063, 0127, 0371, 0010, 0244, 0260, 0230, 0032, 0054, 0121, 0023, 0053, 
+  0130, 0335, 0350, 0137, 0272, 0154, 0140, 0100, 0074, 0236, 0222, 0256, 0224, 0302, 0335, 0043, 
+  0301, 0242, 0105, 0114, 0203, 0052, 0235, 0315, 0320, 0132, 0121, 0102, 0235, 0140, 0041, 0327, 
+  0350, 0105, 0027, 0274, 0234, 0044, 0046, 0217, 0363, 0060, 0337, 0251, 0033, 0340, 0223, 0076, 
+  0133, 0203, 0342, 0372, 0042, 0150, 0257, 0024, 0055, 0316, 0100, 0263, 0036, 0367, 0322, 0312, 
+  0073, 0357, 0112, 0153, 0060, 0152, 0250, 0203, 0163, 0157, 0362, 0171, 0172, 0223, 0063, 0361, 
+  0367, 0065, 0213, 0243, 0146, 0001, 0236, 0047, 0001, 0231, 0342, 0316, 0016, 0331, 0277, 0254, 
+  0271, 0277, 0365, 0176, 0173, 0233, 0262, 0174, 0006, 0071, 0307, 0000, 0162, 0226, 0014, 0255, 
+  0241, 0015, 0323, 0203, 0037, 0063, 0154, 0333, 0200, 0235, 0011, 0264, 0320, 0212, 0075, 0255, 
+  0056, 0354, 0154, 0233, 0347, 0056, 0254, 0273, 0102, 0030, 0307, 0326, 0205, 0135, 0277, 0205, 
+  0163, 0027, 0366, 0324, 0273, 0260, 0076, 0112, 0151, 0233, 0166, 0312, 0135, 0244, 0306, 0104, 
+  0202, 0035, 0053, 0175, 0117, 0114, 0014, 0220, 0100, 0113, 0222, 0314, 0166, 0232, 0275, 0224, 
+  0272, 0301, 0365, 0004, 0032, 0266, 0057, 0247, 0347, 0122, 0271, 0150, 0355, 0033, 0332, 0233, 
+  0301, 0355, 0105, 0350, 0330, 0204, 0334, 0371, 0373, 0224, 0243, 0215, 0254, 0157, 0215, 0170, 
+  0366, 0007, 0312, 0053, 0113, 0332, 0020, 0106, 0374, 0014, 0311, 0237, 0011, 0222, 0117, 0205, 
+  0177, 0074, 0227, 0205, 0213, 0034, 0037, 0025, 0324, 0256, 0161, 0125, 0370, 0014, 0266, 0033, 
+  0003, 0266, 0227, 0114, 0355, 0310, 0301, 0366, 0336, 0100, 0364, 0124, 0120, 0047, 0174, 0215, 
+  0171, 0151, 0213, 0057, 0027, 0076, 0057, 0211, 0342, 0330, 0300, 0363, 0272, 0015, 0234, 0241, 
+  0363, 0251, 0103, 0147, 0046, 0204, 0067, 0325, 0176, 0172, 0167, 0165, 0023, 0000, 0235, 0342, 
+  0147, 0017, 0247, 0040, 0230, 0232, 0201, 0230, 0364, 0117, 0000, 0316, 0330, 0371, 0214, 0235, 
+  0137, 0310, 0175, 0305, 0251, 0343, 0274, 0324, 0333, 0212, 0213, 0373, 0077, 0052, 0334, 0161, 
+  0276, 0323, 0170, 0012, 0056, 0167, 0302, 0067, 0032, 0367, 0350, 0247, 0315, 0271, 0370, 0170, 
+  0063, 0053, 0033, 0236, 0347, 0362, 0143, 0310, 0315, 0175, 0162, 0051, 0116, 0302, 0370, 0144, 
+  0357, 0077, 0116, 0265, 0377, 0242, 0157, 0077, 0256, 0120, 0364, 0013, 0276, 0000, 0231, 0233, 
+  0004, 0115, 0044, 0062, 0102, 0031, 0235, 0357, 0077, 0036, 0305, 0242, 0263, 0126, 0105, 0147, 
+  0227, 0235, 0234, 0004, 0274, 0171, 0071, 0170, 0153, 0114, 0063, 0047, 0115, 0015, 0167, 0313, 
+  0210, 0162, 0133, 0041, 0075, 0245, 0237, 0323, 0314, 0276, 0136, 0315, 0320, 0271, 0247, 0177, 
+  0161, 0232, 0176, 0310, 0341, 0174, 0226, 0120, 0115, 0341, 0235, 0150, 0060, 0261, 0222, 0006, 
+  0127, 0240, 0355, 0166, 0366, 0277, 0207, 0171, 0243, 0036, 0113, 0321, 0171, 0312, 0222, 0201, 
+  0337, 0073, 0356, 0374, 0137, 0175, 0055, 0015, 0154, 0025, 0131, 0230, 0361, 0070, 0373, 0163, 
+  0313, 0257, 0376, 0007, 0112, 0344, 0157, 0105, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0155, 
+  0141, 0164, 0145, 0057, 0000, 0000, 0000, 0000
+} };
+
+static GStaticResource static_resource = { msm_resource_data.data, sizeof (msm_resource_data.data) - 1 /* nul terminator */, NULL, NULL, NULL };
+
+G_MODULE_EXPORT
+GResource *msm_get_resource (void);
+GResource *msm_get_resource (void)
+{
+  return g_static_resource_get_resource (&static_resource);
+}
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GLib Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __G_CONSTRUCTOR_H__
+#define __G_CONSTRUCTOR_H__
+
+/*
+  If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and
+  destructors, in a usable way, including e.g. on library unload. If not you're on
+  your own.
+
+  Some compilers need #pragma to handle this, which does not work with macros,
+  so the way you need to use this is (for constructors):
+
+  #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+  #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(my_constructor)
+  #endif
+  G_DEFINE_CONSTRUCTOR(my_constructor)
+  static void my_constructor(void) {
+   ...
+  }
+
+*/
+
+#ifndef __GTK_DOC_IGNORE__
+
+#if  __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func (void);
+#define G_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func (void);
+
+#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
+/* Visual studio 2008 and later has _Pragma */
+
+/*
+ * Only try to include gslist.h if not already included via glib.h,
+ * so that items using gconstructor.h outside of GLib (such as
+ * GResources) continue to build properly.
+ */
+#ifndef __G_LIB_H__
+#include "gslist.h"
+#endif
+
+#include <stdlib.h>
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* We do some weird things to avoid the constructors being optimized
+ * away on VS2015 if WholeProgramOptimization is enabled. First we
+ * make a reference to the array from the wrapper to make sure its
+ * references. Then we use a pragma to make sure the wrapper function
+ * symbol is always included at the link stage. Also, the symbols
+ * need to be extern (but not dllexport), even though they are not
+ * really used from another object file.
+ */
+
+/* We need to account for differences between the mangling of symbols
+ * for x86 and x64/ARM/ARM64 programs, as symbols on x86 are prefixed
+ * with an underscore but symbols on x64/ARM/ARM64 are not.
+ */
+#ifdef _M_IX86
+#define G_MSVC_SYMBOL_PREFIX "_"
+#else
+#define G_MSVC_SYMBOL_PREFIX ""
+#endif
+
+#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
+#define G_DEFINE_DESTRUCTOR(_func) G_MSVC_DTOR (_func, G_MSVC_SYMBOL_PREFIX)
+
+#define G_MSVC_CTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _wrapper(void) { _func(); g_slist_find (NULL,  _array ## _func); return 0; } \
+  __pragma(comment(linker,"/include:" _sym_prefix # _func "_wrapper")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _wrapper;
+
+#define G_MSVC_DTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _constructor(void) { atexit (_func); g_slist_find (NULL,  _array ## _func); return 0; } \
+   __pragma(comment(linker,"/include:" _sym_prefix # _func "_constructor")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined (_MSC_VER)
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* Pre Visual studio 2008 must use #pragma section */
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _wrapper(void) { _func(); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func ## _wrapper;
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _constructor(void) { atexit (_func); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined(__SUNPRO_C)
+
+/* This is not tested, but i believe it should work, based on:
+ * http://opensource.apple.com/source/OpenSSL098/OpenSSL098-35/src/fips/fips_premain.c
+ */
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  init(_func)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void);
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  fini(_func)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void);
+
+#else
+
+/* constructors not supported for this compiler */
+
+#endif
+
+#endif /* __GTK_DOC_IGNORE__ */
+#endif /* __G_CONSTRUCTOR_H__ */
+
+#ifdef G_HAS_CONSTRUCTORS
+
+#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(msmresource_constructor)
+#endif
+G_DEFINE_CONSTRUCTOR(msmresource_constructor)
+#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(msmresource_destructor)
+#endif
+G_DEFINE_DESTRUCTOR(msmresource_destructor)
+
+#else
+#warning "Constructor not supported on this compiler, linking in resources will not work"
+#endif
+
+static void msmresource_constructor (void)
+{
+  g_static_resource_init (&static_resource);
+}
+
+static void msmresource_destructor (void)
+{
+  g_static_resource_fini (&static_resource);
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/11.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/11.html new file mode 100644 index 00000000..174d418f --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/11.html @@ -0,0 +1,1039 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
#include <config.h>
+
+#include <glib/gi18n.h>
+#include <glibtop/procopenfiles.h>
+#include <sys/stat.h>
+#include <netdb.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include "procman.h"
+#include "openfiles.h"
+#include "proctable.h"
+#include "util.h"
+#include "settings-keys.h"
+
+#ifndef NI_IDN
+#define NI_IDN 0
+#endif
+
+enum
+{
+    COL_FD,
+    COL_TYPE,
+    COL_OBJECT,
+    COL_OPENFILE_STRUCT,
+    NUM_OPENFILES_COL
+};
+
+
+static const char*
+get_type_name(enum glibtop_file_type t)
+{
+    switch(t)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        return _("file");
+    case GLIBTOP_FILE_TYPE_PIPE:
+        return _("pipe");
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+        return _("IPv6 network connection");
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        return _("IPv4 network connection");
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        return _("local socket");
+    default:
+        return _("unknown type");
+    }
+}
+
+
+
+static char *
+friendlier_hostname(const char *addr_str, int port)
+{
+    struct addrinfo hints = { };
+    struct addrinfo *res = NULL;
+    char hostname[NI_MAXHOST];
+    char service[NI_MAXSERV];
+    char port_str[6];
+
+    if (!addr_str[0]) return g_strdup("");
+
+    snprintf(port_str, sizeof port_str, "%d", port);
+
+    hints.ai_family = AF_UNSPEC;
+    hints.ai_socktype = SOCK_STREAM;
+
+    if (getaddrinfo(addr_str, port_str, &hints, &res))
+        goto failsafe;
+
+    if (getnameinfo(res->ai_addr, res->ai_addrlen, hostname,<--- Null pointer dereference
+            sizeof hostname, service, sizeof service, NI_IDN))
+        goto failsafe;
+
+    if (res) freeaddrinfo(res);<--- Assuming that condition 'res' is not redundant
+        return g_strdup_printf("%s, TCP port %d (%s)", hostname, port, service);
+
+  failsafe:
+    if (res) freeaddrinfo(res);
+    return g_strdup_printf("%s, TCP port %d", addr_str, port);
+}
+
+
+
+static void
+add_new_files (gpointer key, gpointer value, gpointer data)
+{
+    glibtop_open_files_entry *openfiles = static_cast<glibtop_open_files_entry*>(value);
+
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreeIter row;
+
+    char *object;
+
+    switch(openfiles->type)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        object = g_strdup(openfiles->info.file.name);
+        break;
+
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        object = friendlier_hostname(openfiles->info.sock.dest_host,
+                         openfiles->info.sock.dest_port);
+        break;
+
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        object = g_strdup(openfiles->info.localsock.name);
+        break;
+
+    default:
+        object = g_strdup("");
+    }
+
+    gtk_list_store_insert (GTK_LIST_STORE (model), &row, 0);
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        COL_FD, openfiles->fd,
+                        COL_TYPE, get_type_name(static_cast<glibtop_file_type>(openfiles->type)),
+                        COL_OBJECT, object,
+#if GLIB_CHECK_VERSION (2, 68, 0)
+                        COL_OPENFILE_STRUCT, g_memdup2(openfiles, sizeof(*openfiles)),
+#else
+                        COL_OPENFILE_STRUCT, g_memdup(openfiles, sizeof(*openfiles)),
+#endif
+                        -1);
+
+    g_free(object);
+}
+
+static GList *old_maps = NULL;
+
+static gboolean
+classify_openfiles (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+    GHashTable *new_maps = static_cast<GHashTable*>(data);
+    GtkTreeIter *old_iter;
+    glibtop_open_files_entry *openfiles;
+    gchar *old_name;
+
+    gtk_tree_model_get (model, iter, 1, &old_name, -1);
+
+    openfiles = static_cast<glibtop_open_files_entry*>(g_hash_table_lookup (new_maps, old_name));
+    if (openfiles) {
+        g_hash_table_remove (new_maps, old_name);
+        g_free (old_name);
+        return FALSE;
+
+    }
+
+    old_iter = gtk_tree_iter_copy (iter);
+    old_maps = g_list_append (old_maps, old_iter);
+    g_free (old_name);
+    return FALSE;
+
+}
+
+
+static gboolean
+compare_open_files(gconstpointer a, gconstpointer b)
+{
+    const glibtop_open_files_entry *o1 = static_cast<const glibtop_open_files_entry *>(a);
+    const glibtop_open_files_entry *o2 = static_cast<const glibtop_open_files_entry *>(b);
+
+    /* Falta manejar los diferentes tipos! */
+    return (o1->fd == o2->fd) && (o1->type == o2->type); /* XXX! */
+}
+
+
+static void
+update_openfiles_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+    GtkTreeModel *model;
+    glibtop_open_files_entry *openfiles;<--- Shadowed declaration
+    glibtop_proc_open_files procmap;
+    GHashTable *new_maps;
+    guint i;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    if (!info)
+        return;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    openfiles = glibtop_get_proc_open_files (&procmap, info->pid);
+
+    if (!openfiles)
+        return;
+
+    new_maps = static_cast<GHashTable *>(g_hash_table_new_full (g_str_hash, compare_open_files,
+                                                                NULL, NULL));
+    for (i=0; i < procmap.number; i++)
+        g_hash_table_insert (new_maps, openfiles + i, openfiles + i);
+
+    gtk_tree_model_foreach (model, classify_openfiles, new_maps);
+
+    g_hash_table_foreach (new_maps, add_new_files, model);
+
+    while (old_maps) {
+        GtkTreeIter *iter = static_cast<GtkTreeIter*>(old_maps->data);
+        glibtop_open_files_entry *openfiles = NULL;<--- Shadow variable
+
+        gtk_tree_model_get (model, iter,
+                            COL_OPENFILE_STRUCT, &openfiles,
+                            -1);
+
+        gtk_list_store_remove (GTK_LIST_STORE (model), iter);
+        gtk_tree_iter_free (iter);
+        g_free (openfiles);
+
+        old_maps = g_list_next (old_maps);
+
+    }
+
+    g_hash_table_destroy (new_maps);
+    g_free (openfiles);
+}
+
+static void
+close_openfiles_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GSettings *settings;
+    guint timer;
+
+    settings = static_cast<GSettings*>(g_object_get_data (G_OBJECT (tree), "settings"));
+    procman_save_tree_state (settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    return ;
+}
+
+
+static GtkWidget *
+create_openfiles_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    const gchar * const titles[] = {
+        /* Translators: "FD" here means "File Descriptor". Please use
+           a very short translation if possible, and at most
+           2-3 characters for it to be able to fit in the UI. */
+        N_("FD"),
+        N_("Type"),
+        N_("Object")
+    };
+
+    model = gtk_list_store_new (NUM_OPENFILES_COL,
+                                G_TYPE_INT,        /* FD */
+                                G_TYPE_STRING,    /* Type */
+                                G_TYPE_STRING,    /* Object */
+                                G_TYPE_POINTER    /* open_files_entry */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_OPENFILES_COL-1; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        switch (i) {
+        case COL_FD:
+            g_object_set(cell, "xalign", 1.0f, NULL);
+            break;
+        }
+
+        column = gtk_tree_view_column_new_with_attributes (_(titles[i]),
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_sort_column_id (column, i);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    procman_get_tree_state (procdata->settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    return tree;
+}
+
+
+static gboolean
+openfiles_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_openfiles_dialog (tree);
+
+    return TRUE;
+}
+
+
+static void
+create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *openfilesdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    openfilesdialog = gtk_dialog_new_with_buttons (_("Open Files"), NULL,
+                                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                   "gtk-close", GTK_RESPONSE_CLOSE,
+                                                   NULL);
+    gtk_window_set_resizable (GTK_WINDOW (openfilesdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (openfilesdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (openfilesdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (openfilesdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Files opened by process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                    GTK_POLICY_AUTOMATIC,
+                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_openfiles_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+    g_object_set_data (G_OBJECT (tree), "settings", procdata->settings);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (openfilesdialog), "response",
+                      G_CALLBACK (close_openfiles_dialog), tree);
+
+    gtk_widget_show_all (openfilesdialog);
+
+    timer = g_timeout_add_seconds (5, openfiles_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_openfiles_dialog (tree);
+
+}
+
+
+void
+create_openfiles_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_openfiles_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/12.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/12.html new file mode 100644 index 00000000..c1c9bcc6 --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/12.html @@ -0,0 +1,385 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
// -*- c++ -*-
+
+#ifndef _PROCMAN_PRETTYTABLE_H_
+#define _PROCMAN_PRETTYTABLE_H_
+
+#include <glib.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <glibmm/refptr.h>
+#include <gdkmm/pixbuf.h>
+#include <giomm/filemonitor.h>
+
+#include <map>
+#include <string>
+
+#ifdef HAVE_WNCK
+extern "C" {
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h>
+}
+#endif
+
+#include "iconthemewrapper.h"
+
+class ProcInfo;
+
+using std::string;
+
+class PrettyTable
+{
+ public:
+    PrettyTable();
+    ~PrettyTable();
+
+    void set_icon(ProcInfo &);
+
+private:
+
+#ifdef HAVE_WNCK
+    static void on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_opened'
+    static void on_application_closed(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_closed'
+
+    void register_application(pid_t pid, Glib::RefPtr<Gdk::Pixbuf> icon);
+    void unregister_application(pid_t pid);
+#endif
+
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_theme(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_default(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_gio(const ProcInfo &);
+#ifdef HAVE_WNCK
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_wnck(const ProcInfo &);
+#endif
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_name(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_for_kernel(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_dummy(const ProcInfo &);
+
+    bool get_default_icon_name(const string &cmd, string &name);
+    void file_monitor_event (Glib::RefPtr<Gio::File>,
+                             Glib::RefPtr<Gio::File>,
+                             Gio::FileMonitorEvent);
+    void init_gio_app_cache ();
+
+    typedef std::map<string, Glib::RefPtr<Gdk::Pixbuf> > IconCache;
+    typedef std::map<pid_t, Glib::RefPtr<Gdk::Pixbuf> > IconsForPID;
+    typedef std::map<string, Glib::RefPtr<Gio::AppInfo> > AppCache;
+    typedef std::map<string, Glib::RefPtr<Gio::FileMonitor> > DesktopDirMonitors;
+
+    IconsForPID apps;
+    IconCache defaults;
+    DesktopDirMonitors monitors;
+    AppCache gio_apps;
+    procman::IconThemeWrapper theme;
+};
+
+#endif /* _PROCMAN_PRETTYTABLE_H_ */
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/13.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/13.html new file mode 100644 index 00000000..b7c3450b --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/13.html @@ -0,0 +1,1417 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
/* Procman - dialogs
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+
+#include <signal.h>
+#include <string.h>
+
+#include "procdialogs.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "procactions.h"
+#include "util.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "procman_gksu.h"
+#include "procman_pkexec.h"
+#include "cgroups.h"
+
+#define GET_WIDGET(x) GTK_WIDGET(gtk_builder_get_object(builder, x))
+
+static GtkWidget *renice_dialog = NULL;
+static GtkWidget *prefs_dialog = NULL;
+static gint new_nice_value = 0;
+
+
+static void
+kill_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    struct KillArgs *kargs = static_cast<KillArgs*>(data);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    if (id == GTK_RESPONSE_OK)
+        kill_process (kargs->procdata, kargs->signal);
+
+    g_free (kargs);
+}
+
+void
+procdialog_create_kill_dialog (ProcData *procdata, int signal)
+{
+    GtkWidget *kill_alert_dialog;
+    gchar *primary, *secondary, *button_text;
+    struct KillArgs *kargs;
+
+    kargs = g_new(KillArgs, 1);
+    kargs->procdata = procdata;
+    kargs->signal = signal;
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if ( selected_count == 1 ) {
+        ProcInfo *selected_process = NULL;
+        // get the last selected row
+        gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &selected_process);
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing single process*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        } else {
+            /*xgettext: primary alert message for ending single process*/
+            primary = g_strdup_printf (_("Are you sure you want to end the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        }
+    } else {
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the %d selected processes?"),
+                                       selected_count);
+        } else {
+            /*xgettext: primary alert message for ending multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to end the %d selected processes?"),
+                                       selected_count);
+
+        }
+    }
+
+    if ( signal == SIGKILL ) {
+        /*xgettext: secondary alert message*/
+        secondary = _("Killing a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be killed.");
+        button_text = ngettext("_Kill Process", "_Kill Processes", selected_count);
+    } else {
+        /*xgettext: secondary alert message*/
+        secondary = _("Ending a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be ended.");
+        button_text = ngettext("_End Process", "_End Processes", selected_count);
+    }
+
+    kill_alert_dialog = gtk_message_dialog_new (GTK_WINDOW (procdata->app),
+                                                static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
+                                                GTK_MESSAGE_WARNING,
+                                                GTK_BUTTONS_NONE,
+                                                "%s",
+                                                primary);
+    g_free (primary);
+
+    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (kill_alert_dialog),
+                                              "%s",
+                                              secondary);
+
+    gtk_dialog_add_buttons (GTK_DIALOG (kill_alert_dialog),
+                            "gtk-cancel", GTK_RESPONSE_CANCEL,
+                            button_text, GTK_RESPONSE_OK,
+                            NULL);
+
+    gtk_dialog_set_default_response (GTK_DIALOG (kill_alert_dialog),
+                                     GTK_RESPONSE_CANCEL);
+
+    g_signal_connect (G_OBJECT (kill_alert_dialog), "response",
+                      G_CALLBACK (kill_dialog_button_pressed), kargs);
+
+    gtk_widget_show_all (kill_alert_dialog);
+}
+
+static void
+renice_scale_changed (GtkAdjustment *adj, gpointer data)
+{
+    GtkWidget *label = GTK_WIDGET (data);
+
+    new_nice_value = int(gtk_adjustment_get_value (adj));
+    gchar* text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (new_nice_value));
+    gtk_label_set_text (GTK_LABEL (label), text);
+    g_free(text);
+
+}
+
+static void
+renice_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (id == 100) {
+        if (new_nice_value == -100)
+            return;
+        renice(procdata, new_nice_value);
+    }
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+    renice_dialog = NULL;
+}
+
+void
+procdialog_create_renice_dialog (ProcData *procdata)
+{
+    ProcInfo  *info;
+    GtkWidget *dialog = NULL;
+    GtkWidget *dialog_vbox;
+    GtkWidget *vbox;
+    GtkWidget *label;
+    GtkWidget *priority_label;
+    GtkWidget *grid;
+    GtkAdjustment *renice_adj;
+    GtkWidget *hscale;
+    GtkWidget *button;
+    GtkWidget *icon;
+    gchar     *text;
+    gchar     *dialog_title;
+
+    if (renice_dialog)
+        return;
+
+    gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &info);
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if (!info)
+        return;
+
+    if ( selected_count == 1 ) {
+        dialog_title = g_strdup_printf (_("Change Priority of Process “%s†(PID: %u)"),
+                                        info->name, info->pid);
+    } else {
+        dialog_title = g_strdup_printf (_("Change Priority of %d Selected Processes"),
+                                        selected_count);
+    }
+
+    dialog = gtk_dialog_new_with_buttons (dialog_title, NULL,
+                                          GTK_DIALOG_DESTROY_WITH_PARENT,
+                                          "gtk-cancel", GTK_RESPONSE_CANCEL,
+                                          NULL);
+    g_free (dialog_title);
+
+    renice_dialog = dialog;
+    gtk_window_set_resizable (GTK_WINDOW (renice_dialog), FALSE);
+    gtk_container_set_border_width (GTK_CONTAINER (renice_dialog), 5);
+
+    button = gtk_button_new_with_mnemonic (_("Change _Priority"));
+    gtk_widget_set_can_default (button, TRUE);
+
+    icon = gtk_image_new_from_icon_name ("gtk-apply", GTK_ICON_SIZE_BUTTON);
+    gtk_button_set_image (GTK_BUTTON (button), icon);
+
+    gtk_dialog_add_action_widget (GTK_DIALOG (renice_dialog), button, 100);
+    gtk_dialog_set_default_response (GTK_DIALOG (renice_dialog), 100);
+    new_nice_value = -100;
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+    gtk_box_set_spacing (GTK_BOX (dialog_vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), vbox, TRUE, TRUE, 0);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+
+    grid = gtk_grid_new ();
+    gtk_grid_set_column_spacing (GTK_GRID(grid), 12);
+    gtk_grid_set_row_spacing (GTK_GRID(grid), 6);
+    gtk_box_pack_start (GTK_BOX (vbox), grid, TRUE, TRUE, 0);
+
+    label = gtk_label_new_with_mnemonic (_("_Nice value:"));
+    gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 2);
+
+    renice_adj = gtk_adjustment_new (info->nice, RENICE_VAL_MIN, RENICE_VAL_MAX, 1, 1, 0);
+    new_nice_value = 0;
+    hscale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, renice_adj);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), hscale);
+    gtk_scale_set_digits (GTK_SCALE (hscale), 0);
+    gtk_widget_set_hexpand (hscale, TRUE);
+    gtk_grid_attach (GTK_GRID (grid), hscale, 1, 0, 1, 1);
+    text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (info->nice));
+    priority_label = gtk_label_new (text);
+    gtk_grid_attach (GTK_GRID (grid), priority_label, 1, 1, 1, 1);
+    g_free(text);
+
+    text = g_strconcat("<small><i><b>", _("Note:"), "</b> ",
+        _("The priority of a process is given by its nice value. A lower nice value corresponds to a higher priority."),
+        "</i></small>", NULL);
+    label = gtk_label_new (_(text));
+    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+    g_free (text);
+
+    g_signal_connect (G_OBJECT (dialog), "response",
+                      G_CALLBACK (renice_dialog_button_pressed), procdata);
+    g_signal_connect (G_OBJECT (renice_adj), "value_changed",
+                      G_CALLBACK (renice_scale_changed), priority_label);
+
+    gtk_widget_show_all (dialog);
+
+
+}
+
+static void
+prefs_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    if (id == GTK_RESPONSE_HELP)
+    {
+        GError* error = 0;
+        if (!g_app_info_launch_default_for_uri("help:mate-system-monitor/mate-system-monitor-prefs", NULL, &error))
+        {
+            g_warning("Could not display preferences help : %s", error->message);
+            g_error_free(error);
+        }
+    }
+    else
+    {
+        gtk_widget_destroy (GTK_WIDGET (dialog));
+        prefs_dialog = NULL;
+    }
+}
+
+
+class SpinButtonUpdater
+{
+public:
+    SpinButtonUpdater(const string& key)
+        : key(key)
+    { }
+
+    static gboolean callback(GtkWidget *widget, GdkEventFocus *event, gpointer data)
+    {
+        SpinButtonUpdater* updater = static_cast<SpinButtonUpdater*>(data);
+        gtk_spin_button_update(GTK_SPIN_BUTTON(widget));
+        updater->update(GTK_SPIN_BUTTON(widget));
+        return FALSE;
+    }
+
+private:
+
+    void update(GtkSpinButton* spin)
+    {
+        int new_value = int(1000 * gtk_spin_button_get_value(spin));
+        g_settings_set_int(ProcData::get_instance()->settings,
+                           this->key.c_str(), new_value);
+
+        procman_debug("set %s to %d", this->key.c_str(), new_value);
+    }
+
+    const string key;
+};
+
+
+static void
+field_toggled (const gchar *child_schema, GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+    GtkTreeIter iter;
+    GtkTreeViewColumn *column;
+    gboolean toggled;
+    GSettings *settings = g_settings_get_child (ProcData::get_instance()->settings, child_schema);
+    gchar *key;
+    int id;
+
+    if (!path)
+        return;
+
+    gtk_tree_model_get_iter (model, &iter, path);
+
+    gtk_tree_model_get (model, &iter, 2, &column, -1);
+    toggled = gtk_cell_renderer_toggle_get_active (cell);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, !toggled, -1);
+    gtk_tree_view_column_set_visible (column, !toggled);
+
+    id = gtk_tree_view_column_get_sort_column_id (column);
+
+    key = g_strdup_printf ("col-%d-visible", id);
+    g_settings_set_boolean (settings, key, !toggled);
+    g_free (key);
+
+    gtk_tree_path_free (path);
+}
+
+static void
+proc_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("proctree", cell, path_str, data);
+}
+
+static void
+disk_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("disktreenew", cell, path_str, data);
+}
+
+static void
+create_field_page(GtkBuilder* builder, GtkWidget *tree, const gchar *widgetname)
+{
+    GtkTreeView *treeview;
+    GList *it, *columns;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;<--- Shadowed declaration
+    GtkCellRenderer *cell;
+    gchar *full_widgetname;
+
+    full_widgetname = g_strdup_printf ("%s_columns", widgetname);
+    treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, full_widgetname));
+    g_free (full_widgetname);
+
+    model = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER);
+
+    gtk_tree_view_set_model (GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(model));
+    g_object_unref (G_OBJECT (model));
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_toggle_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "active", 0,
+                                         NULL);
+
+    if (g_strcmp0 (widgetname, "proctree") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (proc_field_toggled), model);
+    else if (g_strcmp0 (widgetname, "disktreenew") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (disk_field_toggled), model);
+
+    gtk_tree_view_column_set_clickable (column, TRUE);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "text", 1,
+                                         NULL);
+
+    gtk_tree_view_column_set_title (column, "Not Shown");
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    for(it = columns; it; it = it->next)
+    {
+        GtkTreeViewColumn *column = static_cast<GtkTreeViewColumn*>(it->data);<--- Shadow variable
+        GtkTreeIter iter;
+        const gchar *title;
+        gboolean visible;
+        gint column_id;
+
+        title = gtk_tree_view_column_get_title (column);
+        if (!title)
+            title = _("Icon");
+
+        column_id = gtk_tree_view_column_get_sort_column_id(column);
+        if ((column_id == COL_CGROUP) && (!cgroups_enabled()))
+            continue;
+
+        if ((column_id == COL_UNIT ||
+             column_id == COL_SESSION ||
+             column_id == COL_SEAT ||
+             column_id == COL_OWNER)
+#ifdef HAVE_SYSTEMD
+            && !LOGIND_RUNNING()
+#endif
+                )
+            continue;
+
+        visible = gtk_tree_view_column_get_visible (column);
+
+        gtk_list_store_append (model, &iter);
+        gtk_list_store_set (model, &iter, 0, visible, 1, title, 2, column,-1);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procdialog_create_preferences_dialog (ProcData *procdata)
+{
+    typedef SpinButtonUpdater SBU;
+
+    static SBU interval_updater("update-interval");
+    static SBU graph_interval_updater("graph-update-interval");
+    static SBU disks_interval_updater("disks-interval");
+
+    GtkWidget *notebook;
+    GtkAdjustment *adjustment;
+    GtkWidget *spin_button;
+    GtkWidget *check_button;
+    GtkWidget *smooth_button;
+    GtkBuilder *builder;
+    gfloat update;
+
+    if (prefs_dialog)
+        return;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/preferences.ui");
+
+    prefs_dialog = GET_WIDGET("preferences_dialog");
+    notebook = GET_WIDGET("notebook");
+    spin_button = GET_WIDGET("processes_interval_spinner");
+
+    update = (gfloat) procdata->config.update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0,
+                                   MIN_UPDATE_INTERVAL / 1000,
+                                   MAX_UPDATE_INTERVAL / 1000,
+                                   0.25,
+                                   1.0,
+                                   0);
+
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK (SBU::callback), &interval_updater);
+
+    smooth_button = GET_WIDGET("smooth_button");
+    g_settings_bind(procdata->settings, SmoothRefresh::KEY.c_str(), smooth_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    check_button = GET_WIDGET("check_button");
+    g_settings_bind(procdata->settings, "kill-dialog", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    GtkWidget *solaris_button = GET_WIDGET("solaris_button");
+    g_settings_bind(procdata->settings, procman::settings::solaris_mode.c_str(), solaris_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->tree, "proctree");
+
+    update = (gfloat) procdata->config.graph_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0, 0.25,
+                                                      100.0, 0.25, 1.0, 0);
+
+    spin_button = GET_WIDGET("resources_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &graph_interval_updater);
+
+    GtkWidget *bits_button = GET_WIDGET("bits_button");
+    g_settings_bind(procdata->settings, procman::settings::network_in_bits.c_str(), bits_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+
+    update = (gfloat) procdata->config.disks_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new (update / 1000.0, 1.0,
+                                                       100.0, 1.0, 1.0, 0);
+
+    spin_button = GET_WIDGET("devices_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &disks_interval_updater);
+
+    check_button = GET_WIDGET("all_devices_check");
+    g_settings_bind(procdata->settings, "show-all-fs", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->disk_list, "disktreenew");
+
+    gtk_widget_show_all (prefs_dialog);
+    g_signal_connect (G_OBJECT (prefs_dialog), "response",
+                       G_CALLBACK (prefs_dialog_button_pressed), procdata);
+
+    switch (procdata->config.current_tab) {
+    case PROCMAN_TAB_SYSINFO:
+    case PROCMAN_TAB_PROCESSES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
+        break;
+    case PROCMAN_TAB_RESOURCES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 1);
+        break;
+    case PROCMAN_TAB_DISKS:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 2);
+        break;
+    }
+
+    gtk_builder_connect_signals (builder, NULL);
+    g_object_unref (G_OBJECT (builder));
+}
+
+
+static char *
+procman_action_to_command(ProcmanActionType type,
+                          gint pid,
+                          gint extra_value)
+{
+    switch (type) {
+    case PROCMAN_ACTION_KILL:
+           return g_strdup_printf("kill -s %d %d", extra_value, pid);
+    case PROCMAN_ACTION_RENICE:
+        return g_strdup_printf("renice %d %d", extra_value, pid);
+    default:
+        g_assert_not_reached();
+    }
+}
+
+
+/*
+ * type determines whether if dialog is for killing process or renice.
+ * type == PROCMAN_ACTION_KILL,   extra_value -> signal to send
+ * type == PROCMAN_ACTION_RENICE, extra_value -> new priority.
+ */
+gboolean
+procdialog_create_root_password_dialog(ProcmanActionType type,
+                                       ProcData *procdata,
+                                       gint pid,
+                                       gint extra_value)
+{
+    char * command;
+    gboolean ret = FALSE;
+
+    command = procman_action_to_command(type, pid, extra_value);
+
+    procman_debug("Trying to run '%s' as root", command);
+
+    if (procman_has_pkexec())
+        ret = procman_pkexec_create_root_password_dialog(command);
+    else if (procman_has_gksu())
+        ret = procman_gksu_create_root_password_dialog(command);
+
+    g_free(command);
+    return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/14.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/14.html new file mode 100644 index 00000000..3c8a776c --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/14.html @@ -0,0 +1,1109 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
#include <glib/gi18n.h>
+#include <glibtop.h>
+#include <glibtop/close.h>
+#include <glibtop/cpu.h>
+#include <glibtop/sysinfo.h>
+
+#include "procman-app.h"
+#include "procman.h"
+#include "interface.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "argv.h"
+#include "util.h"
+
+static void
+mount_changed(const Glib::RefPtr<Gio::Mount>&)
+{
+    cb_update_disks(ProcData::get_instance());
+}
+
+
+static void
+init_volume_monitor(ProcData *procdata)
+{
+    using namespace Gio;
+    using namespace Glib;
+
+    RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+    monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
+}
+
+static gboolean
+has_key (gchar **keys, const gchar *key)
+{
+    gchar **loop = keys;
+
+    while (*loop) {
+        if (!strcmp (*loop++, key))
+            return TRUE;
+    }
+
+    return FALSE;
+}
+
+static void
+tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_tree = g_settings_get_boolean(settings, key);
+
+    g_object_set(G_OBJECT(procdata->tree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
+    proctable_update (procdata);
+}
+
+
+static void
+network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
+    // force scale to be redrawn
+    procdata->net_graph->clear_background();
+}
+
+static void
+view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.whose_process = g_settings_get_int (settings, key);
+    procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2);
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "kill-dialog")) {
+        procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
+    }
+}
+
+static void
+timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "update-interval")) {
+        procdata->config.update_interval = g_settings_get_int (settings, key);
+        procdata->config.update_interval =
+            MAX (procdata->config.update_interval, 1000);
+
+        procdata->smooth_refresh->reset();
+
+        if(procdata->timeout) {
+            g_source_remove (procdata->timeout);
+            procdata->timeout = g_timeout_add (procdata->config.update_interval,
+                                               cb_timeout,
+                                               procdata);
+        }
+    }
+    else if (g_str_equal (key, "graph-update-interval")){
+        procdata->config.graph_update_interval = g_settings_get_int (settings, key);
+        procdata->config.graph_update_interval =
+            MAX (procdata->config.graph_update_interval,
+                 250);
+        load_graph_change_speed(procdata->cpu_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->mem_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->net_graph,
+                                procdata->config.graph_update_interval);
+    }
+    else if (g_str_equal(key, "disks-interval")) {
+        procdata->config.disks_update_interval = g_settings_get_int (settings, key);
+        procdata->config.disks_update_interval =
+            MAX (procdata->config.disks_update_interval, 1000);
+
+        if(procdata->disk_timeout) {
+            g_source_remove (procdata->disk_timeout);
+            procdata->disk_timeout = \
+                g_timeout_add (procdata->config.disks_update_interval,
+                               cb_update_disks,
+                               procdata);
+        }
+    }
+    else {
+        g_assert_not_reached();
+    }
+}
+
+static void
+color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    gchar *color = g_settings_get_string (settings, key);
+
+    if (g_str_has_prefix (key, "cpu-color")) {
+        for (int i = 0; i < procdata->config.num_cpus; i++) {
+            string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
+            if (cpu_key == key) {
+                gdk_rgba_parse (&procdata->config.cpu_color[i], color);
+                procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
+                break;
+            }
+        }
+    }
+    else if (g_str_equal (key, "mem-color")) {
+        gdk_rgba_parse (&procdata->config.mem_color, color);
+        procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
+    }
+    else if (g_str_equal (key, "swap-color")) {
+        gdk_rgba_parse (&procdata->config.swap_color, color);
+        procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
+    }
+    else if (g_str_equal (key, "net-in-color")) {
+        gdk_rgba_parse (&procdata->config.net_in_color, color);
+        procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
+    }
+    else if (g_str_equal (key, "net-out-color")) {
+        gdk_rgba_parse (&procdata->config.net_out_color, color);
+        procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
+    }
+    else {
+        g_assert_not_reached();
+    }
+    g_free(color);
+}
+
+static void
+show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
+
+    cb_update_disks (data);
+}
+
+static ProcData *
+procman_data_new (GSettings *settings)
+{
+    GSettingsSchema *schema;
+    ProcData *pd;
+    gchar *color;
+    gchar **keys;
+    glibtop_cpu cpu;
+
+    pd = ProcData::get_instance();
+
+    g_settings_get (settings, "window-state", "(iiii)",
+                    &pd->config.width, &pd->config.height,
+                    &pd->config.xpos, &pd->config.ypos);
+
+    pd->config.maximized = g_settings_get_boolean(settings, "maximized");
+
+    pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
+    g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd);
+
+    pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
+    std::string detail_string("changed::" + procman::settings::solaris_mode);
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd);
+
+    pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
+    detail_string = "changed::" + procman::settings::network_in_bits;
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd);
+
+    pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
+    g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd);
+    pd->config.update_interval = g_settings_get_int (settings, "update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.graph_update_interval = g_settings_get_int (settings,
+                                                           "graph-update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",
+                      G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd);
+
+
+    /* show_all_fs */
+    pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
+    g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd);
+
+
+    pd->config.whose_process = g_settings_get_int (settings, "view-as");
+    g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd);
+    pd->config.current_tab = g_settings_get_int (settings, "current-tab");
+
+    glibtop_get_cpu (&cpu);
+    pd->frequency = cpu.frequency;
+    pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
+
+    g_object_get (settings, "settings-schema", &schema, NULL);
+    keys = g_settings_schema_list_keys (schema);
+    g_settings_schema_unref (schema);
+
+    for (int i = 0; i < pd->config.num_cpus; i++) {
+        gchar *key;
+        key = g_strdup_printf ("cpu-color%d", i);
+
+        if (has_key (keys, key))
+            color = g_settings_get_string (settings, key);
+        else
+            color = g_strdup ("#f25915e815e8");
+        detail_string = std::string("changed::") + std::string(key);
+        g_signal_connect (G_OBJECT(settings), detail_string.c_str(),
+                          G_CALLBACK(color_changed_cb), pd);
+        gdk_rgba_parse (&pd->config.cpu_color[i], color);
+        g_free (color);
+        g_free (key);
+    }
+    g_strfreev (keys);
+
+    color = g_settings_get_string (settings, "mem-color");
+    if (!color)
+        color = g_strdup ("#000000ff0082");
+    g_signal_connect (G_OBJECT(settings), "changed::mem-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.mem_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "swap-color");
+    if (!color)
+        color = g_strdup ("#00b6000000ff");
+    g_signal_connect (G_OBJECT(settings), "changed::swap-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.swap_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-in-color");
+    if (!color)
+        color = g_strdup ("#000000f200f2");
+    g_signal_connect (G_OBJECT(settings), "changed::net-in-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_in_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-out-color");
+    if (!color)
+        color = g_strdup ("#00f2000000c1");
+    g_signal_connect (G_OBJECT(settings), "changed::net-out-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_out_color, color);
+    g_free (color);
+
+    /* Sanity checks */
+    GdkDisplay *display;
+    GdkMonitor *monitor;
+    GdkRectangle monitor_geometry;
+
+    display = gdk_display_get_default ();
+    monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
+    if (monitor == NULL) {
+        monitor = gdk_display_get_monitor (display, 0);
+    }
+    gdk_monitor_get_geometry (monitor, &monitor_geometry);
+
+    pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width);
+    pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height);
+    pd->config.update_interval = MAX (pd->config.update_interval, 1000);
+    pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250);
+    pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000);
+    pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2);
+    pd->config.current_tab = CLAMP(pd->config.current_tab,
+                                   PROCMAN_TAB_SYSINFO,
+                                   PROCMAN_TAB_DISKS);
+
+    // delayed initialization as SmoothRefresh() needs ProcData
+    // i.e. we can't call ProcData::get_instance
+    pd->smooth_refresh = new SmoothRefresh(settings);
+
+    pd->terminating = FALSE;
+
+    return pd;
+}
+
+static void
+procman_free_data (ProcData *procdata)
+{
+
+    proctable_free_table (procdata);
+    delete procdata->smooth_refresh;
+}
+
+ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)<--- Member variable 'ProcmanApp::procdata' is not initialized in the constructor.
+{
+    Glib::set_application_name(_("System Monitor"));
+}
+
+Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
+{
+    return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
+}
+
+void ProcmanApp::on_activate()
+{
+    gtk_window_present (GTK_WINDOW (procdata->app));
+}
+
+static void
+set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
+{
+    gtk_notebook_set_current_page(notebook, tab);
+    cb_change_current_page(notebook, tab, procdata);
+}
+
+int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
+{
+    int argc = 0;
+    char** argv = command_line->get_arguments(argc);
+
+    Glib::OptionContext context;
+    context.set_summary(_("A simple process and system monitor."));
+    context.set_ignore_unknown_options(true);
+    procman::OptionGroup option_group;
+    context.set_main_group(option_group);
+
+    try {
+        context.parse(argc, argv);
+    } catch (const Glib::Error& ex) {
+        g_error("Arguments parse error : %s", ex.what().c_str());
+    }
+
+    if (option_group.show_system_tab) {
+        procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_SYSINFO, procdata);
+    } else if (option_group.show_processes_tab) {
+        procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_PROCESSES, procdata);
+    } else if (option_group.show_resources_tab) {
+        procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_RESOURCES, procdata);
+    } else if (option_group.show_file_systems_tab) {
+        procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_DISKS, procdata);
+    }
+
+    on_activate ();
+
+    return 0;
+}
+
+void ProcmanApp::on_startup()
+{
+    Gtk::Application::on_startup();
+
+    GSettings *settings;
+
+    Gtk::Window::set_default_icon_name ("utilities-system-monitor");
+
+    settings = g_settings_new (GSM_GSETTINGS_SCHEMA);
+
+    glibtop_init ();
+
+    procdata = procman_data_new (settings);
+    procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA);
+
+    create_main_window (procdata);
+    init_volume_monitor (procdata);
+
+    Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app));
+    window->show();
+    window->set_name ("mate-system-monitor");
+
+    add_window (*window);
+}
+
+void ProcmanApp::on_shutdown()
+{
+    procman_free_data(procdata);
+    glibtop_close();
+}
+
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/15.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/15.html new file mode 100644 index 00000000..caf6d784 --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/15.html @@ -0,0 +1,671 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+
+#include <locale.h>
+
+#include <gtkmm.h>
+#include <glib/gi18n.h>
+
+#include "procman-app.h"
+#include "procman.h"
+#include "proctable.h"
+
+ProcData::ProcData()<--- Member variable 'ProcData::uimanager' is not initialized in the constructor.<--- Member variable 'ProcData::action_group' is not initialized in the constructor.<--- Member variable 'ProcData::statusbar' is not initialized in the constructor.<--- Member variable 'ProcData::loadavg' is not initialized in the constructor.<--- Member variable 'ProcData::endprocessbutton' is not initialized in the constructor.<--- Member variable 'ProcData::popup_menu' is not initialized in the constructor.<--- Member variable 'ProcData::disk_list' is not initialized in the constructor.<--- Member variable 'ProcData::notebook' is not initialized in the constructor.<--- Member variable 'ProcData::config' is not initialized in the constructor.<--- Member variable 'ProcData::selection' is not initialized in the constructor.<--- Member variable 'ProcData::settings' is not initialized in the constructor.<--- Member variable 'ProcData::app' is not initialized in the constructor.<--- Member variable 'ProcData::menu' is not initialized in the constructor.<--- Member variable 'ProcData::frequency' is not initialized in the constructor.<--- Member variable 'ProcData::smooth_refresh' is not initialized in the constructor.
+    : tree(NULL),
+      cpu_graph(NULL),
+      mem_graph(NULL),
+      net_graph(NULL),
+      selected_process(NULL),
+      timeout(0),
+      disk_timeout(0),
+      cpu_total_time(1),
+      cpu_total_time_last(1)
+{ }
+
+ProcData* ProcData::get_instance()
+{
+    static ProcData instance;
+    return &instance;
+}
+
+gboolean
+procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns, *it;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    sort_col = g_settings_get_int (pt_settings, "sort-col");
+
+    order = static_cast<GtkSortType>(g_settings_get_int (pt_settings, "sort-order"));
+
+    if (sort_col != -1)
+        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
+                                              sort_col,
+                                              order);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        for (it = columns; it; it = it->next)
+        {
+            GtkTreeViewColumn *column;
+            gint width;
+            gboolean visible;
+            int id;
+            gchar *key;
+
+            column = static_cast<GtkTreeViewColumn*>(it->data);
+            id = gtk_tree_view_column_get_sort_column_id (column);
+
+            key = g_strdup_printf ("col-%d-width", id);
+            g_settings_get (pt_settings, key, "i", &width);
+            g_free (key);
+
+            key = g_strdup_printf ("col-%d-visible", id);
+            visible = g_settings_get_boolean (pt_settings, key);
+            g_free (key);
+
+            gtk_tree_view_column_set_visible (column, visible);
+            if (visible) {
+                /* ensure column is really visible */
+                width = MAX(width, 20);
+                gtk_tree_view_column_set_fixed_width(column, width);
+            }
+        }
+
+        GVariant     *value;
+        GVariantIter iter;
+        int          sortIndex;
+
+        GSList *order = NULL;<--- Shadow variable
+
+        value = g_settings_get_value(pt_settings, "columns-order");
+        g_variant_iter_init(&iter, value);
+
+        while (g_variant_iter_loop (&iter, "i", &sortIndex))
+            order = g_slist_append(order, GINT_TO_POINTER(sortIndex));
+
+        proctable_set_columns_order(GTK_TREE_VIEW(tree), order);
+
+        g_variant_unref(value);
+        g_slist_free(order);
+    }
+
+    g_object_unref(pt_settings);
+    pt_settings = NULL;
+
+    g_list_free(columns);
+
+    return TRUE;
+}
+
+void
+procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    if (ProcData::get_instance()->terminating)
+        return;
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    if (gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (model), &sort_col,
+                                              &order)) {
+        g_settings_set_int (pt_settings, "sort-col", sort_col);
+        g_settings_set_int (pt_settings, "sort-order", order);
+    }
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        GSList *order;<--- Shadow variable
+        GSList *order_node;
+        GVariantBuilder *builder;
+        GVariant *order_variant;
+
+        order = proctable_get_columns_order(GTK_TREE_VIEW(tree));
+
+        builder = g_variant_builder_new (G_VARIANT_TYPE ("ai"));
+
+        for (order_node = order; order_node; order_node = order_node->next)
+            g_variant_builder_add(builder, "i", GPOINTER_TO_INT(order_node->data));
+
+        order_variant = g_variant_new("ai", builder);
+        g_settings_set_value(pt_settings, "columns-order", order_variant);
+
+        g_slist_free(order);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procman_save_config (ProcData *data)
+{
+    GSettings *settings = data->settings;
+
+    g_assert(data);
+
+    data->config.maximized = gdk_window_get_state(gtk_widget_get_window (data->app)) & GDK_WINDOW_STATE_MAXIMIZED;
+    if (!data->config.maximized) {
+        // we only want to store/overwrite size and position info with non-maximized state info
+        data->config.width  = gdk_window_get_width (gtk_widget_get_window (data->app));
+        data->config.height = gdk_window_get_height(gtk_widget_get_window (data->app));
+
+        gtk_window_get_position(GTK_WINDOW(data->app), &data->config.xpos, &data->config.ypos);
+
+        g_settings_set (settings, "window-state", "(iiii)",
+                        data->config.width, data->config.height,
+                        data->config.xpos, data->config.ypos);
+    }
+    g_settings_set_boolean (settings, "maximized", data->config.maximized);
+
+    g_settings_set_int (settings, "current-tab", data->config.current_tab);
+}
+
+int
+main (int argc, char *argv[])
+{
+    bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+    textdomain (GETTEXT_PACKAGE);
+    setlocale (LC_ALL, "");
+
+    Glib::RefPtr<ProcmanApp> application = ProcmanApp::create();
+    return application->run (argc, argv);
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/16.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/16.html new file mode 100644 index 00000000..91267585 --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/16.html @@ -0,0 +1,913 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
/* Process properties dialog
+ * Copyright (C) 2010 Krishnan Parthasarathi <krishnan.parthasarathi@gmail.com>
+ *                    Robert Ancell <robert.ancell@canonical.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <glibtop/procmem.h>
+#include <glibtop/procmap.h>
+#include <glibtop/procstate.h>
+
+#include "procman.h"
+#include "procproperties.h"
+#include "proctable.h"
+#include "util.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
+enum
+{
+    COL_PROP = 0,
+    COL_VAL,
+    NUM_COLS,
+};
+
+typedef struct _proc_arg {
+    const gchar *prop;
+    gchar *val;
+} proc_arg;
+
+static void
+get_process_memory_writable (ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info (ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+static gchar*
+format_memsize(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
+}
+
+static gchar*
+format_size(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size(size);
+}
+
+static void
+fill_proc_properties (GtkWidget *tree, ProcInfo *info)
+{
+    guint i;
+    GtkListStore *store;
+
+    if (!info)
+        return;
+
+    get_process_memory_info(info);
+
+    proc_arg proc_props[] = {
+        { N_("Process Name"), g_strdup_printf("%s", info->name)},
+        { N_("User"), g_strdup_printf("%s (%d)", info->user.c_str(), info->uid)},
+        { N_("Status"), g_strdup(format_process_state(info->status))},
+        { N_("Memory"), format_memsize(info->mem)},
+        { N_("Virtual Memory"), format_memsize(info->vmsize)},
+        { N_("Resident Memory"), format_memsize(info->memres)},
+        { N_("Writable Memory"), format_memsize(info->memwritable)},
+        { N_("Shared Memory"), format_memsize(info->memshared)},
+#ifdef HAVE_WNCK
+        { N_("X Server Memory"), format_memsize(info->memxserver)},
+#endif
+        { N_("Disk Read Total"), format_size(info->disk_read_bytes_total)},
+        { N_("Disk Write Total"), format_size(info->disk_write_bytes_total)},
+        { N_("CPU"), g_strdup_printf("%d%%", info->pcpu)},
+        { N_("CPU Time"), procman::format_duration_for_display(100 * info->cpu_time / ProcData::get_instance()->frequency) },
+        { N_("Started"), procman_format_date_for_display(info->start_time) },
+        { N_("Nice"), g_strdup_printf("%d", info->nice)},
+        { N_("Priority"), g_strdup_printf("%s", procman::get_nice_level(info->nice)) },
+        { N_("ID"), g_strdup_printf("%d", info->pid)},
+        { N_("Security Context"), info->security_context ? g_strdup_printf("%s", info->security_context) : g_strdup(_("N/A"))},
+        { N_("Command Line"), g_strdup_printf("%s", info->arguments)},
+        { N_("Waiting Channel"), g_strdup_printf("%s", info->wchan)},
+        { N_("Control Group"), info->cgroup_name ? g_strdup_printf("%s", info->cgroup_name) : g_strdup(_("N/A"))},
+        { NULL, NULL}
+    };
+
+    store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
+    for (i = 0; proc_props[i].prop; i++) {
+        GtkTreeIter iter;
+
+        if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL(store), &iter, NULL, i)) {
+            gtk_list_store_append(store, &iter);
+            gtk_list_store_set(store, &iter, COL_PROP, _(proc_props[i].prop), -1);
+        }
+
+        gtk_list_store_set(store, &iter, COL_VAL, g_strstrip(proc_props[i].val), -1);
+        g_free(proc_props[i].val);
+    }
+}
+
+static void
+update_procproperties_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    fill_proc_properties(tree, info);
+}
+
+static void
+close_procprop_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    guint timer;
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static GtkWidget *
+create_procproperties_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    model = gtk_list_store_new (NUM_COLS,
+                                G_TYPE_STRING,	/* Property */
+                                G_TYPE_STRING	/* Value */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_COLS; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        column = gtk_tree_view_column_new_with_attributes (NULL,
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tree), FALSE);
+    fill_proc_properties(tree, procdata->selected_process);
+
+    return tree;
+}
+
+static gboolean
+procprop_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_procproperties_dialog (tree);
+
+    return TRUE;
+}
+
+static void
+create_single_procproperties_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                     GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *procpropdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    procpropdialog = gtk_dialog_new_with_buttons (_("Process Properties"), NULL,
+                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                  "gtk-close", GTK_RESPONSE_CLOSE,
+                                                  NULL);
+    gtk_window_set_resizable (GTK_WINDOW (procpropdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (procpropdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (procpropdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (procpropdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("Properties of process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_procproperties_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (procpropdialog), "response",
+                      G_CALLBACK (close_procprop_dialog), tree);
+
+    gtk_widget_show_all (procpropdialog);
+
+    timer = g_timeout_add_seconds (5, procprop_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_procproperties_dialog (tree);
+}
+
+void
+create_procproperties_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_procproperties_dialog,
+                                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/17.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/17.html new file mode 100644 index 00000000..3ce08395 --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/17.html @@ -0,0 +1,2635 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
/* Procman tree view and process updating
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <cairo-gobject.h>
+#include <string.h>
+#include <math.h>
+#include <glib/gi18n.h>
+#include <glib/gprintf.h>
+#include <glibtop.h>
+#include <glibtop/loadavg.h>
+#include <glibtop/proclist.h>
+#include <glibtop/procio.h>
+#include <glibtop/procstate.h>
+#include <glibtop/procmem.h>
+#include <glibtop/procmap.h>
+#include <glibtop/proctime.h>
+#include <glibtop/procuid.h>
+#include <glibtop/procargs.h>
+#include <glibtop/prockernel.h>
+#include <glibtop/mem.h>
+#include <glibtop/swap.h>
+#include <sys/stat.h>
+#include <pwd.h>
+#include <time.h>
+
+#include <set>
+#include <list>
+
+#ifdef HAVE_SYSTEMD
+#include <systemd/sd-login.h>
+#endif
+
+#include "procman.h"
+#include "selection.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "util.h"
+#include "interface.h"
+#include "selinux.h"
+#include "cgroups.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
+ProcInfo::UserMap ProcInfo::users;
+ProcInfo::List ProcInfo::all;
+std::map<pid_t, guint64> ProcInfo::cpu_times;
+
+
+ProcInfo* ProcInfo::find(pid_t pid)
+{
+    Iterator it(ProcInfo::all.find(pid));
+    return (it == ProcInfo::all.end() ? NULL : it->second);
+}
+
+void
+get_last_selected (GtkTreeModel *model, GtkTreePath *path,
+           GtkTreeIter *iter, gpointer data)
+{
+    ProcInfo **info = static_cast<ProcInfo**>(data);
+
+    gtk_tree_model_get (model, iter, COL_POINTER, info, -1);
+}
+
+static void
+cb_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "proctree");
+}
+
+static void
+cb_sort_changed (GtkTreeSortable *model, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state (procdata->settings,
+                             GTK_WIDGET (procdata->tree),
+                             "proctree");
+}
+
+
+static GtkTreeViewColumn*
+my_gtk_tree_view_get_column_with_sort_column_id(GtkTreeView *treeview, int id)
+{
+    GList *columns, *it;
+    GtkTreeViewColumn *col = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(it = columns; it; it = it->next)
+    {
+        if(gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(it->data)) == id)
+        {
+            col = static_cast<GtkTreeViewColumn*>(it->data);
+            break;
+        }
+    }
+
+    g_list_free(columns);
+
+    return col;
+}
+
+
+void
+proctable_set_columns_order(GtkTreeView *treeview, GSList *order)
+{
+    GtkTreeViewColumn* last = NULL;
+    GSList *it;
+
+    for(it = order; it; it = it->next)
+    {
+        int id;
+        GtkTreeViewColumn *cur;
+
+        id = GPOINTER_TO_INT(it->data);
+
+        cur = my_gtk_tree_view_get_column_with_sort_column_id(treeview, id);
+
+        if(cur && cur != last)
+        {
+            gtk_tree_view_move_column_after(treeview, cur, last);
+            last = cur;
+        }
+    }
+}
+
+
+GSList*
+proctable_get_columns_order(GtkTreeView *treeview)
+{
+    GList *columns, *col;
+    GSList *order = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(col = columns; col; col = col->next)
+    {
+        int id;
+
+        id = gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(col->data));
+        order = g_slist_prepend(order, GINT_TO_POINTER(id));
+    }
+
+    g_list_free(columns);
+
+    order = g_slist_reverse(order);
+
+    return order;
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "proctree");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_proctable_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+static gboolean
+search_equal_func(GtkTreeModel *model,
+                  gint column,
+                  const gchar *key,
+                  GtkTreeIter *iter,
+                  gpointer search_data)
+{
+    char* name;
+    char* user;
+    gboolean found;
+
+    gtk_tree_model_get(model, iter,
+                       COL_NAME, &name,
+                       COL_USER, &user,
+                       -1);
+
+    found = !((name && strcasestr(name, key))
+              || (user && strcasestr(user, key)));
+
+    g_free(name);
+    g_free(user);
+
+    return found;
+}
+
+
+
+GtkWidget *
+proctable_new (ProcData * const procdata)
+{
+    GtkWidget *proctree;
+    GtkTreeStore *model;
+    GtkTreeSelection *selection;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell_renderer;
+
+    const gchar *titles[] = {
+        N_("Process Name"),
+        N_("User"),
+        N_("Status"),
+        N_("Virtual Memory"),
+        N_("Resident Memory"),
+        N_("Writable Memory"),
+        N_("Shared Memory"),
+        N_("X Server Memory"),
+        /* xgettext:no-c-format */ N_("% CPU"),
+        N_("CPU Time"),
+        N_("Started"),
+        N_("Nice"),
+        N_("ID"),
+        N_("Security Context"),
+        N_("Command Line"),
+        N_("Memory"),
+        /* xgettext: combined noun, the function the process is waiting in, see wchan ps(1) */
+        N_("Waiting Channel"),
+        N_("Control Group"),
+        N_("Unit"),
+        N_("Session"),
+        /* TRANSLATORS: Seat = i.e. the physical seat the session of the process belongs to, only
+	for multi-seat environments. See http://en.wikipedia.org/wiki/Multiseat_configuration */
+        N_("Seat"),
+        N_("Owner"),
+        N_("Disk Read Total"),
+        N_("Disk Write Total"),
+        N_("Disk Read"),
+        N_("Disk Write"),
+        N_("Priority"),
+        NULL,
+        "POINTER"
+    };
+
+    gint i;
+
+    model = gtk_tree_store_new (NUM_COLUMNS,
+                                G_TYPE_STRING,              /* Process Name */
+                                G_TYPE_STRING,              /* User         */
+                                G_TYPE_UINT,                /* Status       */
+                                G_TYPE_ULONG,               /* VM Size      */
+                                G_TYPE_ULONG,               /* Resident Memory */
+                                G_TYPE_ULONG,               /* Writable Memory */
+                                G_TYPE_ULONG,               /* Shared Memory */
+                                G_TYPE_ULONG,               /* X Server Memory */
+                                G_TYPE_UINT,                /* % CPU        */
+                                G_TYPE_UINT64,              /* CPU time     */
+                                G_TYPE_ULONG,               /* Started      */
+                                G_TYPE_INT,                 /* Nice         */
+                                G_TYPE_UINT,                /* ID           */
+                                G_TYPE_STRING,              /* Security Context */
+                                G_TYPE_STRING,              /* Arguments    */
+                                G_TYPE_ULONG,               /* Memory       */
+                                G_TYPE_STRING,              /* wchan        */
+                                G_TYPE_STRING,              /* Cgroup       */
+                                G_TYPE_STRING,              /* Unit         */
+                                G_TYPE_STRING,              /* Session      */
+                                G_TYPE_STRING,              /* Seat         */
+                                G_TYPE_STRING,              /* Owner        */
+                                G_TYPE_UINT64,              /* Disk read total */
+                                G_TYPE_UINT64,              /* Disk write total*/
+                                G_TYPE_UINT64,              /* Disk read    */
+                                G_TYPE_UINT64,              /* Disk write   */
+                                G_TYPE_STRING,              /* Priority     */
+                                CAIRO_GOBJECT_TYPE_SURFACE, /* Icon         */
+                                G_TYPE_POINTER,             /* ProcInfo     */
+                                G_TYPE_STRING               /* Sexy tooltip */
+        );
+
+    proctree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (proctree), COL_TOOLTIP);
+    g_object_set(G_OBJECT(proctree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+    gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (proctree),
+                                         search_equal_func,
+                                         NULL,
+                                         NULL);
+    g_object_unref (G_OBJECT (model));
+
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree));
+    gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+
+    column = gtk_tree_view_column_new ();
+
+    cell_renderer = gtk_cell_renderer_pixbuf_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "surface", COL_SURFACE,
+                                         NULL);
+
+    cell_renderer = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "text", COL_NAME,
+                                         NULL);
+    gtk_tree_view_column_set_title (column, _(titles[0]));
+    gtk_tree_view_column_set_sort_column_id (column, COL_NAME);
+    gtk_tree_view_column_set_resizable (column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+    gtk_tree_view_column_set_min_width (column, 20);
+    gtk_tree_view_column_set_reorderable (column, TRUE);
+    g_signal_connect(G_OBJECT(column), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (proctree), column);
+    gtk_tree_view_set_expander_column (GTK_TREE_VIEW (proctree), column);
+
+
+    for (i = COL_USER; i <= COL_PRIORITY; i++) {
+
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+#ifndef HAVE_WNCK
+        if (i == COL_MEMXSERVER) {
+          continue;
+        }
+#endif
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(proctree), col);
+
+        // type
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_CPU_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::duration_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_START_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::time_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_STATUS:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::status_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::io_rate_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_PRIORITY:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::priority_cell_data_func,
+                                                        GUINT_TO_POINTER(COL_NICE),
+                                                        NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+        }
+
+        // sorting
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+            case COL_CPU:
+            case COL_CPU_TIME:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_START_TIME:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::number_compare_func, GUINT_TO_POINTER(i),
+                                                NULL);
+                break;
+            case COL_PRIORITY:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::priority_compare_func,
+                                                GUINT_TO_POINTER(COL_NICE), NULL);
+                break;
+            default:
+                break;
+        }
+
+        // xalign
+        switch(i)
+        {
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMWRITABLE:
+            case COL_MEMSHARED:
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_CPU:
+            case COL_NICE:
+            case COL_PID:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_CPU_TIME:
+            case COL_MEM:
+                g_object_set(G_OBJECT(cell), "xalign", 1.0f, NULL);
+                break;
+        }
+
+        // sizing
+        switch (i) {
+            case COL_ARGS:
+                gtk_tree_view_column_set_min_width(col, 150);
+                break;
+            default:
+                gtk_tree_view_column_set_min_width(col, 20);
+                break;
+        }
+    }
+
+    procdata->tree = proctree;
+
+    procman_get_tree_state (procdata->settings, proctree, "proctree");
+
+    /* Override column settings by hiding this column if it's meaningless: */
+    if (!can_show_security_context_column ()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id (GTK_TREE_VIEW (proctree), COL_SECURITYCONTEXT);
+        gtk_tree_view_column_set_visible (column, FALSE);
+    }
+
+    if (!cgroups_enabled()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), COL_CGROUP);
+        gtk_tree_view_column_set_visible(column, FALSE);
+    }
+
+#ifdef HAVE_SYSTEMD
+    if (!LOGIND_RUNNING())
+#endif
+    {
+        for (i = COL_UNIT; i <= COL_OWNER; i++) {
+            column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), i);
+            gtk_tree_view_column_set_visible(column, FALSE);
+        }
+    }
+
+    g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree))),
+                      "changed",
+                      G_CALLBACK (cb_row_selected), procdata);
+    g_signal_connect (G_OBJECT (proctree), "popup_menu",
+                      G_CALLBACK (cb_tree_popup_menu), procdata);
+    g_signal_connect (G_OBJECT (proctree), "button_press_event",
+                      G_CALLBACK (cb_tree_button_pressed), procdata);
+
+    g_signal_connect (G_OBJECT(proctree), "columns-changed",
+                      G_CALLBACK(cb_columns_changed), procdata);
+
+    g_signal_connect (G_OBJECT (model), "sort-column-changed",
+                      G_CALLBACK (cb_sort_changed), procdata);
+
+    return proctree;
+}
+
+
+ProcInfo::~ProcInfo()
+{
+    g_free(this->name);
+    g_free(this->tooltip);
+    g_free(this->arguments);
+    g_free(this->security_context);
+    g_free(this->cgroup_name);
+    g_free(this->unit);
+    g_free(this->session);
+    g_free(this->seat);
+    cairo_surface_destroy(this->surface);
+}
+
+
+static void
+get_process_name (ProcInfo *info,
+                  const gchar *cmd, const GStrv args)
+{
+    if (args) {
+        // look for /usr/bin/very_long_name
+        // and also /usr/bin/interpreter /usr/.../very_long_name
+        // which may have use prctl to alter 'cmd' name
+        for (int i = 0; i != 2 && args[i]; ++i) {
+            char* basename;
+            basename = g_path_get_basename(args[i]);
+
+            if (g_str_has_prefix(basename, cmd)) {
+                info->name = basename;
+                return;
+            }
+
+            g_free(basename);
+        }
+    }
+
+    info->name = g_strdup (cmd);
+}
+
+std::string
+ProcInfo::lookup_user(guint uid)
+{
+    typedef std::pair<ProcInfo::UserMap::iterator, bool> Pair;
+    ProcInfo::UserMap::value_type hint(uid, "");
+    Pair p(ProcInfo::users.insert(hint));
+
+    // procman_debug("User lookup for uid %u: %s", uid, (p.second ? "MISS" : "HIT"));
+
+    if (p.second) {
+        struct passwd* pwd;
+        pwd = getpwuid(uid);
+
+        if (pwd && pwd->pw_name)
+            p.first->second = pwd->pw_name;
+        else {
+            char username[16];
+            g_sprintf(username, "%u", uid);
+            p.first->second = username;
+        }
+    }
+
+    return p.first->second;
+}
+
+void
+ProcInfo::set_user(guint uid)
+{
+    if (G_LIKELY(this->uid == uid))
+        return;
+
+    this->uid = uid;
+    this->user = lookup_user(uid);
+}
+
+static void get_process_memory_writable(ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info(ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+
+static void
+update_info_mutable_cols(ProcInfo *info)
+{
+    ProcData * const procdata = ProcData::get_instance();
+    GtkTreeModel *model;
+    model = gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->tree));
+
+    using procman::tree_store_update;
+
+    tree_store_update(model, &info->node, COL_STATUS, info->status);
+    tree_store_update(model, &info->node, COL_USER, info->user.c_str());
+    tree_store_update(model, &info->node, COL_VMSIZE, info->vmsize);
+    tree_store_update(model, &info->node, COL_MEMRES, info->memres);
+    tree_store_update(model, &info->node, COL_MEMWRITABLE, info->memwritable);
+    tree_store_update(model, &info->node, COL_MEMSHARED, info->memshared);
+#ifdef HAVE_WNCK
+    tree_store_update(model, &info->node, COL_MEMXSERVER, info->memxserver);
+#endif
+    tree_store_update(model, &info->node, COL_CPU, info->pcpu);
+    tree_store_update(model, &info->node, COL_CPU_TIME, info->cpu_time);
+    tree_store_update(model, &info->node, COL_DISK_READ_TOTAL, info->disk_read_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_TOTAL, info->disk_write_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_READ_CURRENT, info->disk_read_bytes_current);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_CURRENT, info->disk_write_bytes_current);
+    tree_store_update(model, &info->node, COL_START_TIME, info->start_time);
+    tree_store_update(model, &info->node, COL_NICE, info->nice);
+    tree_store_update(model, &info->node, COL_MEM, info->mem);
+    tree_store_update(model, &info->node, COL_WCHAN, info->wchan);
+    tree_store_update(model, &info->node, COL_CGROUP, info->cgroup_name);
+    tree_store_update(model, &info->node, COL_UNIT, info->unit);
+    tree_store_update(model, &info->node, COL_SESSION, info->session);
+    tree_store_update(model, &info->node, COL_SEAT, info->seat);
+    tree_store_update(model, &info->node, COL_OWNER, info->owner.c_str());
+}
+
+
+
+static void
+insert_info_to_tree (ProcInfo *info, ProcData *procdata, bool forced = false)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    if (procdata->config.show_tree) {
+
+        ProcInfo *parent = 0;
+
+        if (not forced)
+            parent = ProcInfo::find(info->ppid);
+
+        if (parent) {
+            GtkTreePath *parent_node = gtk_tree_model_get_path(model, &parent->node);
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, &parent->node, 0);
+
+            if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(procdata->tree), parent_node)
+#ifdef __linux__
+                // on linuxes we don't want to expand kthreadd by default (always has pid 2)
+                && (parent->pid != 2)
+#endif
+            )
+                gtk_tree_view_expand_row(GTK_TREE_VIEW(procdata->tree), parent_node, FALSE);
+            gtk_tree_path_free(parent_node);
+        } else
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, NULL, 0);
+    }
+    else
+        gtk_tree_store_insert (GTK_TREE_STORE (model), &info->node, NULL, 0);
+
+    gtk_tree_store_set (GTK_TREE_STORE (model), &info->node,
+                        COL_POINTER, info,
+                        COL_NAME, info->name,
+                        COL_ARGS, info->arguments,
+                        COL_TOOLTIP, info->tooltip,
+                        COL_PID, info->pid,
+                        COL_SECURITYCONTEXT, info->security_context,
+                        -1);
+
+    procdata->pretty_table.set_icon(*info);
+
+    procman_debug("inserted %d%s", info->pid, (forced ? " (forced)" : ""));
+}
+
+
+/* Removing a node with children - make sure the children are queued
+** to be readded.
+*/
+template<typename List>
+static void
+remove_info_from_tree (ProcData *procdata, GtkTreeModel *model,
+                       ProcInfo *current, List &orphans, unsigned lvl = 0)
+{
+    GtkTreeIter child_node;
+
+    if (std::find(orphans.begin(), orphans.end(), current) != orphans.end()) {
+        procman_debug("[%u] %d already removed from tree", lvl, int(current->pid));
+        return;
+    }
+
+    procman_debug("[%u] pid %d, %d children", lvl, int(current->pid),
+                  gtk_tree_model_iter_n_children(model, &current->node));
+
+    // it is not possible to iterate&erase over a treeview so instead we
+    // just pop one child after another and recursively remove it and
+    // its children
+
+    while (gtk_tree_model_iter_children(model, &child_node, &current->node)) {
+        ProcInfo *child = 0;
+        gtk_tree_model_get(model, &child_node, COL_POINTER, &child, -1);
+        remove_info_from_tree(procdata, model, child, orphans, lvl + 1);
+    }
+
+    g_assert(not gtk_tree_model_iter_has_child(model, &current->node));
+
+    if (procdata->selected_process == current)
+        procdata->selected_process = NULL;
+
+    orphans.push_back(current);
+    gtk_tree_store_remove(GTK_TREE_STORE(model), &current->node);
+    procman::poison(current->node, 0x69);
+}
+
+static void
+get_process_systemd_info(ProcInfo *info)
+{
+#ifdef HAVE_SYSTEMD
+    uid_t uid;
+
+    if (!LOGIND_RUNNING())
+        return;
+
+    free(info->unit);
+    info->unit = NULL;
+    sd_pid_get_unit(info->pid, &info->unit);
+
+    free(info->session);
+    info->session = NULL;
+    sd_pid_get_session(info->pid, &info->session);
+
+    free(info->seat);
+    info->seat = NULL;
+
+    if (info->session != NULL)
+        sd_session_get_seat(info->session, &info->seat);
+
+    if (sd_pid_get_owner_uid(info->pid, &uid) >= 0)
+        info->owner = info->lookup_user(uid);
+    else
+        info->owner = "";
+#endif
+}
+
+static void
+update_info (ProcData *procdata, ProcInfo *info)
+{
+    glibtop_proc_state procstate;
+    glibtop_proc_uid procuid;
+    glibtop_proc_time proctime;
+    glibtop_proc_kernel prockernel;
+    glibtop_proc_io procio;
+
+    glibtop_get_proc_kernel(&prockernel, info->pid);
+    g_strlcpy(info->wchan, prockernel.wchan, sizeof info->wchan);
+
+    glibtop_get_proc_state (&procstate, info->pid);
+    info->status = procstate.state;
+
+    glibtop_get_proc_uid (&procuid, info->pid);
+    glibtop_get_proc_time (&proctime, info->pid);
+    glibtop_get_proc_io (&procio, info->pid);
+
+    get_process_memory_info(info);
+
+    info->set_user(procstate.uid);
+
+    // if the cpu time has increased reset the status to running
+    // regardless of kernel state (https://bugzilla.gnome.org/606579)
+    guint64 difference = proctime.rtime - info->cpu_time;
+    if (difference > 0)
+        info->status = GLIBTOP_PROCESS_RUNNING;
+    info->pcpu = difference * 100 / procdata->cpu_total_time;
+    info->pcpu = MIN(info->pcpu, 100);
+
+    if (not procdata->config.solaris_mode)
+      info->pcpu *= procdata->config.num_cpus;
+
+    ProcInfo::cpu_times[info->pid] = info->cpu_time = proctime.rtime;
+    info->nice = procuid.nice;
+
+    gdouble update_interval_seconds = procdata->config.update_interval / 1000.0;
+    difference = procio.disk_wbytes - info->disk_write_bytes_total;
+    info->disk_write_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+    difference = procio.disk_rbytes - info->disk_read_bytes_total;
+    info->disk_read_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+
+    info->disk_write_bytes_total = procio.disk_wbytes;
+    info->disk_read_bytes_total = procio.disk_rbytes;
+
+    // set the ppid only if one can exist
+    // i.e. pid=0 can never have a parent
+    if (info->pid > 0) {
+        info->ppid = procuid.ppid;
+    }
+
+    g_assert(info->pid != info->ppid);
+    g_assert(info->ppid != -1 || info->pid == 0);
+
+    /* get cgroup data */
+    get_process_cgroup_info(info);
+
+    get_process_systemd_info(info);
+}
+
+
+ProcInfo::ProcInfo(pid_t pid)
+    : node(),
+      surface(),
+      tooltip(NULL),
+      name(NULL),
+      arguments(NULL),
+      security_context(NULL),
+      pid(pid),
+      ppid(-1),
+      uid(-1)
+{
+    ProcInfo * const info = this;
+    glibtop_proc_state procstate;
+    glibtop_proc_time proctime;
+    glibtop_proc_args procargs;
+    gchar** arguments;<--- Shadow variable
+
+    glibtop_get_proc_state (&procstate, pid);
+    glibtop_get_proc_time (&proctime, pid);
+    arguments = glibtop_get_proc_argv (&procargs, pid, 0);
+
+    /* FIXME : wrong. name and arguments may change with exec* */
+    get_process_name (info, procstate.cmd, static_cast<const GStrv>(arguments));
+
+    std::string tooltip = make_string(g_strjoinv(" ", arguments));<--- Shadow variable
+    if (tooltip.empty())
+        tooltip = procstate.cmd;
+
+    info->tooltip = g_markup_escape_text(tooltip.c_str(), -1);
+
+    info->arguments = g_strescape(tooltip.c_str(), "\\\"");
+    g_strfreev(arguments);
+
+    guint64 cpu_time = proctime.rtime;
+    std::map<pid_t, guint64>::iterator it(ProcInfo::cpu_times.find(pid));
+    if (it != ProcInfo::cpu_times.end())
+    {
+        if (proctime.rtime >= it->second)
+          cpu_time = it->second;
+    }
+    info->cpu_time = cpu_time;
+    info->start_time = proctime.start_time;
+
+    get_process_selinux_context (info);
+    info->cgroup_name = NULL;
+    get_process_cgroup_info(info);
+
+    info->unit = info->session = info->seat = NULL;
+    get_process_systemd_info(info);
+}
+
+static void
+refresh_list (ProcData *procdata, const pid_t* pid_list, const guint n)
+{
+    typedef std::list<ProcInfo*> ProcList;
+    ProcList addition;
+
+    GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+    guint i;
+
+    // Add or update processes in the process list
+    for(i = 0; i < n; ++i) {
+        ProcInfo *info = ProcInfo::find(pid_list[i]);
+
+        if (!info) {
+            info = new ProcInfo(pid_list[i]);
+            ProcInfo::all[info->pid] = info;
+            addition.push_back(info);
+        }
+
+        update_info (procdata, info);
+    }
+
+
+    // Remove dead processes from the process list and from the
+    // tree. children are queued to be readded at the right place
+    // in the tree.
+
+    const std::set<pid_t> pids(pid_list, pid_list + n);
+
+    ProcInfo::Iterator it(ProcInfo::begin());<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration
+
+    while (it != ProcInfo::end()) {
+        ProcInfo * const info = it->second;
+        ProcInfo::Iterator next(it);
+        ++next;
+
+        if (pids.find(info->pid) == pids.end()) {
+            procman_debug("ripping %d", info->pid);
+            remove_info_from_tree(procdata, model, info, addition);
+            addition.remove(info);
+            ProcInfo::all.erase(it);
+            delete info;
+        }
+
+        it = next;
+    }
+
+    // INVARIANT
+    // pid_list == ProcInfo::all + addition
+
+
+    if (procdata->config.show_tree) {
+
+        // insert process in the tree. walk through the addition list
+        // (new process + process that have a new parent). This loop
+        // handles the dependencies because we cannot insert a process
+        // until its parent is in the tree.
+
+        std::set<pid_t> in_tree(pids);
+
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            in_tree.erase((*it)->pid);
+
+
+        while (not addition.empty()) {
+            procman_debug("looking for %d parents", int(addition.size()));
+            ProcList::iterator it(addition.begin());<--- Shadow variable
+
+            while (it != addition.end()) {
+                procman_debug("looking for %d's parent with ppid %d",
+                              int((*it)->pid), int((*it)->ppid));
+
+
+                // inserts the process in the treeview if :
+                // - it has no parent (ppid = -1),
+                //   ie it is for example the [kernel] on FreeBSD
+                // - it is init
+                // - its parent is already in tree
+                // - its parent is unreachable
+                //
+                // rounds == 2 means that addition contains processes with
+                // unreachable parents
+                //
+                // FIXME: this is broken if the unreachable parent becomes active
+                // i.e. it gets active or changes ower
+                // so we just clear the tree on __each__ update
+                // see proctable_update_list (ProcData * const procdata)
+
+
+                if ((*it)->ppid <= 0 or in_tree.find((*it)->ppid) != in_tree.end()) {
+                    insert_info_to_tree(*it, procdata);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ProcInfo *parent = ProcInfo::find((*it)->ppid);
+                // if the parent is unreachable
+                if (not parent) {
+                    // or std::find(addition.begin(), addition.end(), parent) == addition.end()) {
+                    insert_info_to_tree(*it, procdata, true);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ++it;
+            }
+        }
+    }
+    else {
+        // don't care of the tree
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            insert_info_to_tree(*it, procdata);
+    }
+
+
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)<--- Shadow variable
+        update_info_mutable_cols(it->second);
+}
+
+
+static void
+proctable_update_list (ProcData * const procdata)
+{
+    pid_t* pid_list;
+    glibtop_proclist proclist;
+    glibtop_cpu cpu;
+    gint which, arg;
+    procman::SelectionMemento selection;
+
+    switch (procdata->config.whose_process) {
+        case ALL_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL;
+            arg = 0;
+            break;
+
+        case ACTIVE_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL | GLIBTOP_EXCLUDE_IDLE;
+            arg = 0;
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+
+        default:
+            which = GLIBTOP_KERN_PROC_UID;
+            arg = getuid ();
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+    }
+
+    pid_list = glibtop_get_proclist (&proclist, which, arg);
+
+    /* FIXME: total cpu time elapsed should be calculated on an individual basis here
+    ** should probably have a total_time_last gint in the ProcInfo structure */
+    glibtop_get_cpu (&cpu);
+    procdata->cpu_total_time = MAX(cpu.total - procdata->cpu_total_time_last, 1);
+    procdata->cpu_total_time_last = cpu.total;
+
+    // FIXME: not sure if glibtop always returns a sorted list of pid
+    // but it is important otherwise refresh_list won't find the parent
+    std::sort(pid_list, pid_list + proclist.number);
+
+    refresh_list (procdata, pid_list, proclist.number);
+
+    selection.restore(procdata->tree);
+
+    g_free (pid_list);
+
+    /* proclist.number == g_list_length(procdata->info) == g_hash_table_size(procdata->pids) */
+}
+
+
+void
+proctable_update (ProcData * const procdata)
+{
+    char* string;
+
+    string = make_loadavg_string();
+    gtk_label_set_text (GTK_LABEL(procdata->loadavg), string);
+    g_free (string);
+
+    proctable_update_list (procdata);
+}
+
+
+void
+proctable_free_table (ProcData * const procdata)
+{
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)
+        delete it->second;
+
+    ProcInfo::all.clear();
+}
+
+
+void
+proctable_clear_tree (ProcData * const procdata)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    gtk_tree_store_clear (GTK_TREE_STORE (model));
+
+    proctable_free_table (procdata);
+
+    update_sensitivity(procdata);
+}
+
+
+char*
+make_loadavg_string(void)
+{
+    glibtop_loadavg buf;
+
+    glibtop_get_loadavg(&buf);
+
+    return g_strdup_printf(
+        _("Load averages for the last 1, 5, 15 minutes: "
+          "%0.2f, %0.2f, %0.2f"),
+        buf.loadavg[0],
+        buf.loadavg[1],
+        buf.loadavg[2]);
+}
+
+
+
+void
+ProcInfo::set_icon(Glib::RefPtr<Gdk::Pixbuf> icon)
+{
+  this->surface = gdk_cairo_surface_create_from_pixbuf (icon->gobj(), 0, NULL);
+
+  GtkTreeModel *model;
+  model = gtk_tree_view_get_model(GTK_TREE_VIEW(ProcData::get_instance()->tree));
+  gtk_tree_store_set(GTK_TREE_STORE(model), &this->node,
+                     COL_SURFACE, this->surface,
+                    -1);
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/18.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/18.html new file mode 100644 index 00000000..4e691255 --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/18.html @@ -0,0 +1,405 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
#include <config.h>
+
+#include <glib.h>
+
+#include "selinux.h"
+#include "procman.h"
+#include "util.h"
+
+
+static int (*getpidcon)(pid_t, char**);
+static void (*freecon)(char*);
+static int (*is_selinux_enabled)(void);
+
+static gboolean has_selinux;
+
+static gboolean load_selinux(void)
+{
+    return load_symbols("libselinux.so.1",
+                        "getpidcon", &getpidcon,
+                        "freecon", &freecon,
+                        "is_selinux_enabled", &is_selinux_enabled,
+                        NULL);
+}
+
+
+
+void
+get_process_selinux_context (ProcInfo *info)
+{
+    char *con;
+
+    if (has_selinux && !getpidcon (info->pid, &con)) {
+        info->security_context = g_strdup (con);
+        freecon (con);
+    }
+}
+
+
+
+gboolean
+can_show_security_context_column (void)
+{
+    if (!(has_selinux = load_selinux()))
+        return FALSE;
+
+    switch (is_selinux_enabled()) {
+        case 1:
+            /* We're running on an SELinux kernel */
+            return TRUE;
+
+        case -1:
+            /* Error; hide the security context column */
+
+        case 0:
+            /* We're not running on an SELinux kernel:
+               hide the security context column */
+
+        default:
+            g_warning("SELinux was found but is not enabled.\n");
+            return FALSE;
+    }
+}
+
+
+
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/19.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/19.html new file mode 100644 index 00000000..913bbae3 --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/19.html @@ -0,0 +1,2359 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
#include <config.h>
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <glibmm.h>
+#include <glib/gi18n.h>
+
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+
+#include <glibtop/fsusage.h>
+#include <glibtop/mountlist.h>
+#include <glibtop/mem.h>
+#include <glibtop/sysinfo.h>
+
+#include <unistd.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#include <math.h>
+#include <errno.h>
+
+#include <exception>
+#include <string>
+#include <vector>
+#include <fstream>
+#include <sstream>
+#include <sys/utsname.h>
+
+#include "sysinfo.h"
+#include "procman.h"
+#include "util.h"
+
+
+using std::string;
+using std::vector;
+
+
+namespace {
+
+    class SysInfo
+    {
+    public:
+        string hostname;
+        string distro_name;
+        string distro_release;
+        string kernel;
+        string mate_version;
+        guint64 memory_bytes;
+        guint64 free_space_bytes;
+
+        string graphics;
+        string processors;
+
+        SysInfo()
+        {
+            this->load_processors_info();
+            this->load_graphics_info();
+            this->load_memory_info();
+            this->load_disk_info();
+            this->load_uname_info();
+            this->load_mate_version();
+        }
+
+        virtual ~SysInfo()
+        { }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Virtual function in base class
+        {
+            g_object_set(G_OBJECT(name),
+                        "label",
+                        ("<big><big><b>" + this->distro_name + "</b></big></big>").c_str(),
+                        NULL);
+
+            char* markup;
+#ifdef __linux__
+            if (this->distro_release != "")
+            {
+                /* Translators: The first string parameter is release version (codename),
+                 * the second one is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("Release %s %s"),
+                                         this->distro_release.c_str(),
+                                         SysInfo::get_os_type().c_str());
+            }
+            else
+            {
+                /* Translators: The string parameter is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("%s Version"),
+                                         SysInfo::get_os_type().c_str());
+            }
+#else
+            /* Translators: The string parameter is release version (codename) */
+            markup = g_strdup_printf(_("Release %s"),
+                                     this->distro_release.c_str());
+#endif
+
+            g_object_set(G_OBJECT(release),
+                         "label",
+                         markup,
+                         NULL);
+
+            g_free(markup);
+        }
+
+        static string release()
+        {
+            return uname().release;
+        }
+
+        static string system()
+        {
+            return uname().sysname;
+        }
+
+    private:
+
+        void load_memory_info()
+        {
+            glibtop_mem mem;
+
+            glibtop_get_mem(&mem);
+            this->memory_bytes = mem.total;
+        }
+
+        static string get_os_type ()<--- Unused private function: 'SysInfo::get_os_type'
+        {
+            int bits;
+
+            if (GLIB_SIZEOF_VOID_P == 8)
+                bits = 64;
+            else
+                bits = 32;
+
+            /* translators: This is the type of architecture, for example:
+             * "64-bit" or "32-bit" */
+            char* bytes = g_strdup_printf (_("%d-bit"), bits);
+            string retval(bytes);
+            g_free(bytes);
+            return retval;
+        }
+
+        typedef struct
+        {
+            const char* regex;
+            const char* replacement;
+        } ReplaceStrings;
+
+        static char* remove_duplicate_whitespace (const char* old)
+        {
+            char* result;
+            GRegex* re;
+            GError* error = NULL;
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+
+            re = g_regex_new ("[ \t\n\r]+", G_REGEX_MULTILINE, flags, &error);
+            if (re == NULL) {
+                g_warning ("Error building regex: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+            result = g_regex_replace (re, old, -1, 0, " ", flags, &error);
+            g_regex_unref (re);
+            if (result == NULL) {
+                g_warning ("Error replacing string: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+
+            return result;
+        }
+
+        static char* prettify_info (const char *info)
+        {
+            char* pretty;
+            const GRegexCompileFlags cflags = static_cast<GRegexCompileFlags>(0);
+            const GRegexMatchFlags mflags = static_cast<GRegexMatchFlags>(0);
+
+            static const ReplaceStrings rs[] = {
+                { "Intel[(]R[)]", "Intel\302\256"},
+                { "Core[(]TM[)]", "Core\342\204\242"},
+                { "Atom[(]TM[)]", "Atom\342\204\242"},
+            };
+
+            pretty = g_markup_escape_text (info, -1);
+
+            for (uint i = 0; i < G_N_ELEMENTS (rs); i++) {
+                GError* error;
+                GRegex* re;
+                char* result;
+
+                error = NULL;
+
+                re = g_regex_new (rs[i].regex, cflags, mflags, &error);
+                if (re == NULL) {
+                    g_warning ("Error building regex: %s", error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                result = g_regex_replace_literal (re, pretty, -1, 0,
+                                             rs[i].replacement, mflags, &error);
+
+                g_regex_unref (re);
+
+                if (error != NULL) {
+                    g_warning ("Error replacing %s: %s", rs[i].regex, error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                g_free (pretty);
+                pretty = result;
+            }
+
+            return pretty;
+        }
+
+        static char* get_renderer_from_helper (gboolean discrete_gpu)
+        {
+            int status;
+            const char *argv[] = { LIBEXECDIR "/mate-session-check-accelerated", NULL };
+            g_auto(GStrv) envp = NULL;
+            g_autofree char *renderer = NULL;
+            g_autoptr(GError) error = NULL;
+
+            if (discrete_gpu)
+            {
+                envp = g_get_environ ();
+                envp = g_environ_setenv (envp, "DRI_PRIME", "1", TRUE);
+            }
+
+            if (!g_spawn_sync (NULL, (char **) argv, envp, G_SPAWN_DEFAULT, NULL, NULL, &renderer, NULL, &status, &error))
+            {
+                g_debug ("Failed to get %s GPU: %s",
+                         discrete_gpu ? "discrete" : "integrated",
+                         error->message);
+                return NULL;
+            }
+
+            if (!g_spawn_check_exit_status (status, NULL))
+                return NULL;
+
+            if (renderer == NULL || *renderer == '\0')
+                return NULL;
+
+            return prettify_info (renderer);
+        }
+
+
+        void load_graphics_info()
+        {
+            g_autofree char *renderer = NULL;
+
+            try
+            {
+                g_autoptr(GDBusProxy) session_proxy = NULL;
+                g_autoptr(GVariant) renderer_variant = NULL;
+                g_autoptr(GError) error = NULL;
+
+                session_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                               G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL,
+                                                               "org.gnome.SessionManager",
+                                                               "/org/gnome/SessionManager",
+                                                               "org.gnome.SessionManager",
+                                                               NULL, &error);
+                if (error != NULL)
+                {
+                    throw std::runtime_error ("Unable to connect to create a proxy for org.gnome.SessionManager");
+                }
+
+                renderer_variant = g_dbus_proxy_get_cached_property (session_proxy, "Renderer");
+                if (!renderer_variant)
+                {
+                    throw std::runtime_error ("Unable to retrieve org.gnome.SessionManager.Renderer property.");
+                }
+
+                renderer = prettify_info (g_variant_get_string (renderer_variant, NULL));
+            }
+            catch (std::exception& e)
+            {
+                g_warning ("%s", e.what());
+            }
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (FALSE);
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (TRUE);
+
+            if (renderer)
+            {
+                this->graphics = g_strdup (renderer);
+            }
+            else
+            {
+                this->graphics = _("Unknown");
+            }
+        }
+
+        void load_processors_info()
+        {
+            const glibtop_sysinfo *info = glibtop_get_sysinfo();
+
+            GHashTable* counts;
+            GString* cpu;
+            GHashTableIter iter;
+            gpointer key, value;
+
+            counts = g_hash_table_new (g_str_hash, g_str_equal);
+
+            /* count duplicates */
+            for (uint i = 0; i != info->ncpu; ++i) {
+                const char* const keys[] = { "model name", "cpu", "Processor" };
+                char* model;
+                int* count;
+
+                model = NULL;
+
+                for (int j = 0; model == NULL && j != G_N_ELEMENTS (keys); ++j) {
+                    model = static_cast<char*>(g_hash_table_lookup (info->cpuinfo[i].values,
+                                                 keys[j]));
+                }
+
+                if (model == NULL)
+                    continue;
+
+                count = static_cast<int*>(g_hash_table_lookup (counts, model));
+                if (count == NULL)
+                    g_hash_table_insert (counts, model, GINT_TO_POINTER (1));
+                else
+                    g_hash_table_replace (counts, model, GINT_TO_POINTER (GPOINTER_TO_INT (count) + 1));
+            }
+
+            cpu = g_string_new (NULL);
+            g_hash_table_iter_init (&iter, counts);
+            while (g_hash_table_iter_next (&iter, &key, &value)) {
+                char* stripped;
+                int   count;
+
+                count = GPOINTER_TO_INT (value);
+                stripped = remove_duplicate_whitespace ((const char *)key);
+                if (count > 1)
+                    g_string_append_printf (cpu, "%s \303\227 %d ", stripped, count);
+                else
+                    g_string_append_printf (cpu, "%s ", stripped);
+                g_free (stripped);
+            }
+
+            g_hash_table_destroy (counts);
+            this->processors = string(prettify_info (cpu->str));
+            g_string_free (cpu, TRUE);
+        }
+
+        void load_disk_info()
+        {
+            GHashTable *devices;
+            glibtop_mountentry *entries;
+            glibtop_mountlist mountlist;
+
+            entries = glibtop_get_mountlist(&mountlist, 0);
+            devices = g_hash_table_new(g_str_hash, g_str_equal);
+            this->free_space_bytes = 0;
+
+            for (guint i = 0; i != mountlist.number; ++i) {
+                if ((string(entries[i].mountdir).compare("/") == 0) && \
+                    (string(entries[i].type).compare("zfs") == 0)) {
+                    // Root filesystem is ZFS based: Calculate usage based on "/".
+                    glibtop_fsusage usage;
+                    glibtop_get_fsusage(&usage, "/");
+                    this->free_space_bytes = usage.bavail * usage.block_size;
+                    break;
+                }
+
+                if (string(entries[i].devname).find("/dev/") != 0)
+                    continue;
+
+                if (string(entries[i].mountdir).find("/media/") == 0)
+                    continue;
+
+                /* avoid adding a device more than once such as for btrfs filesystem */
+                if (g_hash_table_contains (devices, entries[i].devname))
+                    continue;
+                else
+                    g_hash_table_insert (devices, entries[i].devname, entries[i].mountdir);
+
+                glibtop_fsusage usage;
+                glibtop_get_fsusage(&usage, entries[i].mountdir);
+                this->free_space_bytes += usage.bavail * usage.block_size;
+            }
+
+            g_hash_table_destroy (devices);
+            g_free(entries);
+        }
+
+        static const struct utsname & uname()
+        {
+            static struct utsname name;
+
+            if (!name.sysname[0]) {
+                ::uname(&name);
+            }
+
+            return name;
+        }
+
+        void load_uname_info()
+        {
+            this->hostname = uname().nodename;
+#if defined(__linux__)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().machine;
+#elif defined(__sun) && defined(__SVR4)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().version + ' ' + uname().machine;
+#else
+            this->kernel = string(uname().version) + ' ' + uname().machine;
+#endif
+        }
+
+
+        void load_mate_version()
+        {
+            xmlDocPtr document;
+            xmlXPathContextPtr context;
+            const string nodes[3] = { "string(/mate-version/platform)",
+                                      "string(/mate-version/minor)",
+                                      "string(/mate-version/micro)" };
+            string values[3];
+
+            if (not (document = xmlParseFile(DATADIR "/mate-about/mate-version.xml")))
+                return;
+
+            if (not (context = xmlXPathNewContext(document)))
+                return;
+
+            for (size_t i = 0; i != 3; ++i)
+            {
+                xmlXPathObjectPtr xpath;
+                xpath = xmlXPathEvalExpression(BAD_CAST nodes[i].c_str(), context);
+
+                if (xpath and xpath->type == XPATH_STRING)
+                    values[i] = reinterpret_cast<const char*>(xpath->stringval);
+
+                xmlXPathFreeObject(xpath);
+            }
+
+            xmlXPathFreeContext(context);
+            xmlFreeDoc(document);
+
+            if (!values[0].empty() && !values[1].empty() && !values[2].empty())
+                this->mate_version = values[0] + '.' + values[1] + '.' + values[2];
+        }
+    };
+
+    class FreeBSDSysInfo
+        : public SysInfo
+    {
+    public:
+	FreeBSDSysInfo()
+        {
+            this->load_freebsd_info();
+        }
+
+    private:
+        void load_freebsd_info()
+        {
+            this->distro_name = "FreeBSD";
+            this->distro_release = release();
+        }
+    };
+
+    class SolarisSysInfo
+        : public SysInfo
+    {
+    public:
+        SolarisSysInfo()
+        {
+            this->load_solaris_info();
+        }
+
+    private:
+        void load_solaris_info()
+        {
+            std::ifstream input("/etc/release");
+
+            if (input) {
+                std::string s;
+                std::getline(input, s);
+                std::size_t found = s.find("OpenIndiana ");
+                if (found!=std::string::npos) {
+                    this->distro_name = "OpenIndiana";
+                    this->distro_release = s.substr(found + strlen("OpenIndiana "));
+                } else if (!s.empty()) {
+                    this->distro_release = s;
+                }
+            }
+
+            if (this->distro_release.empty()) {
+                this->distro_name = "Solaris";
+            }
+        }
+    };
+
+
+    class LSBSysInfo
+        : public SysInfo
+    {
+    public:
+        LSBSysInfo()<--- Member variable 'LSBSysInfo::lsb_fd' is not initialized in the constructor.<--- Member variable 'LSBSysInfo::name' is not initialized in the constructor.<--- Member variable 'LSBSysInfo::release' is not initialized in the constructor.
+            : re(Glib::Regex::create("^.+?:\\s*(.+)\\s*$"))
+        {
+            // start();
+        }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Function in derived class
+        {
+            this->name = name;
+            this->release = release;
+
+            this->start();
+        }
+
+
+    private:
+
+        sigc::connection child_watch;
+        int lsb_fd;
+        GtkWidget* name;
+        GtkWidget* release;<--- Shadowed declaration<--- Shadowed declaration
+
+        void strip_description(string &s) const
+        {
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+            GMatchInfo* info = 0;
+
+           if (g_regex_match(this->re->gobj(), s.c_str(), flags, &info)) {
+               s = make_string(g_match_info_fetch(info, 1));
+               g_match_info_free(info);
+           }
+        }
+
+        std::istream& get_value(std::istream &is, string &s) const
+        {
+            if (std::getline(is, s))
+                this->strip_description(s);
+            return is;
+        }
+
+
+        void read_lsb(Glib::Pid pid, int status)
+        {
+            this->child_watch.disconnect();
+
+            if (!WIFEXITED(status) or WEXITSTATUS(status) != 0) {
+                g_error("Child %d failed with status %d", int(pid), status);
+                return;
+            }
+
+            Glib::RefPtr<Glib::IOChannel> channel = Glib::IOChannel::create_from_fd(this->lsb_fd);
+            Glib::ustring content;
+
+            while (channel->read_to_end(content) == Glib::IO_STATUS_AGAIN)
+                ;
+
+            channel->close();
+            Glib::spawn_close_pid(pid);
+
+            procman_debug("lsb_release output = '%s'", content.c_str());
+
+            string release, codename;<--- Shadow variable
+            std::istringstream input(content);
+
+            this->get_value(input, this->distro_name)
+                and this->get_value(input, release)
+                and this->get_value(input, codename);
+
+            this->distro_release = release;
+            if (codename != "" && codename != "n/a")
+                this->distro_release += " (" + codename + ')';
+
+            this->SysInfo::set_distro_labels(this->name, this->release);
+        }
+
+
+        void start()
+        {
+            std::vector<string> argv(2);
+            argv[0] = "lsb_release";
+            argv[1] = "-irc";
+
+            Glib::SpawnFlags flags = Glib::SPAWN_DO_NOT_REAP_CHILD
+                | Glib::SPAWN_SEARCH_PATH
+                | Glib::SPAWN_STDERR_TO_DEV_NULL;
+
+            Glib::Pid child;
+
+            try {
+                Glib::spawn_async_with_pipes("/", // wd
+                                             argv,
+                                             flags,
+                                             sigc::slot<void>(), // child setup
+                                             &child,
+                                             0, // stdin
+                                             &this->lsb_fd); // stdout
+            } catch (Glib::SpawnError &e) {
+                g_error("g_spawn_async_with_pipes error: %s", e.what().c_str());
+                return;
+            }
+
+            sigc::slot<void,GPid, int> slot = sigc::mem_fun(this, &LSBSysInfo::read_lsb);
+            this->child_watch = Glib::signal_child_watch().connect(slot, child);
+        }
+
+
+        void sync_lsb_release()<--- Unused private function: 'LSBSysInfo::sync_lsb_release'
+        {
+            char *out= 0;
+            GError *error = 0;
+            int status;
+
+            if (g_spawn_command_line_sync("lsb_release -irc",
+                                          &out,
+                                          0,
+                                          &status,
+                                          &error)) {
+                string release, codename;<--- Shadow variable
+                if (!error and WIFEXITED(status) and WEXITSTATUS(status) == 0) {
+                    std::istringstream input(out);
+                    this->get_value(input, this->distro_name)
+                        and this->get_value(input, release)
+                        and this->get_value(input, codename);
+                    this->distro_release = release;
+                if (codename != "" && codename != "n/a")
+                    this->distro_release += " (" + codename + ')';
+                }
+            }
+
+            if (error)
+                g_error_free(error);
+
+            g_free(out);
+        }
+
+    private:
+        Glib::RefPtr<Glib::Regex> re;
+    };
+
+
+    class NetBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        NetBSDSysInfo()
+        {
+            this->load_netbsd_info();
+        }
+
+    private:
+        void load_netbsd_info()
+        {
+            this->distro_name = "NetBSD";
+
+            std::ifstream input("/etc/release");
+
+            if (input)
+                std::getline(input, this->distro_release);
+        }
+    };
+
+
+    class GenericSysInfo
+        : public SysInfo
+    {
+    public:
+        GenericSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            std::ifstream input("/etc/os-release");
+
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int start;
+                    std::getline(input, s);
+                    if (s.find("NAME=") == 0) {
+                        start = strlen("NAME=");
+                        if ((s.at(start) == '\"') && (s.at(s.size() - 1) == '\"')) {
+                            this->distro_name = s.substr(start + 1, s.size() - start - 2);
+                        } else {
+                            this->distro_name = s.substr(start);
+                        }
+                    } else if (s.find("VERSION=") == 0) {
+                        start = strlen("VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    } else if (s.find("# VERSION=") == 0) {
+                        start = strlen("# VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    }
+                }
+                input.close();
+                input.clear();
+            }
+            if (this->distro_release.empty()) {
+                input.open("/etc/debian_version");
+                if (input) {
+                    getline(input, this->distro_release);
+                }
+            }
+        }
+    };
+
+    class MintSysInfo
+        : public SysInfo
+    {
+    public:
+        MintSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            this->distro_name = "Linux Mint";
+            std::ifstream input("/etc/linuxmint/info");
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int len;
+                    std::getline(input, s);
+                    if (s.find("DESCRIPTION=") == 0) {
+                        len = strlen("DESCRIPTION=");
+                        // also strip the surrounding quotes
+                       this->distro_release = s.substr(len + 1, s.size() - len - 2);
+                   }
+                }
+            }
+        }
+    };
+
+    class OpenBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        OpenBSDSysInfo()
+        {
+            this->load_openbsd_info();
+        }
+
+    private:
+        void load_openbsd_info()
+        {
+            this->distro_name = "OpenBSD";
+            this->distro_release = this->kernel;
+
+            std::ifstream input("/etc/motd");
+
+            if (input)
+                std::getline(input, this->kernel);
+        }
+    };
+
+    SysInfo* get_sysinfo()
+    {
+        if (g_file_test ("/etc/linuxmint/info", G_FILE_TEST_EXISTS)) {
+            return new MintSysInfo;
+        }
+        else if (g_file_test ("/etc/os-release", G_FILE_TEST_EXISTS)) {
+            return new GenericSysInfo;
+        }
+        else if (char *p = g_find_program_in_path("lsb_release")) {
+            g_free(p);
+            return new LSBSysInfo;
+        }
+        else if (SysInfo::system() == "FreeBSD") {
+            return new FreeBSDSysInfo;
+        }
+        else if (SysInfo::system() == "SunOS") {
+            return new SolarisSysInfo;
+        }
+        else if (SysInfo::system() == "NetBSD") {
+            return new NetBSDSysInfo;
+        }
+        else if (SysInfo::system() == "OpenBSD") {
+            return new OpenBSDSysInfo;
+        }
+
+        return new SysInfo;
+    }
+}
+
+
+#define X_PAD  0
+#define Y_PAD  0
+#define LOGO_W 92
+#define LOGO_H 351
+#define RADIUS 5
+
+static gboolean sysinfo_logo_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    GtkStyle *style;
+    cairo_t *cr;
+    cairo_pattern_t *cp;
+
+    cr = gdk_cairo_create(gtk_widget_get_window(widget));
+
+    gtk_widget_get_allocation (widget, &allocation);
+    cairo_translate(cr, allocation.x, allocation.y);
+
+    cairo_move_to(cr, X_PAD + RADIUS, Y_PAD);
+    cairo_line_to(cr, X_PAD + LOGO_W - RADIUS, Y_PAD);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + RADIUS, RADIUS, -0.5 * M_PI, 0);
+    cairo_line_to(cr, X_PAD + LOGO_W, Y_PAD + LOGO_H - RADIUS);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0, 0.5 * M_PI);
+    cairo_line_to(cr, X_PAD + RADIUS, Y_PAD + LOGO_H);
+    cairo_arc(cr, X_PAD + RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0.5 * M_PI, -1.0 * M_PI);
+    cairo_line_to(cr, X_PAD, Y_PAD + RADIUS);
+    cairo_arc(cr,  X_PAD + RADIUS, Y_PAD + RADIUS, RADIUS, -1.0 * M_PI, -0.5 * M_PI);
+
+    cp = cairo_pattern_create_linear(0, Y_PAD, 0, Y_PAD + LOGO_H);
+    style = gtk_widget_get_style (widget);
+    cairo_pattern_add_color_stop_rgba(cp, 0.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      1.0);
+    cairo_pattern_add_color_stop_rgba(cp, 1.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      0.0);
+    cairo_set_source(cr, cp);
+    cairo_fill(cr);
+
+    cairo_pattern_destroy(cp);
+    cairo_destroy(cr);
+
+    return FALSE;
+}
+
+static GtkWidget*
+add_section(GtkBox *vbox , const char * title, int num_row, int num_col, GtkWidget **out_frame)
+{
+    GtkWidget *table;
+
+    GtkWidget *frame = gtk_frame_new(title);
+    gtk_frame_set_label_align(GTK_FRAME(frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
+
+    table = gtk_grid_new();
+    gtk_grid_set_row_spacing(GTK_GRID(table), 6);
+    gtk_grid_set_column_spacing(GTK_GRID(table), 6);
+    gtk_widget_set_margin_start (GTK_WIDGET(table), 12);
+    gtk_container_set_border_width(GTK_CONTAINER(table), 6);
+    gtk_container_add(GTK_CONTAINER(frame), table);
+
+    if(out_frame)
+        *out_frame = frame;
+
+    return table;
+}
+
+
+static GtkWidget*
+add_row(GtkGrid * table, const char * label, const char * value, int row)
+{
+    GtkWidget *header = gtk_label_new(NULL);
+    gtk_label_set_markup(GTK_LABEL(header), label);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        table, header,
+        0, row, 1, 1);
+
+    GtkWidget *label_widget = gtk_label_new(value);
+    gtk_label_set_selectable(GTK_LABEL(label_widget), TRUE);
+    gtk_widget_set_can_focus(label_widget, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (label_widget), 0.0);
+    gtk_grid_attach(
+        table, label_widget,
+        1, row, 1, 1);
+
+    return label_widget;
+}
+
+
+static GtkWidget *
+procman_create_sysinfo_view(void)
+{
+    GtkWidget *hbox;
+    GtkWidget *vbox;
+
+    SysInfo *data = get_sysinfo();;
+
+    GtkWidget * logo;
+
+    GtkWidget *distro_frame;
+    GtkWidget *distro_release_label;
+    GtkWidget *distro_table;
+
+    GtkWidget *hardware_table;
+    GtkWidget *disk_space_table;
+
+    GtkWidget *header;
+
+    gchar *markup;
+
+    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);
+
+    /* left-side logo */
+    if (g_file_test (DATADIR "/pixmaps/mate-system-monitor/distribution/side.png", G_FILE_TEST_EXISTS)) {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/distribution/side.png");
+    }
+    else {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/side.png");
+    }
+    gtk_widget_set_valign (logo, GTK_ALIGN_START);
+    gtk_widget_set_margin_start (logo, 5);
+    gtk_widget_set_margin_end (logo, 5);
+    gtk_widget_set_margin_top (logo, 12);
+    gtk_widget_set_margin_bottom (logo, 12);
+    gtk_box_pack_start(GTK_BOX(hbox), logo, FALSE, FALSE, 0);
+
+    g_signal_connect(G_OBJECT(logo), "draw", G_CALLBACK(sysinfo_logo_draw), NULL);
+
+    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
+    gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
+
+    // hostname
+
+    markup = g_strdup_printf("<big><big><b><u>%s</u></b></big></big>",
+                             data->hostname.c_str());
+    GtkWidget *hostname_frame = gtk_frame_new(markup);
+    g_free(markup);
+    gtk_frame_set_label_align(GTK_FRAME(hostname_frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(hostname_frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(hostname_frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), hostname_frame, FALSE, FALSE, 0);
+
+
+    /* distro section */
+
+    unsigned table_size = 2;
+    if (data->mate_version != "")
+        table_size++;
+    distro_table = add_section(GTK_BOX(vbox), "???", table_size, 1, &distro_frame);
+
+    unsigned table_count = 0;
+
+    distro_release_label = gtk_label_new("???");
+    gtk_label_set_selectable(GTK_LABEL(distro_release_label), TRUE);
+    gtk_widget_set_can_focus(distro_release_label, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (distro_release_label), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), distro_release_label,
+        0, table_count, 1, 1);
+    table_count++;
+    data->set_distro_labels(gtk_frame_get_label_widget(GTK_FRAME(distro_frame)), distro_release_label);
+
+    markup = g_strdup_printf(_("Kernel %s"), data->kernel.c_str());
+    header = gtk_label_new(markup);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    g_free(markup);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), header,
+        0, table_count, 1, 1);
+    table_count++;
+
+    if (data->mate_version != "")
+    {
+        markup = g_strdup_printf(_("MATE %s"), data->mate_version.c_str());
+        header = gtk_label_new(markup);
+        gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+        gtk_widget_set_can_focus(header, FALSE);
+        g_free(markup);
+        gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+        gtk_grid_attach(
+            GTK_GRID(distro_table), header,
+            0, table_count, 1, 1);
+        table_count++;<--- Variable 'table_count' is assigned a value that is never used.
+    }
+
+    /* hardware section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("Hardware"));
+    hardware_table = add_section(GTK_BOX(vbox), markup, 1, 3, NULL);
+    g_free(markup);
+
+    markup = g_format_size_full(data->memory_bytes, G_FORMAT_SIZE_IEC_UNITS);
+    add_row(GTK_GRID(hardware_table), _("Memory:"), markup, 0);
+    g_free(markup);
+
+    add_row(GTK_GRID(hardware_table), _("Processor:"),
+            data->processors.c_str(), 1);
+    add_row(GTK_GRID(hardware_table), _("Graphics:"),
+            data->graphics.c_str(), 2);
+
+    /* disk space section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("System Status"));
+    disk_space_table = add_section(GTK_BOX(vbox), markup, 1, 2, NULL);
+    g_free(markup);
+
+    markup = g_format_size(data->free_space_bytes);
+    add_row(GTK_GRID(disk_space_table), _("Available disk space:"), markup, 0);
+    g_free(markup);
+
+    return hbox;
+}
+
+
+
+namespace procman
+{
+    void build_sysinfo_ui()
+    {
+        static GtkWidget* ui;
+
+        if (!ui) {
+            ProcData* procdata = ProcData::get_instance();
+            ui = procman_create_sysinfo_view();
+            GtkBox* box = GTK_BOX(gtk_notebook_get_nth_page(GTK_NOTEBOOK(procdata->notebook),
+                                                            PROCMAN_TAB_SYSINFO));
+            gtk_box_pack_start(box, ui, TRUE, TRUE, 0);
+            gtk_widget_show_all(ui);
+        }
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/2.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/2.html new file mode 100644 index 00000000..0154b48f --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/2.html @@ -0,0 +1,489 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
#ifndef _PROCMAN_LOAD_GRAPH_H_
+#define _PROCMAN_LOAD_GRAPH_H_
+
+#include <glib.h>
+#include <glibtop/cpu.h>
+
+enum
+{
+    LOAD_GRAPH_CPU,
+    LOAD_GRAPH_MEM,
+    LOAD_GRAPH_NET
+};
+
+enum {
+    CPU_TOTAL,
+    CPU_USED,
+    N_CPU_STATES
+};
+
+struct LoadGraphLabels
+{
+    GtkWidget *cpu[GLIBTOP_NCPU];
+    GtkWidget *memory;
+    GtkWidget *swap;
+    GtkWidget *net_in;
+    GtkWidget *net_in_total;
+    GtkWidget *net_out;
+    GtkWidget *net_out_total;
+};
+
+struct LoadGraph {
+
+    static const unsigned NUM_POINTS = 60 + 2;
+    static const unsigned GRAPH_MIN_HEIGHT = 40;
+
+    LoadGraph(guint type);
+    ~LoadGraph();
+
+    unsigned num_bars() const;
+    void clear_background();
+
+    double fontsize;
+    double rmargin;
+    double indent;
+
+    guint n;
+    gint type;
+    guint speed;
+    guint draw_width, draw_height;
+    guint render_counter;
+    guint frames_per_unit;
+    guint graph_dely;
+    guint real_draw_height;
+    double graph_delx;
+    guint graph_buffer_offset;
+
+    std::vector<GdkRGBA> colors;
+
+    std::vector<float> data_block;
+    gfloat* data[NUM_POINTS];
+
+    GtkWidget *main_widget;
+    GtkWidget *disp;
+
+    cairo_pattern_t *background;
+
+    guint timer_index;
+
+    gboolean draw;
+
+    LoadGraphLabels labels;
+    GtkWidget *mem_color_picker;
+    GtkWidget *swap_color_picker;
+
+    /* union { */
+        struct {
+            guint now; /* 0 -> current, 1 -> last
+                    now ^ 1 each time */
+            /* times[now], times[now ^ 1] is last */
+            guint64 times[2][GLIBTOP_NCPU][N_CPU_STATES];
+        } cpu;
+
+        struct {
+            guint64 last_in, last_out;
+#if GLIB_CHECK_VERSION(2,61,2)
+            gint64 time;
+#else
+            GTimeVal time;
+#endif
+            guint64 max;
+            unsigned values[NUM_POINTS];
+            size_t cur;
+        } net;
+    /* }; */
+};
+
+/* Force a drawing update */
+void
+load_graph_queue_draw (LoadGraph *g);
+
+/* Start load graph. */
+void
+load_graph_start (LoadGraph *g);
+
+/* Stop load graph. */
+void
+load_graph_stop (LoadGraph *g);
+
+/* Change load graph speed and restart it if it has been previously started */
+void
+load_graph_change_speed (LoadGraph *g,
+                         guint new_speed);
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+#endif /* _PROCMAN_LOAD_GRAPH_H_ */
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/3.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/3.html new file mode 100644 index 00000000..e0d59e5d --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/3.html @@ -0,0 +1,645 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
#include <config.h>
+
+#include <cstring>
+#include <glib/gi18n.h>
+
+#include "cgroups.h"
+#include "util.h"
+
+gboolean
+cgroups_enabled(void)
+{
+    static gboolean initialized = FALSE;
+    static gboolean has_cgroups;
+
+    if (!initialized) {
+        initialized = TRUE;
+        has_cgroups = g_file_test("/proc/cgroups", G_FILE_TEST_EXISTS);
+    }
+
+    return has_cgroups;
+}
+
+static void
+append_cgroup_name(char *line, gchar **current_cgroup_name)
+{
+    gchar *controller, *path, *tmp, *path_plus_space;
+    int paren_offset, off, tmp_size;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return;
+
+    *(path - 1) = '\0';
+    g_strdelimit(controller, ",", '/');
+
+    if ((std::strcmp(path, "/") == 0) || (std::strncmp(controller, "name=", 5) == 0))
+        return;
+
+    if (*current_cgroup_name == NULL) {
+        *current_cgroup_name = g_strdup_printf("%s (%s)", path, controller);
+        return;
+    }
+
+    /* add a space to the end of the path string */
+    path_plus_space = g_strdup_printf("%s ", path);
+
+    if ((tmp = g_strstr_len(*current_cgroup_name, -1, path_plus_space))) {
+        tmp_size = strlen(*current_cgroup_name) + strlen(controller) + 1;
+        paren_offset = g_strstr_len(tmp + strlen(path), -1, ")") - *current_cgroup_name;
+        *(*current_cgroup_name + paren_offset) = '\0';
+        tmp = (gchar *)g_strnfill(tmp_size, '\0');
+        off = g_strlcat(tmp, *current_cgroup_name, tmp_size);
+        *(tmp + off) = '/';
+        off++;
+        off += g_strlcat(tmp + off, controller, tmp_size);
+        *(tmp + off) = ')';
+        off++;
+        g_strlcat(tmp + off, *current_cgroup_name + paren_offset + 1, tmp_size);
+    } else
+        tmp = g_strdup_printf("%s, %s(%s)", *current_cgroup_name, path_plus_space, controller);
+
+    g_free(path_plus_space);
+    g_free(*current_cgroup_name);
+    *current_cgroup_name = tmp;
+}
+
+static int
+check_cgroup_changed(gchar *line, gchar *current_cgroup_set)
+{
+    /* check if line is contained in current_cgroup_set */
+    gchar *controller, *path, *tmp, *found, *close_paren, *open_paren;
+    int ret = 0;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return 1;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return 1;
+
+    *(path - 1) = '\0';
+
+    if (std::strncmp(controller, "name=", 5) == 0)
+        goto out;
+
+    /* if there are multiple controllers just report string has changed */
+    if (g_strstr_len(controller, -1, ",")) {
+        ret = 1;
+        goto out;
+    }
+
+    if (!current_cgroup_set) {
+        if (std::strcmp(path, "/") != 0)
+            ret = 1;
+        goto out;
+    }
+
+    /* special case for root cgroup */
+    tmp = current_cgroup_set;
+    if (std::strcmp(path, "/") == 0) {
+        while ((found = g_strstr_len(tmp, -1, controller))) {
+            close_paren = g_strstr_len(found, -1, ")");
+            open_paren = g_strstr_len(found, -1, "(");
+            if (close_paren) {
+                if (!open_paren || (close_paren < open_paren)) {
+                    ret = 1;
+                    goto out;
+                }
+            }
+            tmp = found + strlen(controller);
+        }
+        goto out;
+    }
+
+    tmp = current_cgroup_set;
+    while ((found = g_strstr_len(tmp, -1, path))) {
+            found = found + strlen(path);
+            close_paren = g_strstr_len(found, -1, ")");
+            if (*found == ' ') {
+                if (g_strstr_len(found + 1, close_paren - found, controller))
+                    goto out;
+            }
+            tmp = close_paren + 1;
+    }
+    ret = 1;
+out:
+    *(path - 1) = ':';
+    return ret;
+}
+
+void
+get_process_cgroup_info(ProcInfo *info)
+{
+    gchar *path;
+    gchar *cgroup_name = NULL;
+    int cgroups_changed = 0;
+    gchar *text;
+    char **lines;
+    int i;
+
+    if (!cgroups_enabled())
+        return;
+
+    /* read out of /proc/pid/cgroup */
+    path = g_strdup_printf("/proc/%d/cgroup", info->pid);
+    if (!path)
+        return;
+    if(!g_file_get_contents(path, &text, NULL, NULL))
+        goto out;
+    lines = g_strsplit(text, "\n", -1);
+    g_free(text);
+    if (!lines)
+        goto out;
+
+    for (i = 0; lines[i] != NULL; i++) {
+        if (lines[i][0] == '\0')
+            continue;
+        if (check_cgroup_changed(lines[i], info->cgroup_name)) {
+            cgroups_changed = 1;
+            break;
+        }
+    }
+
+    if (cgroups_changed) {
+        for (i = 0; lines[i] != NULL; i++) {
+            if (lines[i][0] == '\0')
+                continue;
+            append_cgroup_name(lines[i], &cgroup_name);
+        }
+        if (info->cgroup_name)
+            g_free(info->cgroup_name);
+        if (!cgroup_name)
+            info->cgroup_name = g_strdup("");
+        else
+            info->cgroup_name = cgroup_name;
+    }
+
+    g_strfreev(lines);
+out:
+    g_free(path);
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/4.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/4.html new file mode 100644 index 00000000..cc9dbf88 --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/4.html @@ -0,0 +1,1277 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
#include <config.h>
+
+#ifdef __linux__
+#include <mntent.h>
+#endif // __linux__
+
+#include <giomm.h>
+#include <giomm/themedicon.h>
+#include <gtk/gtk.h>
+#include <glibtop/mountlist.h>
+#include <glibtop/fsusage.h>
+#include <glib/gi18n.h>
+
+#include "procman.h"
+#include "disks.h"
+#include "util.h"
+#include "interface.h"
+#include "iconthemewrapper.h"
+
+namespace
+{
+  const unsigned DISK_ICON_SIZE = 24;
+}
+
+enum DiskColumns
+{
+    /* string columns* */
+    DISK_DEVICE,
+    DISK_DIR,
+    DISK_TYPE,
+    DISK_SUBVOLUME,
+    DISK_TOTAL,
+    DISK_FREE,
+    DISK_AVAIL,
+    /* USED has to be the last column */
+    DISK_USED,
+    // then unvisible columns
+    /* Surface column */
+    DISK_ICON,
+    /* numeric columns */
+    DISK_USED_PERCENTAGE,
+    DISK_N_COLUMNS
+};
+
+
+
+static void
+fsusage_stats(const glibtop_fsusage *buf,
+              guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
+              gint *percentage)
+{
+    guint64 total = buf->blocks * buf->block_size;
+
+    if (!total) {
+        /* not a real device */
+        *btotal = *bfree = *bavail = *bused = 0ULL;
+        *percentage = 0;
+    } else {
+        int percent;
+        *btotal = total;
+        *bfree = buf->bfree * buf->block_size;
+        *bavail = buf->bavail * buf->block_size;
+        *bused = *btotal - *bfree;
+        /* percent = 100.0f * *bused / *btotal; */
+        percent = 100 * *bused / (*bused + *bavail);
+        *percentage = CLAMP(percent, 0, 100);
+    }
+}
+
+
+namespace
+{
+    string get_icon_for_path(const std::string& path)
+    {
+        using namespace Glib;
+        using namespace Gio;
+
+        // FIXME: I don't know whether i should use Volume or Mount or UnixMount
+        // all i need an icon name.
+        RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+        std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
+
+        for (size_t i = 0; i != mounts.size(); ++i) {
+            if (mounts[i]->get_name() != path)
+                continue;
+
+            RefPtr<Icon> icon = mounts[i]->get_icon();
+            RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
+
+            if (themed_icon) {
+                char* name = 0;
+                // FIXME: not wrapped yet
+                g_object_get(G_OBJECT(themed_icon->gobj()), "name", &name, NULL);
+                return make_string(name);
+            }
+        }
+
+        return "";
+    }
+}
+
+
+static Glib::RefPtr<Gdk::Pixbuf>
+get_icon_for_device(const char *mountpoint)
+{
+    procman::IconThemeWrapper icon_theme;
+    string icon_name = get_icon_for_path(mountpoint);
+    if (icon_name == "")
+        // FIXME: defaults to a safe value
+        icon_name = "drive-harddisk"; // get_icon_for_path("/");
+    return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
+}
+
+
+static gboolean
+find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
+                   GtkTreeIter *result)
+{
+    GtkTreeIter iter;
+    gboolean found = FALSE;
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        do {
+            char *dir;
+
+            gtk_tree_model_get(model, &iter,
+                               DISK_DIR, &dir,
+                               -1);
+
+            if (dir && !strcmp(dir, mountpoint)) {
+                *result = iter;
+                found = TRUE;
+            }
+
+            g_free(dir);
+
+        } while (!found && gtk_tree_model_iter_next(model, &iter));
+    }
+
+    return found;
+}
+
+
+
+static void
+remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
+{
+    GtkTreeIter iter;
+
+    if (!gtk_tree_model_get_iter_first(model, &iter))
+        return;
+
+    while (true) {
+        char *dir;
+        guint i;
+        gboolean found = FALSE;
+
+        gtk_tree_model_get(model, &iter,
+                           DISK_DIR, &dir,
+                           -1);
+
+        for (i = 0; i != n; ++i) {
+            if (!strcmp(dir, entries[i].mountdir)) {
+                found = TRUE;
+                break;
+            }
+        }
+
+        g_free(dir);
+
+        if (!found) {
+            if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                break;
+            else
+                continue;
+        }
+
+        if (!gtk_tree_model_iter_next(model, &iter))
+            break;
+    }
+}
+
+#ifdef __linux__
+static char *
+get_mount_opt(const glibtop_mountentry *entry, const char* opt)
+{
+    char *opt_value = NULL;
+    const struct mntent *mnt;
+    FILE *fp;
+
+    if (!(fp = setmntent(MOUNTED, "r"))) {
+        goto out;
+    }
+
+    while ((mnt = getmntent(fp))) {
+        if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
+            (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
+            char *res;
+
+            res = hasmntopt(mnt, "subvol");<--- res is assigned
+            if ((res = hasmntopt(mnt, "subvol")) != NULL) {<--- res is overwritten
+                char **strs = g_strsplit_set(res, "=", 2);
+
+                if (g_strv_length(strs) == 2) {
+                    char *value = strs[1];
+                    if (g_strcmp0 (value,"/root") == 0)
+                       opt_value = g_strdup("/");
+                    else
+                        opt_value = g_strdup(strs[1]);
+                    g_strfreev(strs);
+                }
+            }
+            break;
+        }
+    }
+
+    endmntent(fp);
+
+  out:
+     return opt_value;
+}
+#endif // __linux__
+
+
+static void
+add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
+{
+    Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+    cairo_surface_t *surface;
+    GtkTreeIter iter;
+    glibtop_fsusage usage;
+    guint64 bused, bfree, bavail, btotal;
+    gint percentage;
+#ifdef __linux__
+    char *subvol = NULL;
+#endif // __linux__
+
+    glibtop_get_fsusage(&usage, entry->mountdir);
+
+    if (not show_all_fs and usage.blocks == 0) {
+        if (find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+            gtk_list_store_remove(list, &iter);
+        return;
+    }
+
+    fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
+#ifdef __linux__
+    subvol = get_mount_opt(entry, "subvol");
+#endif // __linux__
+    pixbuf = get_icon_for_device(entry->mountdir);
+    surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL);
+
+    /* if we can find a row with the same mountpoint, we get it but we
+       still need to update all the fields.
+       This makes selection persistent.
+    */
+    if (!find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+        gtk_list_store_append(list, &iter);
+
+    gtk_list_store_set(list, &iter,
+                       DISK_ICON, surface,
+                       DISK_DEVICE, entry->devname,
+                       DISK_DIR, entry->mountdir,
+                       DISK_TYPE, entry->type,
+#ifdef __linux__
+
+                       DISK_SUBVOLUME, subvol != NULL ? subvol : "",
+#else
+                       DISK_SUBVOLUME, "",
+#endif // __linux__
+                       DISK_USED_PERCENTAGE, percentage,
+                       DISK_TOTAL, btotal,
+                       DISK_FREE, bfree,
+                       DISK_AVAIL, bavail,
+                       DISK_USED, bused,
+                       -1);
+#ifdef __linux__
+    g_free (subvol);
+#endif // __linux__
+}
+
+
+
+int
+cb_update_disks(gpointer data)
+{
+    ProcData *const procdata = static_cast<ProcData*>(data);
+
+    GtkListStore *list;
+    glibtop_mountentry * entries;
+    glibtop_mountlist mountlist;
+    guint i;
+
+    list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)));
+
+    entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
+
+    remove_old_disks(GTK_TREE_MODEL(list), entries, mountlist.number);
+
+    for (i = 0; i < mountlist.number; i++)
+        add_disk(list, &entries[i], procdata->config.show_all_fs);
+
+    g_free(entries);
+
+    return TRUE;
+}
+
+
+static void
+cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "disktreenew");
+}
+
+
+static void
+open_dir(GtkTreeView       *tree_view,
+         GtkTreePath       *path,
+         GtkTreeViewColumn *column,
+         gpointer           user_data)
+{
+    GtkTreeIter iter;
+    GtkTreeModel *model;
+    char *dir, *url;
+
+    model = gtk_tree_view_get_model(tree_view);
+
+    if (!gtk_tree_model_get_iter(model, &iter, path)) {
+        char *p;
+        p = gtk_tree_path_to_string(path);
+        g_warning("Cannot get iter for path '%s'\n", p);
+        g_free(p);
+        return;
+    }
+
+    gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
+
+    url = g_strdup_printf("file://%s", dir);
+
+    GError* error = 0;
+    if (!g_app_info_launch_default_for_uri(url, NULL, &error)) {
+        g_warning("Cannot open '%s' : %s\n", url, error->message);
+        g_error_free(error);
+    }
+
+    g_free(url);
+    g_free(dir);
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "disktreenew");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+void
+create_disk_view(ProcData *procdata, GtkBuilder *builder)
+{
+    GtkWidget *scrolled;
+    GtkWidget *disk_tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *col;
+    GtkCellRenderer *cell;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Device"),
+        N_("Directory"),
+        N_("Type"),
+        N_("SubVolume"),
+        N_("Total"),
+        N_("Free"),
+        N_("Available"),
+        N_("Used")
+    };
+
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"));
+
+    model = gtk_list_store_new(DISK_N_COLUMNS,             /* n columns */
+                               G_TYPE_STRING,              /* DISK_DEVICE */
+                               G_TYPE_STRING,              /* DISK_DIR */
+                               G_TYPE_STRING,              /* DISK_TYPE */
+                               G_TYPE_STRING,              /* DISK_SUBVOLUME */
+                               G_TYPE_UINT64,              /* DISK_TOTAL */
+                               G_TYPE_UINT64,              /* DISK_FREE */
+                               G_TYPE_UINT64,              /* DISK_AVAIL */
+                               G_TYPE_UINT64,              /* DISK_USED */
+                               CAIRO_GOBJECT_TYPE_SURFACE, /* DISK_ICON */
+                               G_TYPE_INT);                /* DISK_USED_PERCENTAGE */
+
+    disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL);
+    procdata->disk_list = disk_tree;
+    gtk_container_add(GTK_CONTAINER(scrolled), disk_tree);
+    g_object_unref(G_OBJECT(model));
+
+    /* icon + device */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
+                                        NULL);
+
+    cell = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
+                                        NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 30);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* sizes - used */
+
+    for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_min_width (col, 30);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+        switch (i) {
+            case DISK_TOTAL:
+            case DISK_FREE:
+            case DISK_AVAIL:
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+        default:
+            gtk_tree_view_column_set_attributes(col, cell,
+                                                "text", i,
+                                                NULL);
+            break;
+        }
+    }
+
+    /* used + percentage */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_text_new();
+    g_object_set(cell, "xalign", 1.0f, NULL);
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_cell_data_func(col, cell,
+                                            &procman::storage_size_cell_data_func,
+                                            GUINT_TO_POINTER(DISK_USED),
+                                            NULL);
+
+    cell = gtk_cell_renderer_progress_new();
+    gtk_tree_view_column_pack_start(col, cell, TRUE);
+    gtk_tree_view_column_set_attributes(col, cell, "value",
+                                        DISK_USED_PERCENTAGE, NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_USED]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 150);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* numeric sort */
+
+    procman_get_tree_state(procdata->settings, disk_tree,
+                   "disktreenew");
+
+    g_signal_connect (G_OBJECT(disk_tree), "columns-changed",
+                      G_CALLBACK(cb_disk_columns_changed), procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/5.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/5.html new file mode 100644 index 00000000..17de817b --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/5.html @@ -0,0 +1,2141 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
+852
+853
+854
+855
+856
+857
+858
+859
+860
+861
+862
+863
+864
+865
+866
+867
+868
+869
+870
+871
+872
+873
+874
+875
+876
+877
+878
+879
+880
+881
+882
+883
+884
+885
+886
+887
+888
+889
+890
+891
+892
+893
+894
+895
+896
+897
+898
+899
+900
+901
+902
+903
+904
+905
+906
+907
+908
+909
+910
+911
+912
+913
+914
+915
+916
+917
+918
+919
+920
+921
+922
+923
+924
+925
+926
+927
+928
+929
+930
+931
+932
+933
+934
+935
+936
+937
+938
+939
+940
+941
+942
+943
+944
+945
+946
/*
+ * Mate system monitor color pickers
+ * Copyright (C) 2007 Karl Lattimer <karl@qdh.org.uk>
+ * Copyright (C) 2012-2021 MATE Developers
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with the software; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <gdk/gdkkeysyms.h>
+#include <math.h>
+#include <cairo.h>
+#include <librsvg/rsvg.h>
+
+#include "gsm_color_button.h"
+
+typedef struct {
+    GtkWidget *cc_dialog;		/* Color chooser dialog */
+
+    gchar *title;            /* Title for the color selection window */
+
+    GdkRGBA color;
+
+    gdouble fraction;        /* Only used by GSMCP_TYPE_PIE */
+    guint type;
+    cairo_surface_t *image_buffer;
+    gdouble highlight;
+    gboolean button_down;
+    gboolean in_button;
+} GSMColorButtonPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GSMColorButton, gsm_color_button, GTK_TYPE_DRAWING_AREA)
+
+/* Properties */
+enum
+{
+    PROP_0,
+    PROP_PERCENTAGE,
+    PROP_TITLE,
+    PROP_COLOR,
+    PROP_TYPE
+};
+
+/* Signals */
+enum
+{
+    COLOR_SET,
+    LAST_SIGNAL
+};
+
+#define GSMCP_MIN_WIDTH 15
+#define GSMCP_MIN_HEIGHT 15
+
+static void gsm_color_button_finalize (GObject * object);
+static void gsm_color_button_set_property (GObject * object, guint param_id,
+                                           const GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_get_property (GObject * object, guint param_id,
+                                           GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_realize (GtkWidget * widget);
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width);
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height);
+static void gsm_color_button_size_allocate (GtkWidget * widget,
+                                            GtkAllocation * allocation);
+static void gsm_color_button_unrealize (GtkWidget * widget);
+static void gsm_color_button_state_changed (GtkWidget * widget,
+                                            GtkStateType previous_state);
+static void gsm_color_button_style_set (GtkWidget * widget,
+                                        GtkStyle * previous_style);
+static gint gsm_color_button_pressed (GtkWidget * widget,
+                                      GdkEventButton * event);
+static gint gsm_color_button_released (GtkWidget * widget,
+                                       GdkEventButton * event);
+static gboolean gsm_color_button_enter_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+static gboolean gsm_color_button_leave_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+/* source side drag signals */
+static void gsm_color_button_drag_begin (GtkWidget * widget,
+                                         GdkDragContext * context,
+                                         gpointer data);
+static void gsm_color_button_drag_data_get (GtkWidget * widget,
+                                            GdkDragContext * context,
+                                            GtkSelectionData * selection_data,
+                                            guint info, guint time,
+                                            GSMColorButton * color_button);
+
+/* target side drag signals */
+static void gsm_color_button_drag_data_received (GtkWidget * widget,
+                                                 GdkDragContext * context,
+                                                 gint x,
+                                                 gint y,
+                                                 GtkSelectionData *
+                                                 selection_data, guint info,
+                                                 guint32 time,
+                                                 GSMColorButton *
+                                                 color_button);
+
+static guint color_button_signals[LAST_SIGNAL] = { 0 };
+
+static const GtkTargetEntry drop_types[] = { {"application/x-color", 0, 0} };
+
+static void
+gsm_color_button_class_init (GSMColorButtonClass * klass)
+{
+    GObjectClass *gobject_class;
+    GtkWidgetClass *widget_class;
+
+    gobject_class = G_OBJECT_CLASS (klass);
+    widget_class = GTK_WIDGET_CLASS (klass);
+
+    gobject_class->get_property = gsm_color_button_get_property;
+    gobject_class->set_property = gsm_color_button_set_property;
+    gobject_class->finalize = gsm_color_button_finalize;
+    widget_class->state_changed = gsm_color_button_state_changed;
+    widget_class->get_preferred_width = gsm_color_button_get_preferred_width;
+    widget_class->get_preferred_height = gsm_color_button_get_preferred_height;
+    widget_class->size_allocate = gsm_color_button_size_allocate;
+    widget_class->realize = gsm_color_button_realize;
+    widget_class->unrealize = gsm_color_button_unrealize;
+    widget_class->style_set = gsm_color_button_style_set;
+    widget_class->button_release_event = gsm_color_button_released;
+    widget_class->button_press_event = gsm_color_button_pressed;
+    widget_class->enter_notify_event = gsm_color_button_enter_notify;
+    widget_class->leave_notify_event = gsm_color_button_leave_notify;
+
+    klass->color_set = NULL;
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_PERCENTAGE,
+                                     g_param_spec_double ("fraction",
+                                                          _("Fraction"),
+                                     // TRANSLATORS: description of the pie color picker's (mem, swap) filled percentage property
+                                                          _("Percentage full for pie color pickers"),
+                                                          0, 1, 0.5,
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TITLE,
+                                     g_param_spec_string ("title",
+                                                          _("Title"),
+                                                          _("The title of the color selection dialog"),
+                                                          _("Pick a Color"),
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_COLOR,
+                                     g_param_spec_boxed ("color",
+                                                         _("Current Color"),
+                                                         _("The selected color"),
+                                                         GDK_TYPE_RGBA,
+                                                         G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TYPE,
+                                     g_param_spec_uint ("type", _("Type"),
+                                                        _("Type of color picker"),
+                                                        0, 4, 0,
+                                                        G_PARAM_READWRITE));
+
+    color_button_signals[COLOR_SET] = g_signal_new ("color_set",
+                                                    G_TYPE_FROM_CLASS
+                                                    (gobject_class),
+                                                    G_SIGNAL_RUN_FIRST,
+                                                    G_STRUCT_OFFSET
+                                                    (GSMColorButtonClass,
+                                                    color_set), NULL, NULL,
+                                                    g_cclosure_marshal_VOID__VOID,
+                                                    G_TYPE_NONE, 0);
+
+}
+
+static cairo_surface_t *
+fill_image_buffer_from_file (cairo_t *cr, const char *filePath)
+{
+    GError *error = NULL;
+    RsvgHandle *handle;
+    cairo_surface_t *tmp_surface;
+    cairo_t *tmp_cr;
+
+    handle = rsvg_handle_new_from_file (filePath, &error);
+
+    if (handle == NULL) {
+        g_warning("rsvg_handle_new_from_file(\"%s\") failed: %s",
+              filePath, (error ? error->message : "unknown error"));
+    if (error)
+          g_error_free(error);
+    return NULL;
+    }
+
+    tmp_surface = cairo_surface_create_similar (cairo_get_target (cr),
+                                                CAIRO_CONTENT_COLOR_ALPHA,
+                                                32, 32);
+    tmp_cr = cairo_create (tmp_surface);
+    rsvg_handle_render_cairo (handle, tmp_cr);
+    cairo_destroy (tmp_cr);
+    g_object_unref (handle);
+    return tmp_surface;
+}
+
+static void
+render (GtkWidget * widget)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GdkRGBA *color;
+    GdkRGBA tmp_color = priv->color;
+    color = &tmp_color;
+    cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
+    cairo_path_t *path = NULL;
+    gint width, height;
+    gdouble radius, arc_start, arc_end;
+    gdouble highlight_factor;
+
+    if (priv->highlight > 0) {
+        highlight_factor = 0.125 * priv->highlight;
+
+    if (color->red + highlight_factor > 1.0)
+        color->red = 1.0;
+    else
+        color->red = color->red + highlight_factor;
+
+    if (color->blue + highlight_factor > 1.0)
+        color->blue = 1.0;
+    else
+      color->blue = color->blue + highlight_factor;
+
+    if (color->green + highlight_factor > 1.0)
+        color->green = 1.0;
+    else
+        color->green = color->green + highlight_factor;
+    }
+    gdk_cairo_set_source_rgba (cr, color);
+
+    width = gdk_window_get_width(gtk_widget_get_window(widget));
+    height = gdk_window_get_height(gtk_widget_get_window(widget));
+
+    switch (priv->type)
+        {
+        case GSMCP_TYPE_CPU:
+            //gtk_widget_set_size_request (widget, GSMCP_MIN_WIDTH, GSMCP_MIN_HEIGHT);
+            cairo_paint (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1);
+            cairo_stroke (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.4);
+            cairo_rectangle (cr, 1.5, 1.5, width - 3, height - 3);
+            cairo_stroke (cr);
+            break;
+        case GSMCP_TYPE_PIE:
+            if (width < 32)        // 32px minimum size
+                gtk_widget_set_size_request (widget, 32, 32);
+            if (width < height)
+                radius = width / 2;
+            else
+                radius = height / 2;
+
+            arc_start = -G_PI_2 + 2 * G_PI * priv->fraction;
+            arc_end = -G_PI_2;
+
+            cairo_set_line_width (cr, 1);
+
+            // Draw external stroke and fill
+            if (priv->fraction < 0.01) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_end);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    arc_end, arc_start);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_start);
+            }
+            cairo_fill_preserve (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.7);
+            cairo_stroke (cr);
+
+            // Draw internal highlight
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.45);
+            cairo_set_line_width (cr, 1);
+
+            if (priv->fraction < 0.03) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_end - (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    arc_end - (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+            }
+            cairo_stroke (cr);
+
+            // Draw external shape
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.2);
+            cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 1.25, 0,
+                G_PI * 2);
+            cairo_stroke (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_IN:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                    fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/download.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 8.5, 1.5);
+            cairo_line_to (cr, 23.5, 1.5);
+            cairo_line_to (cr, 23.5, 11.5);
+            cairo_line_to (cr, 29.5, 11.5);
+            cairo_line_to (cr, 16.5, 27.5);
+            cairo_line_to (cr, 15.5, 27.5);
+            cairo_line_to (cr, 2.5, 11.5);
+            cairo_line_to (cr, 8.5, 11.5);
+            cairo_line_to (cr, 8.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_OUT:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/upload.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 16.5, 1.5);
+            cairo_line_to (cr, 29.5, 17.5);
+            cairo_line_to (cr, 23.5, 17.5);
+            cairo_line_to (cr, 23.5, 27.5);
+            cairo_line_to (cr, 8.5, 27.5);
+            cairo_line_to (cr, 8.5, 17.5);
+            cairo_line_to (cr, 2.5, 17.5);
+            cairo_line_to (cr, 15.5, 1.5);
+            cairo_line_to (cr, 16.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        }
+    cairo_destroy (cr);
+}
+
+/* Handle exposure events for the color picker's drawing area */
+static gboolean draw (GtkWidget * widget, cairo_t * cr, gpointer data)
+{
+    render (GTK_WIDGET (data));
+
+    return FALSE;
+}
+
+static void
+gsm_color_button_realize (GtkWidget * widget)
+{
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->realize (widget);
+    render (widget);
+}
+
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width)
+{
+    g_return_if_fail (widget != NULL && minimum_width != NULL && natural_width != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_width = GSMCP_MIN_WIDTH;
+    *natural_width = GSMCP_MIN_WIDTH;
+}
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height)
+{
+    g_return_if_fail (widget != NULL && minimum_height != NULL && natural_height != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_height = GSMCP_MIN_HEIGHT;
+    *natural_height = GSMCP_MIN_HEIGHT;
+}
+
+static void
+gsm_color_button_size_allocate (GtkWidget * widget,
+                                GtkAllocation * allocation)
+{
+    g_return_if_fail (widget != NULL || allocation != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    gtk_widget_set_allocation (widget, allocation);
+
+    if (gtk_widget_get_realized (widget))
+    {
+        gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y,
+                                allocation->width, allocation->height);
+    }
+}
+
+static void
+gsm_color_button_unrealize (GtkWidget * widget)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->unrealize (widget);
+}
+
+static void
+gsm_color_button_style_set (GtkWidget * widget, GtkStyle * previous_style)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->style_set (widget,
+                                                                 previous_style);
+
+}
+
+static void
+gsm_color_button_state_changed (GtkWidget * widget,
+                                GtkStateType previous_state)
+{
+}
+
+static void
+gsm_color_button_drag_data_received (GtkWidget * widget,
+                                     GdkDragContext * context,
+                                     gint x,
+                                     gint y,
+                                     GtkSelectionData * selection_data,
+                                     guint info,
+                                     guint32 time,
+                                     GSMColorButton * color_button)
+{
+    gint length;
+    guint16 *dropped;
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    length = gtk_selection_data_get_length (selection_data);
+
+    if (length < 0)
+        return;
+
+    /* We accept drops with the wrong format, since the KDE color
+     * chooser incorrectly drops application/x-color with format 8.
+     */
+    if (length != 8)
+    {
+        g_warning (_("Received invalid color data\n"));
+        return;
+    }
+
+    dropped = (guint16 *) gtk_selection_data_get_data (selection_data);
+
+    priv->color.red =   ((double) dropped[0]) / 65535.0;
+    priv->color.green = ((double) dropped[1]) / 65535.0;
+    priv->color.blue =  ((double) dropped[2]) / 65535.0;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+    g_object_freeze_notify (G_OBJECT (color_button));
+    g_object_notify (G_OBJECT (color_button), "color");
+    g_object_thaw_notify (G_OBJECT (color_button));
+}
+
+static void
+set_color_icon (GdkDragContext * context, GdkRGBA * color)
+{
+    GdkPixbuf *pixbuf;
+    guint32 pixel;
+
+    pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 48, 32);
+
+    pixel = ((guint32)(color->red * 0xff) << 24) |
+            ((guint32)(color->green * 0xff) << 16) |
+            ((guint32)(color->blue * 0xff) << 8);
+
+    gdk_pixbuf_fill (pixbuf, pixel);
+
+    gtk_drag_set_icon_pixbuf (context, pixbuf, -2, -2);
+    g_object_unref (pixbuf);
+}
+
+static void
+gsm_color_button_drag_begin (GtkWidget * widget,
+                             GdkDragContext * context, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = data;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    set_color_icon (context, &priv->color);
+}
+
+static void
+gsm_color_button_drag_data_get (GtkWidget * widget,
+                                GdkDragContext * context,
+                                GtkSelectionData * selection_data,
+                                guint info,
+                                guint time, GSMColorButton * color_button)
+{
+    guint16 dropped[4];
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    dropped[0] = (guint16) (65535.0 * priv->color.red);
+    dropped[1] = (guint16) (65535.0 * priv->color.green);
+    dropped[2] = (guint16) (65535.0 * priv->color.blue);
+    dropped[3] = 65535;        // This widget doesn't care about alpha
+
+    gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data),
+                            16, (guchar *) dropped, 8);
+}
+
+static void
+gsm_color_button_init (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = 0;
+    priv->color.green = 0;
+    priv->color.blue = 0;
+    priv->fraction = 0.5;
+    priv->type = GSMCP_TYPE_CPU;
+    priv->image_buffer = NULL;
+    priv->title = g_strdup (_("Pick a Color"));     /* default title */
+    priv->in_button = FALSE;
+    priv->button_down = FALSE;
+
+    gtk_drag_dest_set (GTK_WIDGET (color_button),
+                       GTK_DEST_DEFAULT_MOTION |
+                       GTK_DEST_DEFAULT_HIGHLIGHT |
+                       GTK_DEST_DEFAULT_DROP, drop_types, 1, GDK_ACTION_COPY);
+    gtk_drag_source_set (GTK_WIDGET (color_button),
+                         GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
+                         drop_types, 1, GDK_ACTION_COPY);
+    g_signal_connect (color_button, "drag_begin",
+                      G_CALLBACK (gsm_color_button_drag_begin), color_button);
+    g_signal_connect (color_button, "drag_data_received",
+                      G_CALLBACK (gsm_color_button_drag_data_received),
+                      color_button);
+    g_signal_connect (color_button, "drag_data_get",
+                      G_CALLBACK (gsm_color_button_drag_data_get),
+                      color_button);
+
+    gtk_widget_add_events (GTK_WIDGET(color_button), GDK_ENTER_NOTIFY_MASK
+                              | GDK_LEAVE_NOTIFY_MASK);
+
+    gtk_widget_set_tooltip_text (GTK_WIDGET(color_button), _("Click to set graph colors"));
+
+    g_signal_connect (color_button, "draw", G_CALLBACK (draw), color_button);
+}
+
+static void
+gsm_color_button_finalize (GObject * object)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    if (priv->cc_dialog != NULL)
+        gtk_widget_destroy (priv->cc_dialog);
+    priv->cc_dialog = NULL;
+
+    g_free (priv->title);
+    priv->title = NULL;
+
+    cairo_surface_destroy (priv->image_buffer);
+    priv->image_buffer = NULL;
+
+    G_OBJECT_CLASS (gsm_color_button_parent_class)->finalize (object);
+}
+
+GtkWidget *
+gsm_color_button_new (const GdkRGBA * color, guint type)
+{
+    return g_object_new (GSM_TYPE_COLOR_BUTTON, "color", color, "type", type,
+                         NULL);
+}
+
+static void
+dialog_response (GtkWidget * widget, GtkResponseType response, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GtkColorChooser *color_chooser;
+
+    if (response == GTK_RESPONSE_OK) {
+        color_chooser = GTK_COLOR_CHOOSER (priv->cc_dialog);
+
+        gtk_color_chooser_get_rgba (color_chooser, &priv->color);
+
+        gtk_widget_hide (priv->cc_dialog);
+
+        gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+        g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+        g_object_freeze_notify (G_OBJECT (color_button));
+        g_object_notify (G_OBJECT (color_button), "color");
+        g_object_thaw_notify (G_OBJECT (color_button));
+    }
+    else  /* (response == GTK_RESPONSE_CANCEL) */
+        gtk_widget_hide (priv->cc_dialog);
+}
+
+static gboolean
+dialog_destroy (GtkWidget * widget, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->cc_dialog = NULL;
+
+    return FALSE;
+}
+
+static gint
+gsm_color_button_clicked (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    /* if dialog already exists, make sure it's shown and raised */
+    if (!priv->cc_dialog)
+    {
+        /* Create the dialog and connects its buttons */
+        GtkWidget *cc_dialog;
+        GtkWidget *parent;
+
+        parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));
+        if (!gtk_widget_is_toplevel (parent))
+            parent = NULL;
+
+        cc_dialog = gtk_color_chooser_dialog_new (priv->title, GTK_WINDOW (parent));
+
+        gtk_window_set_modal (GTK_WINDOW (cc_dialog), TRUE);
+
+        g_signal_connect (cc_dialog, "response",
+                          G_CALLBACK (dialog_response), color_button);
+
+        g_signal_connect (cc_dialog, "destroy",
+                          G_CALLBACK (dialog_destroy), color_button);
+
+        priv->cc_dialog = cc_dialog;
+    }
+
+    gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (priv->cc_dialog),
+                                &priv->color);
+
+    gtk_window_present (GTK_WINDOW (priv->cc_dialog));
+
+    return 0;
+}
+
+static gint
+gsm_color_button_pressed (GtkWidget * widget, GdkEventButton * event)
+{
+    if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) )
+    {
+	GSMColorButtonPrivate *priv;
+        GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+	priv = gsm_color_button_get_instance_private (color_button);
+	priv->button_down = TRUE;
+    }
+  return 0;
+}
+
+static gint
+gsm_color_button_released (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    if (priv->button_down && priv->in_button)
+        gsm_color_button_clicked (widget, event);
+    priv->button_down = FALSE;
+    return 0;
+}
+
+static gboolean
+gsm_color_button_enter_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 1.0;
+    priv->in_button = TRUE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+static gboolean
+gsm_color_button_leave_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 0;
+    priv->in_button = FALSE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+guint
+gsm_color_button_get_cbtype (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->type;
+}
+
+void
+gsm_color_button_set_cbtype (GSMColorButton * color_button, guint type)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->type = type;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "type");
+}
+
+gdouble
+gsm_color_button_get_fraction (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->fraction;
+}
+
+void
+gsm_color_button_set_fraction (GSMColorButton * color_button,
+                               gdouble fraction)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->fraction = fraction;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "fraction");
+}
+
+void
+gsm_color_button_get_color (GSMColorButton * color_button, GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    color->red = priv->color.red;
+    color->green = priv->color.green;
+    color->blue = priv->color.blue;
+    color->alpha = priv->color.alpha;
+}
+
+void
+gsm_color_button_set_color (GSMColorButton * color_button,
+                            const GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    g_return_if_fail (color != NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = color->red;
+    priv->color.green = color->green;
+    priv->color.blue = color->blue;
+    priv->color.alpha = color->alpha;
+
+    gtk_widget_queue_draw (GTK_WIDGET (color_button));
+
+    g_object_notify (G_OBJECT (color_button), "color");
+}
+
+void
+gsm_color_button_set_title (GSMColorButton * color_button,
+                            const gchar * title)
+{
+    gchar *old_title;
+    GSMColorButtonPrivate *priv;
+
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    old_title = priv->title;
+    priv->title = g_strdup (title);
+    g_free (old_title);
+
+    if (priv->cc_dialog)
+        gtk_window_set_title (GTK_WINDOW (priv->cc_dialog),
+                              priv->title);
+
+    g_object_notify (G_OBJECT (color_button), "title");
+}
+
+const gchar* gsm_color_button_get_title(GSMColorButton* color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail(GSM_IS_COLOR_BUTTON(color_button), NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->title;
+}
+
+static void
+gsm_color_button_set_property (GObject * object,
+                               guint param_id,
+                               const GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            gsm_color_button_set_fraction (color_button,
+                                           g_value_get_double (value));
+            break;
+        case PROP_TITLE:
+            gsm_color_button_set_title (color_button, g_value_get_string (value));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_set_color (color_button, g_value_get_boxed (value));
+            break;
+        case PROP_TYPE:
+            gsm_color_button_set_cbtype (color_button, g_value_get_uint (value));
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+static void
+gsm_color_button_get_property (GObject * object,
+                               guint param_id,
+                               GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+    GdkRGBA color;
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            g_value_set_double (value,
+                                gsm_color_button_get_fraction (color_button));
+            break;
+        case PROP_TITLE:
+            g_value_set_string (value, gsm_color_button_get_title (color_button));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_get_color (color_button, &color);
+                                        g_value_set_boxed (value, &color);
+            break;
+        case PROP_TYPE:
+            g_value_set_uint (value, gsm_color_button_get_cbtype (color_button));
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/6.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/6.html new file mode 100644 index 00000000..f73c90ba --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/6.html @@ -0,0 +1,1599 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
/* Procman - main window
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <gdk/gdkkeysyms.h>
+#include <math.h>
+
+#include "procman.h"
+#include "callbacks.h"
+#include "interface.h"
+#include "proctable.h"
+#include "procactions.h"
+#include "load-graph.h"
+#include "util.h"
+#include "disks.h"
+#include "sysinfo.h"
+#include "gsm_color_button.h"
+
+static void    cb_toggle_tree (GtkAction *action, gpointer data);
+static void    cb_proc_goto_tab (gint tab);
+
+static const GtkActionEntry menu_entries[] =
+{
+    // xgettext: noun, top level menu.
+    // "File" did not make sense for system-monitor
+    { "Monitor", NULL, N_("_Monitor") },
+    { "Edit", NULL, N_("_Edit") },
+    { "View", NULL, N_("_View") },
+    { "Help", NULL, N_("_Help") },
+
+    { "Lsof", "edit-find", N_("Search for _Open Files"), "<control>O",
+      N_("Search for open files"), G_CALLBACK(cb_show_lsof) },
+    { "Quit", "application-exit", N_("_Quit"), "<control>Q",
+      N_("Quit the program"), G_CALLBACK (cb_app_exit) },
+
+
+    { "StopProcess", NULL, N_("_Stop Process"), "<control>S",
+      N_("Stop process"), G_CALLBACK(cb_kill_sigstop) },
+    { "ContProcess", NULL, N_("_Continue Process"), "<control>C",
+      N_("Continue process if stopped"), G_CALLBACK(cb_kill_sigcont) },
+
+    { "EndProcess", NULL, N_("_End Process"), "<control>E",
+      N_("Force process to finish normally"), G_CALLBACK (cb_end_process) },
+    { "KillProcess", NULL, N_("_Kill Process"), "<control>K",
+      N_("Force process to finish immediately"), G_CALLBACK (cb_kill_process) },
+    { "ChangePriority", NULL, N_("_Change Priority"), NULL,
+      N_("Change the order of priority of process"), NULL },
+    { "Preferences", "preferences-desktop", N_("_Preferences"), NULL,
+      N_("Configure the application"), G_CALLBACK (cb_edit_preferences) },
+
+    { "Refresh", "view-refresh", N_("_Refresh"), "<control>R",
+      N_("Refresh the process list"), G_CALLBACK(cb_user_refresh) },
+
+    { "MemoryMaps", NULL, N_("_Memory Maps"), "<control>M",
+      N_("Open the memory maps associated with a process"), G_CALLBACK (cb_show_memory_maps) },
+    // Translators: this means 'Files that are open' (open is no verb here
+    { "OpenFiles", NULL, N_("Open _Files"), "<control>F",
+      N_("View the files opened by a process"), G_CALLBACK (cb_show_open_files) },
+    { "ProcessProperties", NULL, N_("_Properties"), NULL,
+      N_("View additional information about a process"), G_CALLBACK (cb_show_process_properties) },
+
+
+    { "HelpContents", "help-browser", N_("_Contents"), "F1",
+      N_("Open the manual"), G_CALLBACK (cb_help_contents) },
+    { "About", "help-about", N_("_About"), NULL,
+      N_("About this application"), G_CALLBACK (cb_about) }
+};
+
+static const GtkToggleActionEntry toggle_menu_entries[] =
+{
+    { "ShowDependencies", NULL, N_("_Dependencies"), "<control>D",
+      N_("Show parent/child relationship between processes"),
+      G_CALLBACK (cb_toggle_tree), TRUE },
+};
+
+
+static const GtkRadioActionEntry radio_menu_entries[] =
+{
+  { "ShowActiveProcesses", NULL, N_("_Active Processes"), NULL,
+    N_("Show active processes"), ACTIVE_PROCESSES },
+  { "ShowAllProcesses", NULL, N_("A_ll Processes"), NULL,
+    N_("Show all processes"), ALL_PROCESSES },
+  { "ShowMyProcesses", NULL, N_("M_y Processes"), NULL,
+    N_("Show only user-owned processes"), MY_PROCESSES }
+};
+
+static const GtkRadioActionEntry priority_menu_entries[] =
+{
+    { "VeryHigh", NULL, N_("Very High"), NULL,
+      N_("Set process priority to very high"), VERY_HIGH_PRIORITY },
+    { "High", NULL, N_("High"), NULL,
+      N_("Set process priority to high"), HIGH_PRIORITY },
+    { "Normal", NULL, N_("Normal"), NULL,
+      N_("Set process priority to normal"), NORMAL_PRIORITY },
+    { "Low", NULL, N_("Low"), NULL,
+      N_("Set process priority to low"), LOW_PRIORITY },
+    { "VeryLow", NULL, N_("Very Low"), NULL,
+      N_("Set process priority to very low"), VERY_LOW_PRIORITY },
+    { "Custom", NULL, N_("Custom"), NULL,
+      N_("Set process priority manually"), CUSTOM_PRIORITY }
+};
+
+
+static const char ui_info[] =
+    "  <menubar name=\"MenuBar\">"
+    "    <menu name=\"MonitorMenu\" action=\"Monitor\">"
+    "      <menuitem name=\"MonitorLsofMenu\" action=\"Lsof\" />"
+    "      <menuitem name=\"MonitorQuitMenu\" action=\"Quit\" />"
+    "    </menu>"
+    "    <menu name=\"EditMenu\" action=\"Edit\">"
+    "      <menuitem name=\"EditStopProcessMenu\" action=\"StopProcess\" />"
+    "      <menuitem name=\"EditContProcessMenu\" action=\"ContProcess\" />"
+    "      <separator />"
+    "      <menuitem name=\"EditEndProcessMenu\" action=\"EndProcess\" />"
+    "      <menuitem name=\"EditKillProcessMenu\" action=\"KillProcess\" />"
+    "      <separator />"
+    "      <menu name=\"EditChangePriorityMenu\" action=\"ChangePriority\" >"
+    "        <menuitem action=\"VeryHigh\" />"
+    "        <menuitem action=\"High\" />"
+    "        <menuitem action=\"Normal\" />"
+    "        <menuitem action=\"Low\" />"
+    "        <menuitem action=\"VeryLow\" />"
+    "        <separator />"
+    "        <menuitem action=\"Custom\"/>"
+    "      </menu>"
+    "      <separator />"
+    "      <menuitem name=\"EditPreferencesMenu\" action=\"Preferences\" />"
+    "    </menu>"
+    "    <menu name=\"ViewMenu\" action=\"View\">"
+    "      <menuitem name=\"ViewActiveProcesses\" action=\"ShowActiveProcesses\" />"
+    "      <menuitem name=\"ViewAllProcesses\" action=\"ShowAllProcesses\" />"
+    "      <menuitem name=\"ViewMyProcesses\" action=\"ShowMyProcesses\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewDependenciesMenu\" action=\"ShowDependencies\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewMemoryMapsMenu\" action=\"MemoryMaps\" />"
+    "      <menuitem name=\"ViewOpenFilesMenu\" action=\"OpenFiles\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewProcessPropertiesMenu\" action=\"ProcessProperties\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewRefresh\" action=\"Refresh\" />"
+    "    </menu>"
+    "    <menu name=\"HelpMenu\" action=\"Help\">"
+    "      <menuitem name=\"HelpContentsMenu\" action=\"HelpContents\" />"
+    "      <menuitem name=\"HelpAboutMenu\" action=\"About\" />"
+    "    </menu>"
+    "  </menubar>"
+    "  <popup name=\"PopupMenu\" action=\"Popup\">"
+    "    <menuitem action=\"StopProcess\" />"
+    "    <menuitem action=\"ContProcess\" />"
+    "    <separator />"
+    "    <menuitem action=\"EndProcess\" />"
+    "    <menuitem action=\"KillProcess\" />"
+    "    <separator />"
+    "    <menu name=\"ChangePriorityMenu\" action=\"ChangePriority\" >"
+    "      <menuitem action=\"VeryHigh\" />"
+    "      <menuitem action=\"High\" />"
+    "      <menuitem action=\"Normal\" />"
+    "      <menuitem action=\"Low\" />"
+    "      <menuitem action=\"VeryLow\" />"
+    "      <separator />"
+    "      <menuitem action=\"Custom\"/>"
+    "    </menu>"
+    "    <separator />"
+    "    <menuitem action=\"MemoryMaps\" />"
+    "    <menuitem action=\"OpenFiles\" />"
+    "    <separator />"
+    "    <menuitem action=\"ProcessProperties\" />"
+
+    "  </popup>";
+
+
+static void
+create_proc_view(ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *proctree;
+    GtkWidget *scrolled;
+    char* string;
+
+    /* create the processes tab */
+    string = make_loadavg_string ();
+    procdata->loadavg = GTK_WIDGET (gtk_builder_get_object (builder, "load_avg_label"));
+    gtk_label_set_text (GTK_LABEL (procdata->loadavg), string);
+    g_free (string);
+
+    proctree = proctable_new (procdata);
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "processes_scrolled"));
+
+    gtk_container_add (GTK_CONTAINER (scrolled), proctree);
+
+    procdata->endprocessbutton = GTK_WIDGET (gtk_builder_get_object (builder, "endprocessbutton"));
+    g_signal_connect (G_OBJECT (procdata->endprocessbutton), "clicked",
+                      G_CALLBACK (cb_end_process_button_pressed), procdata);
+
+    /* create popup_menu for the processes tab */
+    procdata->popup_menu = gtk_ui_manager_get_widget (procdata->uimanager, "/PopupMenu");
+}
+
+
+GtkWidget *
+make_title_label (const char *text)
+{
+    GtkWidget *label;
+    char *full;
+
+    full = g_strdup_printf ("<span weight=\"bold\">%s</span>", text);
+    label = gtk_label_new (full);
+    g_free (full);
+
+    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+
+    return label;
+}
+
+
+static void
+create_sys_view (ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *cpu_graph_box, *mem_graph_box, *net_graph_box;
+    GtkWidget *label,*cpu_label;
+    GtkWidget *table;
+    GtkWidget *color_picker;
+    GtkWidget *picker_alignment;
+    LoadGraph *cpu_graph, *mem_graph, *net_graph;
+
+    gint i;
+    gchar *title_text;
+    gchar *label_text;
+    gchar *title_template;
+
+    // Translators: color picker title, %s is CPU, Memory, Swap, Receiving, Sending
+    title_template = g_strdup(_("Pick a Color for '%s'"));
+
+    /* The CPU BOX */
+
+    cpu_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_graph_box"));
+
+    cpu_graph = new LoadGraph(LOAD_GRAPH_CPU);
+    gtk_box_pack_start (GTK_BOX (cpu_graph_box),
+                        load_graph_get_widget(cpu_graph),
+                        TRUE,
+                        TRUE,
+                         0);
+
+    GtkWidget* flowbox = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_flow_box"));
+    gtk_box_reorder_child (GTK_BOX (cpu_graph_box), flowbox, 1);
+    for (i=0;i<procdata->config.num_cpus; i++) {
+        GtkWidget *temp_hbox;
+
+        temp_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
+        gtk_container_add (GTK_CONTAINER (flowbox), temp_hbox);
+
+        color_picker = gsm_color_button_new (&cpu_graph->colors.at(i), GSMCP_TYPE_CPU);
+        g_signal_connect (G_OBJECT (color_picker), "color_set",
+                          G_CALLBACK (cb_cpu_color_changed), GINT_TO_POINTER (i));
+        gtk_box_pack_start (GTK_BOX (temp_hbox), color_picker, FALSE, TRUE, 0);
+        gtk_widget_set_size_request(GTK_WIDGET(color_picker), 32, -1);
+        if(procdata->config.num_cpus == 1) {
+            label_text = g_strdup (_("CPU"));
+        } else {
+            label_text = g_strdup_printf (_("CPU%d"), i+1);
+        }
+        title_text = g_strdup_printf(title_template, label_text);
+        label = gtk_label_new (label_text);
+        gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+        g_free(title_text);
+        gtk_box_pack_start (GTK_BOX (temp_hbox), label, FALSE, FALSE, 6);
+        g_free (label_text);
+
+        cpu_label = gtk_label_new (NULL);
+        gtk_label_set_width_chars (GTK_LABEL (cpu_label), 7);
+        gtk_label_set_xalign (GTK_LABEL (cpu_label), 0.0);
+
+        gtk_box_pack_start (GTK_BOX (temp_hbox), cpu_label, TRUE, TRUE, 0);
+        load_graph_get_labels(cpu_graph)->cpu[i] = cpu_label;
+
+    }
+
+    procdata->cpu_graph = cpu_graph;
+
+    /** The memory box */
+    mem_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "mem_graph_box"));
+
+    mem_graph = new LoadGraph(LOAD_GRAPH_MEM);
+    gtk_box_pack_start (GTK_BOX (mem_graph_box),
+                        load_graph_get_widget(mem_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "mem_table"));
+
+    color_picker = load_graph_get_mem_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_mem_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Memory"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 0, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->memory;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 1, 1, 1, 1);
+
+    color_picker = load_graph_get_swap_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_swap_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Swap"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 2, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->swap;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 3, 1, 1, 1);
+
+    procdata->mem_graph = mem_graph;
+
+    /* The net box */
+    net_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "net_graph_box"));
+
+    net_graph = new LoadGraph(LOAD_GRAPH_NET);
+    gtk_box_pack_start (GTK_BOX (net_graph_box),
+                        load_graph_get_widget(net_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "net_table"));
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(0), GSMCP_TYPE_NETWORK_IN);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_in_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Receiving"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "receiving_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_in;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_in_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 1, 1, 1);
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(1), GSMCP_TYPE_NETWORK_OUT);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_out_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Sending"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "sending_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_out;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_out_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 1, 1, 1);
+
+    procdata->net_graph = net_graph;
+    g_free(title_template);
+}
+
+static void
+menu_item_select_cb (GtkMenuItem *proxy,
+                     ProcData *procdata)
+{
+    GtkAction *action;
+    char *message;
+
+    action = gtk_activatable_get_related_action (GTK_ACTIVATABLE(proxy));
+    g_assert(action);
+
+    g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
+    if (message)
+    {
+        gtk_statusbar_push (GTK_STATUSBAR (procdata->statusbar),
+                    procdata->tip_message_cid, message);
+        g_free (message);
+    }
+}
+
+static void
+menu_item_deselect_cb (GtkMenuItem *proxy,
+                       ProcData *procdata)
+{
+    gtk_statusbar_pop (GTK_STATUSBAR (procdata->statusbar),
+               procdata->tip_message_cid);
+}
+
+static void
+connect_proxy_cb (GtkUIManager *manager,
+                  GtkAction *action,
+                  GtkWidget *proxy,
+                  ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_connect (proxy, "select",
+                          G_CALLBACK (menu_item_select_cb), procdata);
+        g_signal_connect (proxy, "deselect",
+                          G_CALLBACK (menu_item_deselect_cb), procdata);
+    }
+}
+
+static void
+disconnect_proxy_cb (GtkUIManager *manager,
+                     GtkAction *action,
+                     GtkWidget *proxy,
+                     ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_select_cb)), procdata);
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_deselect_cb)), procdata);
+    }
+}
+
+void
+create_main_window (ProcData *procdata)
+{
+    gint i;
+    gint width, height, xpos, ypos;
+    GtkWidget *app;
+    GtkAction *action;
+    GtkWidget *menubar;
+    GtkWidget *main_box;
+    GtkWidget *notebook;
+    GtkBuilder *builder;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/interface.ui");
+
+    app = GTK_WIDGET (gtk_builder_get_object (builder, "main_window"));
+    main_box = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
+
+    GdkScreen* screen = gtk_widget_get_screen(app);
+    /* use visual, if available */
+    GdkVisual* visual = gdk_screen_get_rgba_visual(screen);
+    if (visual)
+        gtk_widget_set_visual(app, visual);
+
+    width = procdata->config.width;
+    height = procdata->config.height;
+    xpos = procdata->config.xpos;
+    ypos = procdata->config.ypos;
+    gtk_window_set_default_size (GTK_WINDOW (app), width, height);
+    gtk_window_move(GTK_WINDOW (app), xpos, ypos);
+
+    if (procdata->config.maximized) {
+        gtk_window_maximize(GTK_WINDOW(app));
+    }
+
+    /* create the menubar */
+    procdata->uimanager = gtk_ui_manager_new ();
+
+    /* show tooltips in the statusbar */
+    g_signal_connect (procdata->uimanager, "connect_proxy",
+                      G_CALLBACK (connect_proxy_cb), procdata);
+    g_signal_connect (procdata->uimanager, "disconnect_proxy",
+                      G_CALLBACK (disconnect_proxy_cb), procdata);
+
+    gtk_window_add_accel_group (GTK_WINDOW (app),
+                                gtk_ui_manager_get_accel_group (procdata->uimanager));
+
+    if (!gtk_ui_manager_add_ui_from_string (procdata->uimanager,
+                                            ui_info,
+                                            -1,
+                                            NULL)) {
+        g_error("building menus failed");
+    }
+
+    procdata->action_group = gtk_action_group_new ("ProcmanActions");
+    gtk_action_group_set_translation_domain (procdata->action_group, NULL);
+    gtk_action_group_add_actions (procdata->action_group,
+                                  menu_entries,
+                                  G_N_ELEMENTS (menu_entries),
+                                  procdata);
+    gtk_action_group_add_toggle_actions (procdata->action_group,
+                                         toggle_menu_entries,
+                                         G_N_ELEMENTS (toggle_menu_entries),
+                                         procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                        radio_menu_entries,
+                        G_N_ELEMENTS (radio_menu_entries),
+                        procdata->config.whose_process,
+                        G_CALLBACK(cb_radio_processes),
+                        procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                                        priority_menu_entries,
+                                        G_N_ELEMENTS (priority_menu_entries),
+                                        NORMAL_PRIORITY,
+                                        G_CALLBACK(cb_renice),
+                                        procdata);
+
+    gtk_ui_manager_insert_action_group (procdata->uimanager,
+                                        procdata->action_group,
+                                        0);
+
+    menubar = gtk_ui_manager_get_widget (procdata->uimanager, "/MenuBar");
+    gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0);
+    gtk_box_reorder_child (GTK_BOX (main_box), menubar, 0);
+
+    /* create the main notebook */
+    procdata->notebook = notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
+
+    create_proc_view(procdata, builder);
+    create_sys_view (procdata, builder);
+    create_disk_view (procdata, builder);
+
+    g_signal_connect (G_OBJECT (notebook), "switch-page",
+              G_CALLBACK (cb_switch_page), procdata);
+    g_signal_connect (G_OBJECT (notebook), "change-current-page",
+              G_CALLBACK (cb_change_current_page), procdata);
+
+    gtk_widget_show_all(notebook); // need to make page switch work
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab);
+    cb_change_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab, procdata);
+    g_signal_connect (G_OBJECT (app), "delete_event",
+                      G_CALLBACK (cb_app_delete),
+                      procdata);
+
+    GtkAccelGroup *accel_group;
+    GClosure *goto_tab_closure[4];
+    accel_group = gtk_accel_group_new ();
+    gtk_window_add_accel_group (GTK_WINDOW(app), accel_group);
+    for (i = 0; i < 4; ++i) {
+        goto_tab_closure[i] = g_cclosure_new_swap (G_CALLBACK (cb_proc_goto_tab),
+                                                   GINT_TO_POINTER (i), NULL);
+        gtk_accel_group_connect (accel_group, '0'+(i+1),
+                                 GDK_MOD1_MASK, GTK_ACCEL_VISIBLE,
+                                 goto_tab_closure[i]);
+    }
+
+    /* create the statusbar */
+    procdata->statusbar = GTK_WIDGET (gtk_builder_get_object (builder, "statusbar"));
+    procdata->tip_message_cid = gtk_statusbar_get_context_id
+        (GTK_STATUSBAR (procdata->statusbar), "tip_message");
+
+    action = gtk_action_group_get_action (procdata->action_group, "ShowDependencies");
+    gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+                      procdata->config.show_tree);
+
+    gtk_builder_connect_signals (builder, NULL);
+
+    gtk_widget_show_all(app);
+    procdata->app = app;
+
+    g_object_unref (G_OBJECT (builder));
+}
+
+void
+do_popup_menu (ProcData *procdata, GdkEventButton *event)
+{
+    gtk_menu_popup_at_pointer (GTK_MENU (procdata->popup_menu), NULL);
+}
+
+void
+update_sensitivity(ProcData *data)
+{
+    const char * const selected_actions[] = { "StopProcess",
+                                              "ContProcess",
+                                              "EndProcess",
+                                              "KillProcess",
+                                              "ChangePriority",
+                                              "MemoryMaps",
+                                              "OpenFiles",
+                                              "ProcessProperties" };
+
+    const char * const processes_actions[] = { "ShowActiveProcesses",
+                                               "ShowAllProcesses",
+                                               "ShowMyProcesses",
+                                               "ShowDependencies",
+                                               "Refresh"
+    };
+
+    size_t i;
+    gboolean processes_sensitivity, selected_sensitivity;
+    GtkAction *action;
+
+    processes_sensitivity = (data->config.current_tab == PROCMAN_TAB_PROCESSES);
+    selected_sensitivity = (processes_sensitivity && data->selection && gtk_tree_selection_count_selected_rows (data->selection) > 0);
+
+    if(data->endprocessbutton) {
+        /* avoid error on startup if endprocessbutton
+           has not been built yet */
+        gtk_widget_set_sensitive(data->endprocessbutton, selected_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(processes_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             processes_actions[i]);
+        gtk_action_set_sensitive(action, processes_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(selected_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             selected_actions[i]);
+        gtk_action_set_sensitive(action, selected_sensitivity);
+    }
+}
+
+void
+block_priority_changed_handlers(ProcData *data, bool block)
+{
+    gint i;
+    if (block) {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_block_by_func(action, (gpointer)cb_renice, data);
+        }
+    } else {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_unblock_by_func(action, (gpointer)cb_renice, data);
+        }
+    }
+}
+
+static void
+cb_toggle_tree (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GSettings *settings = procdata->settings;
+    gboolean show;
+
+    show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+    if (show == procdata->config.show_tree)
+        return;
+
+    g_settings_set_boolean (settings, "show-tree", show);
+}
+
+static void
+cb_proc_goto_tab (gint tab)
+{
+    ProcData *data = ProcData::get_instance ();
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (data->notebook), tab);
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/7.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/7.html new file mode 100644 index 00000000..8b385037 --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/7.html @@ -0,0 +1,1939 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
#include <config.h>
+
+#include <gdkmm/pixbuf.h>
+
+#include <stdio.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <signal.h>
+#include <dirent.h>
+#include <string.h>
+#include <time.h>
+
+#include <glib/gi18n.h>
+
+#include <glibtop.h>
+#include <glibtop/cpu.h>
+#include <glibtop/mem.h>
+#include <glibtop/swap.h>
+#include <glibtop/netload.h>
+#include <glibtop/netlist.h>
+#include <math.h>
+
+#include <algorithm>
+
+#include "procman.h"
+#include "load-graph.h"
+#include "util.h"
+#include "gsm_color_button.h"
+
+void LoadGraph::clear_background()
+{
+    if (background) {
+        cairo_pattern_destroy (background);
+        this->background = NULL;
+    }
+}
+
+
+unsigned LoadGraph::num_bars() const
+{
+    unsigned n;<--- Shadow variable
+
+    // keep 100 % num_bars == 0
+    switch (static_cast<int>(this->draw_height / (fontsize + 14)))
+    {
+    case 0:
+    case 1:
+        n = 1;
+        break;
+    case 2:
+    case 3:
+        n = 2;
+        break;
+    case 4:
+        n = 4;
+        break;
+    default:
+        n = 5;
+    }
+
+    return n;
+}
+
+
+
+#define FRAME_WIDTH 4
+static void draw_background(LoadGraph *graph) {
+    GtkAllocation allocation;
+    cairo_t *cr;
+    guint i;<--- Shadowed declaration
+    unsigned num_bars;
+    g_autofree gchar *caption;
+    PangoLayout* layout;
+    PangoFontDescription* font_desc;
+    PangoRectangle extents;
+    cairo_surface_t *surface;
+    GdkRGBA fg, bg;
+
+    num_bars = graph->num_bars();
+    graph->graph_dely = (graph->draw_height - 15) / num_bars; /* round to int to avoid AA blur */
+    graph->real_draw_height = graph->graph_dely * num_bars;
+    graph->graph_delx = (graph->draw_width - 2.0 - graph->rmargin - graph->indent) / (LoadGraph::NUM_POINTS - 3);
+    graph->graph_buffer_offset = (int) (1.5 * graph->graph_delx) + FRAME_WIDTH ;
+
+    gtk_widget_get_allocation (graph->disp, &allocation);
+    surface = gdk_window_create_similar_surface (gtk_widget_get_window (graph->disp), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height);
+    cr = cairo_create (surface);
+
+    GtkStyleContext *context = gtk_widget_get_style_context (ProcData::get_instance()->notebook);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get_background_color (context, gtk_style_context_get_state (context), &bg);
+    gtk_style_context_get_color (context, gtk_style_context_get_state (context), &fg);
+    gtk_style_context_restore (context);
+
+    // set the background color
+    gdk_cairo_set_source_rgba (cr, &bg);
+    cairo_paint (cr);
+
+    layout = pango_cairo_create_layout (cr);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get (context,
+                           gtk_style_context_get_state (context),
+                           GTK_STYLE_PROPERTY_FONT,
+                           &font_desc, NULL);
+    gtk_style_context_restore (context);
+    pango_font_description_set_size (font_desc, 0.8 * graph->fontsize * PANGO_SCALE);
+    pango_layout_set_font_description (layout, font_desc);
+    pango_font_description_free (font_desc);
+
+    /* draw frame */
+    cairo_translate (cr, FRAME_WIDTH, FRAME_WIDTH);
+
+    /* Draw background rectangle */
+    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+    cairo_rectangle (cr, graph->rmargin + graph->indent, 0,
+                     graph->draw_width - graph->rmargin - graph->indent, graph->real_draw_height);
+    cairo_fill(cr);
+
+    cairo_set_line_width (cr, 1.0);
+    cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    for (i = 0; i <= num_bars; ++i) {
+        double y;
+
+        if (i == 0)
+            y = 0.5 + graph->fontsize / 2.0;
+        else if (i == num_bars)
+            y = i * graph->graph_dely + 0.5;
+        else
+            y = i * graph->graph_dely + graph->fontsize / 2.0;
+
+        gdk_cairo_set_source_rgba (cr, &fg);
+        if (graph->type == LOAD_GRAPH_NET) {
+            // operation orders matters so it's 0 if i == num_bars
+            guint64 rate = graph->net.max - (i * graph->net.max / num_bars);
+            caption = g_format_size_full (network_in_bits ? rate*8 : rate, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        } else {
+            // operation orders matters so it's 0 if i == num_bars
+            caption = g_strdup_printf("%d%%", 100 - i * (100 / num_bars));
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        }
+
+        if (i==0 || i==num_bars)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, graph->rmargin + graph->indent - 3, i * graph->graph_dely + 0.5);
+        cairo_line_to (cr, graph->draw_width - 0.5, i * graph->graph_dely + 0.5);
+        cairo_stroke (cr);
+    }
+
+    const unsigned total_seconds = graph->speed * (LoadGraph::NUM_POINTS - 2) / 1000;
+
+    for (unsigned int i = 0; i < 7; i++) {<--- Shadow variable
+        double x = (i) * (graph->draw_width - graph->rmargin - graph->indent) / 6;
+        if (i==0 || i==6)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, 0.5);
+        cairo_line_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, graph->real_draw_height + 4.5);
+        cairo_stroke(cr);
+        unsigned seconds = total_seconds - i * total_seconds / 6;
+        const char* format;
+        if (i == 0)
+            format = dngettext(GETTEXT_PACKAGE, "%u second", "%u seconds", seconds);
+        else
+            format = "%u";
+        caption = g_strdup_printf(format, seconds);
+        pango_layout_set_text (layout, caption, -1);
+        pango_layout_get_extents (layout, NULL, &extents);
+        cairo_move_to (cr, ((ceil(x) + 0.5) + graph->rmargin + graph->indent) - (1.0 * extents.width / PANGO_SCALE/2), graph->draw_height - 1.0 * extents.height / PANGO_SCALE);
+        gdk_cairo_set_source_rgba (cr, &fg);
+        pango_cairo_show_layout (cr, layout);
+    }
+    g_object_unref(layout);
+    cairo_stroke (cr);
+    cairo_destroy (cr);
+    graph->background = cairo_pattern_create_for_surface (surface);
+    cairo_surface_destroy (surface);
+}
+
+/* Redraws the backing buffer for the load graph and updates the window */
+void
+load_graph_queue_draw (LoadGraph *graph)
+{
+    /* repaint */
+    gtk_widget_queue_draw (graph->disp);
+}
+
+static int load_graph_update (gpointer user_data); // predeclare load_graph_update so we can compile ;)
+
+static gboolean
+load_graph_configure (GtkWidget *widget,
+                      GdkEventConfigure *event,
+                      gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    gtk_widget_get_allocation (widget, &allocation);
+    graph->draw_width = allocation.width - 2 * FRAME_WIDTH;
+    graph->draw_height = allocation.height - 2 * FRAME_WIDTH;
+
+    graph->clear_background();
+
+    load_graph_queue_draw (graph);
+
+    return TRUE;
+}
+
+static gboolean load_graph_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+    GdkWindow *window;
+
+    guint i, j;
+    gdouble sample_width, x_offset;
+
+    window = gtk_widget_get_window (graph->disp);
+
+    /* Number of pixels wide for one graph point */
+    sample_width = (float)(graph->draw_width - graph->rmargin - graph->indent) / (float)LoadGraph::NUM_POINTS;
+    /* General offset */
+    x_offset = graph->draw_width - graph->rmargin + (sample_width*2);
+
+    /* Subframe offset */
+    x_offset += graph->rmargin - ((sample_width / graph->frames_per_unit) * graph->render_counter);
+
+    /* draw the graph */
+    cairo_t* cr;
+
+    cr = gdk_cairo_create (window);
+
+    if (graph->background == NULL) {
+        draw_background(graph);
+    }
+    cairo_set_source (cr, graph->background);
+    cairo_paint (cr);
+
+    cairo_set_line_width (cr, 1);
+    cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+    cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+    cairo_rectangle (cr, graph->rmargin + graph->indent + FRAME_WIDTH + 1, FRAME_WIDTH - 1,
+             graph->draw_width - graph->rmargin - graph->indent - 1, graph->real_draw_height + FRAME_WIDTH - 1);
+    cairo_clip(cr);
+
+    for (j = 0; j < graph->n; ++j) {
+        cairo_move_to (cr, x_offset, (1.0f - graph->data[0][j]) * graph->real_draw_height);
+        gdk_cairo_set_source_rgba (cr, &(graph->colors [j]));
+
+        for (i = 1; i < LoadGraph::NUM_POINTS; ++i) {
+            if (graph->data[i][j] == -1.0f)
+                continue;
+            cairo_curve_to (cr,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i-1][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - (i * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f);
+        }
+        cairo_stroke (cr);
+
+    }
+
+    cairo_destroy (cr);
+
+    return TRUE;
+}
+
+static void
+get_load (LoadGraph *graph)
+{
+    guint i;
+    glibtop_cpu cpu;
+
+    glibtop_get_cpu (&cpu);
+
+#undef NOW
+#undef LAST
+#define NOW  (graph->cpu.times[graph->cpu.now])
+#define LAST (graph->cpu.times[graph->cpu.now ^ 1])
+
+    if (graph->n == 1) {
+        NOW[0][CPU_TOTAL] = cpu.total;
+        NOW[0][CPU_USED] = cpu.user + cpu.nice + cpu.sys;
+    } else {
+        for (i = 0; i < graph->n; i++) {
+            NOW[i][CPU_TOTAL] = cpu.xcpu_total[i];
+            NOW[i][CPU_USED] = cpu.xcpu_user[i] + cpu.xcpu_nice[i]
+                + cpu.xcpu_sys[i];
+        }
+    }
+
+    // on the first call, LAST is 0
+    // which means data is set to the average load since boot
+    // that value has no meaning, we just want all the
+    // graphs to be aligned, so the CPU graph needs to start
+    // immediately
+
+    for (i = 0; i < graph->n; i++) {
+        float load;
+        float total, used;
+        gchar *text;
+
+        total = NOW[i][CPU_TOTAL] - LAST[i][CPU_TOTAL];
+        used  = NOW[i][CPU_USED]  - LAST[i][CPU_USED];
+
+        load = used / MAX(total, 1.0f);
+        graph->data[0][i] = load;
+
+        /* Update label */
+        text = g_strdup_printf("%.1f%%", load * 100.0f);
+        gtk_label_set_text(GTK_LABEL(graph->labels.cpu[i]), text);
+        g_free(text);
+    }
+
+    graph->cpu.now ^= 1;
+
+#undef NOW
+#undef LAST
+}
+
+
+namespace
+{
+
+    void set_memory_label_and_picker(GtkLabel* label, GSMColorButton* picker,
+                                   guint64 used, guint64 total, double percent)
+    {
+        char* used_text;
+        char* total_text;
+        char* text;
+
+        used_text = g_format_size_full(used, G_FORMAT_SIZE_IEC_UNITS);
+        total_text = g_format_size_full(total, G_FORMAT_SIZE_IEC_UNITS);
+        if (total == 0) {
+            text = g_strdup(_("not available"));
+        } else {
+            // xgettext: 540MiB (53 %) of 1.0 GiB
+            text = g_strdup_printf(_("%s (%.1f%%) of %s"), used_text, 100.0 * percent, total_text);
+        }
+        gtk_label_set_text(label, text);
+        g_free(used_text);
+        g_free(total_text);
+        g_free(text);
+
+        if (picker)
+            gsm_color_button_set_fraction(picker, percent);
+    }
+}
+
+static void
+get_memory (LoadGraph *graph)
+{
+    float mempercent, swappercent;
+
+    glibtop_mem mem;
+    glibtop_swap swap;
+
+    glibtop_get_mem (&mem);
+    glibtop_get_swap (&swap);
+
+    /* There's no swap on LiveCD : 0.0f is better than NaN :) */
+    swappercent = (swap.total ? (float)swap.used / (float)swap.total : 0.0f);
+    mempercent  = (float)mem.user  / (float)mem.total;
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.memory),
+                                GSM_COLOR_BUTTON(graph->mem_color_picker),
+                                mem.user, mem.total, mempercent);
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.swap),
+                                GSM_COLOR_BUTTON(graph->swap_color_picker),
+                                swap.used, swap.total, swappercent);
+
+    graph->data[0][0] = mempercent;
+    graph->data[0][1] = swappercent;
+}
+
+/* Nice Numbers for Graph Labels after Paul Heckbert
+   nicenum: find a "nice" number approximately equal to x.
+   Round the number if round=1, take ceiling if round=0    */
+
+static double
+nicenum (double x, int round)
+{
+    int expv;				/* exponent of x */
+    double f;				/* fractional part of x */
+    double nf;				/* nice, rounded fraction */
+
+    expv = floor( log10(x) );
+    f = x/pow( 10.0, expv );		/* between 1 and 10 */
+    if (round) {
+        if ( f < 1.5 ) nf = 1.0;
+        else if ( f < 3.0 ) nf = 2.0;
+        else if ( f < 7.0 ) nf = 5.0;
+        else nf = 10.0;
+    } else {
+        if ( f <= 1.0 ) nf = 1.0;
+        else if ( f <= 2.0 ) nf = 2.0;
+        else if ( f <= 5.0 ) nf = 5.0;
+        else nf = 10.0;
+    }
+    return nf * pow(10.0, expv);
+}
+
+static void
+net_scale (LoadGraph *graph, guint64 din, guint64 dout)
+{
+    graph->data[0][0] = 1.0f * din / graph->net.max;
+    graph->data[0][1] = 1.0f * dout / graph->net.max;
+
+    guint64 dmax = std::max(din, dout);
+    graph->net.values[graph->net.cur] = dmax;
+    graph->net.cur = (graph->net.cur + 1) % LoadGraph::NUM_POINTS;
+
+    guint64 new_max;
+    // both way, new_max is the greatest value
+    if (dmax >= graph->net.max)
+        new_max = dmax;
+    else
+        new_max = *std::max_element(&graph->net.values[0],
+                                    &graph->net.values[LoadGraph::NUM_POINTS]);
+
+    //
+    // Round network maximum
+    //
+
+    const guint64 bak_max(new_max);
+
+    if (ProcData::get_instance()->config.network_in_bits) {
+        // nice number is for the ticks
+        unsigned ticks = graph->num_bars();
+
+        // gets messy at low values due to division by 8
+        guint64 bit_max = std::max( new_max*8, G_GUINT64_CONSTANT(10000) );
+
+        // our tick size leads to max
+        double d = nicenum(bit_max/ticks, 0);
+        bit_max = ticks * d;
+        new_max = bit_max / 8;
+
+        procman_debug("bak*8 %" G_GUINT64_FORMAT ", ticks %d, d %f"
+                      ", bit_max %" G_GUINT64_FORMAT ", new_max %" G_GUINT64_FORMAT,
+                      bak_max*8, ticks, d, bit_max, new_max );
+    } else {
+        // round up to get some extra space
+        // yes, it can overflow
+        new_max = 1.1 * new_max;
+        // make sure max is not 0 to avoid / 0
+        // default to 1 KiB
+        new_max = std::max(new_max, G_GUINT64_CONSTANT(1024));
+
+        // decompose new_max = coef10 * 2**(base10 * 10)
+        // where coef10 and base10 are integers and coef10 < 2**10
+        //
+        // e.g: ceil(100.5 KiB) = 101 KiB = 101 * 2**(1 * 10)
+        //      where base10 = 1, coef10 = 101, pow2 = 16
+
+        guint64 pow2 = std::floor(log2(new_max));
+        guint64 base10 = pow2 / 10.0;
+        guint64 coef10 = std::ceil(new_max / double(G_GUINT64_CONSTANT(1) << (base10 * 10)));
+        g_assert(new_max <= (coef10 * (G_GUINT64_CONSTANT(1) << (base10 * 10))));
+
+        // then decompose coef10 = x * 10**factor10
+        // where factor10 is integer and x < 10
+        // so we new_max has only 1 significant digit
+
+        guint64 factor10 = std::pow(10.0, std::floor(std::log10(coef10)));
+        coef10 = std::ceil(coef10 / double(factor10)) * factor10;
+
+        // then make coef10 divisible by num_bars
+        if (coef10 % graph->num_bars() != 0)
+            coef10 = coef10 + (graph->num_bars() - coef10 % graph->num_bars());
+        g_assert(coef10 % graph->num_bars() == 0);
+        new_max = coef10 * (G_GUINT64_CONSTANT(1) << guint64(base10 * 10));
+        procman_debug("bak %" G_GUINT64_FORMAT " new_max %" G_GUINT64_FORMAT
+                      "pow2 %" G_GUINT64_FORMAT " coef10 %" G_GUINT64_FORMAT,
+                      bak_max, new_max, pow2, coef10);
+    }
+
+    if (bak_max > new_max) {
+        procman_debug("overflow detected: bak=%" G_GUINT64_FORMAT
+                      " new=%" G_GUINT64_FORMAT,
+                      bak_max, new_max);
+        new_max = bak_max;
+    }
+
+    // if max is the same or has decreased but not so much, don't
+    // do anything to avoid rescaling
+    if ((0.8 * graph->net.max) < new_max && new_max <= graph->net.max)
+        return;
+
+    const double scale = 1.0f * graph->net.max / new_max;
+
+    for (size_t i = 0; i < LoadGraph::NUM_POINTS; i++) {
+        if (graph->data[i][0] >= 0.0f) {
+            graph->data[i][0] *= scale;
+            graph->data[i][1] *= scale;
+        }
+    }
+
+    procman_debug("rescale dmax = %" G_GUINT64_FORMAT
+                  " max = %" G_GUINT64_FORMAT
+                  " new_max = %" G_GUINT64_FORMAT,
+                  dmax, graph->net.max, new_max);
+
+    graph->net.max = new_max;
+
+    // force the graph background to be redrawn now that scale has changed
+    graph->clear_background();
+}
+
+static void
+get_net (LoadGraph *graph)
+{
+    glibtop_netlist netlist;
+    char **ifnames;
+    guint32 i;
+    guint64 in = 0, out = 0;
+#if GLIB_CHECK_VERSION(2,61,2)
+    gint64 time;
+#else
+    GTimeVal time;
+#endif
+    guint64 din, dout;
+
+    ifnames = glibtop_get_netlist(&netlist);
+
+    for (i = 0; i < netlist.number; ++i)
+    {
+        glibtop_netload netload;
+        glibtop_get_netload (&netload, ifnames[i]);
+
+        if (netload.if_flags & (1 << GLIBTOP_IF_FLAGS_LOOPBACK))
+            continue;
+
+        /* Skip interfaces without any IPv4/IPv6 address (or
+         those with only a LINK ipv6 addr) However we need to
+         be able to exclude these while still keeping the
+         value so when they get online (with NetworkManager
+         for example) we don't get a suddent peak.  Once we're
+         able to get this, ignoring down interfaces will be
+         possible too.  */
+        if (not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS6)
+             and netload.scope6 != GLIBTOP_IF_IN6_SCOPE_LINK)
+            and not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS)))
+            continue;
+
+        /* Don't skip interfaces that are down (GLIBTOP_IF_FLAGS_UP)
+           to avoid spikes when they are brought up */
+
+        in  += netload.bytes_in;
+        out += netload.bytes_out;
+    }
+
+    g_strfreev(ifnames);
+
+#if GLIB_CHECK_VERSION(2,61,2)
+    time = g_get_real_time ();
+
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time != 0) {
+        float dtime = (double) (time - graph->net.time) / G_USEC_PER_SEC;
+#else
+    g_get_current_time (&time);
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time.tv_sec != 0) {
+        float dtime;
+        dtime = time.tv_sec - graph->net.time.tv_sec +
+            (double) (time.tv_usec - graph->net.time.tv_usec) / G_USEC_PER_SEC;
+#endif
+        din   = static_cast<guint64>((in  - graph->net.last_in)  / dtime);
+        dout  = static_cast<guint64>((out - graph->net.last_out) / dtime);
+    } else {
+        /* Don't calc anything if new data is less than old (interface
+           removed, counters reset, ...) or if it is the first time */
+        din  = 0;
+        dout = 0;
+    }
+
+    graph->net.last_in  = in;
+    graph->net.last_out = out;
+    graph->net.time     = time;
+
+    net_scale(graph, din, dout);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    g_autofree gchar *str=NULL, *formatted_str=NULL;
+
+    str = g_format_size_full (network_in_bits ? din*8 : din, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? in*8 : in, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in_total), str);
+
+    str = g_format_size_full (network_in_bits ? dout*8 : dout, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? out*8 : out, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out_total), str);
+}
+
+
+/* Updates the load graph when the timeout expires */
+static gboolean
+load_graph_update (gpointer user_data)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(user_data);
+
+    if (graph->render_counter == graph->frames_per_unit - 1) {
+        std::rotate(&graph->data[0], &graph->data[LoadGraph::NUM_POINTS - 1], &graph->data[LoadGraph::NUM_POINTS]);
+
+        switch (graph->type) {
+        case LOAD_GRAPH_CPU:
+            get_load(graph);
+            break;
+        case LOAD_GRAPH_MEM:
+            get_memory(graph);
+            break;
+        case LOAD_GRAPH_NET:
+            get_net(graph);
+            break;
+        default:
+            g_assert_not_reached();
+        }
+    }
+
+    if (graph->draw)
+        load_graph_queue_draw (graph);
+
+    graph->render_counter++;
+
+    if (graph->render_counter >= graph->frames_per_unit)
+        graph->render_counter = 0;
+
+    return TRUE;
+}
+
+
+
+LoadGraph::~LoadGraph()
+{
+  load_graph_stop(this);
+
+  if (timer_index)
+    g_source_remove(timer_index);
+
+  clear_background();
+}
+
+
+
+static gboolean
+load_graph_destroy (GtkWidget *widget, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    delete graph;
+
+    return FALSE;
+}
+
+
+LoadGraph::LoadGraph(guint type)
+  : fontsize(8.0),
+    rmargin(3.5 * fontsize),
+    indent(24.0),
+    n(0),
+    type(type),
+    speed(0),
+    draw_width(0),
+    draw_height(0),
+    render_counter(0),
+    frames_per_unit(10), // this will be changed but needs initialising
+    graph_dely(0),
+    real_draw_height(0),
+    graph_delx(0.0),
+    graph_buffer_offset(0),
+    main_widget(NULL),
+    disp(NULL),
+    background(NULL),
+    timer_index(0),
+    draw(FALSE),
+    mem_color_picker(NULL),
+    swap_color_picker(NULL)
+{
+    LoadGraph * const graph = this;
+
+    // FIXME:
+    // on configure, graph->frames_per_unit = graph->draw_width/(LoadGraph::NUM_POINTS);
+    // knock FRAMES down to 5 until cairo gets faster
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memset(&cpu, 0, sizeof cpu);
+        n = ProcData::get_instance()->config.num_cpus;
+
+        for(guint i = 0; i < G_N_ELEMENTS(labels.cpu); ++i)
+            labels.cpu[i] = gtk_label_new(NULL);
+
+        break;
+
+    case LOAD_GRAPH_MEM:
+        n = 2;
+        labels.memory = gtk_label_new(NULL);
+        labels.swap = gtk_label_new(NULL);
+        break;
+
+    case LOAD_GRAPH_NET:
+        memset(&net, 0, sizeof net);
+        n = 2;
+        net.max = 1;
+        labels.net_in = gtk_label_new(NULL);
+        labels.net_in_total = gtk_label_new(NULL);
+        labels.net_out = gtk_label_new(NULL);
+        labels.net_out_total = gtk_label_new(NULL);
+        break;
+    }
+
+    speed  = ProcData::get_instance()->config.graph_update_interval;
+
+    colors.resize(n);
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memcpy(&colors[0], ProcData::get_instance()->config.cpu_color,
+               n * sizeof colors[0]);
+        break;
+    case LOAD_GRAPH_MEM:
+        colors[0] = ProcData::get_instance()->config.mem_color;
+        colors[1] = ProcData::get_instance()->config.swap_color;
+        mem_color_picker = gsm_color_button_new (&colors[0],
+                                                 GSMCP_TYPE_PIE);
+        swap_color_picker = gsm_color_button_new (&colors[1],
+                                                  GSMCP_TYPE_PIE);
+        break;
+    case LOAD_GRAPH_NET:
+        colors[0] = ProcData::get_instance()->config.net_in_color;
+        colors[1] = ProcData::get_instance()->config.net_out_color;
+        break;
+    }
+
+    timer_index = 0;
+    render_counter = (frames_per_unit - 1);
+    draw = FALSE;
+
+    main_widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+    gtk_widget_set_size_request(main_widget, -1, LoadGraph::GRAPH_MIN_HEIGHT);
+    gtk_widget_show (main_widget);
+
+    disp = gtk_drawing_area_new ();
+    gtk_widget_show (disp);
+    g_signal_connect (G_OBJECT (disp), "draw", G_CALLBACK (load_graph_draw), graph);
+    g_signal_connect (G_OBJECT(disp), "configure_event",
+                      G_CALLBACK (load_graph_configure), graph);
+    g_signal_connect (G_OBJECT(disp), "destroy",
+                      G_CALLBACK (load_graph_destroy), graph);
+
+    gtk_widget_set_events (disp, GDK_EXPOSURE_MASK);
+
+    gtk_box_pack_start (GTK_BOX (main_widget), disp, TRUE, TRUE, 0);
+
+
+    /* Allocate data in a contiguous block */
+    data_block = std::vector<float>(n * LoadGraph::NUM_POINTS, -1.0f);
+
+    for (guint i = 0; i < LoadGraph::NUM_POINTS; ++i)
+        data[i] = &data_block[0] + i * n;
+
+    gtk_widget_show_all (main_widget);
+}
+
+void
+load_graph_start (LoadGraph *graph)
+{
+    if(!graph->timer_index) {
+
+        load_graph_update(graph);
+
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->draw = TRUE;
+}
+
+void
+load_graph_stop (LoadGraph *graph)
+{
+    /* don't draw anymore, but continue to poll */
+    graph->draw = FALSE;
+}
+
+void
+load_graph_change_speed (LoadGraph *graph,
+             guint new_speed)
+{
+    if (graph->speed == new_speed)
+        return;
+
+    graph->speed = new_speed;
+
+    if(graph->timer_index) {
+        g_source_remove (graph->timer_index);
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->clear_background();
+}
+
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *graph)
+{
+    return &graph->labels;
+}
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *graph)
+{
+    return graph->main_widget;
+}
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *graph)
+{
+    return graph->mem_color_picker;
+}
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *graph)
+{
+    return graph->swap_color_picker;
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/8.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/8.html new file mode 100644 index 00000000..6bd78123 --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/8.html @@ -0,0 +1,1075 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
#include <config.h>
+
+#include <gtkmm/messagedialog.h>
+#include <glibmm/regex.h>
+#include <glib/gi18n.h>
+#include <glibtop/procopenfiles.h>
+
+#include <sys/wait.h>
+
+#include <set>
+#include <string>
+#include <sstream>
+#include <iterator>
+
+#include <glibmm/regex.h>
+
+#include "procman.h"
+#include "lsof.h"
+#include "util.h"
+
+
+using std::string;
+
+
+namespace
+{
+
+    class Lsof
+    {
+        Glib::RefPtr<Glib::Regex> re;
+
+        bool matches(const string &filename) const
+        {
+            return this->re->match(filename);
+        }
+
+    public:
+
+        Lsof(const string &pattern, bool caseless)
+        {
+            Glib::RegexCompileFlags flags = static_cast<Glib::RegexCompileFlags>(0);
+
+            if (caseless)
+                flags |= Glib::REGEX_CASELESS;
+
+            this->re = Glib::Regex::create(pattern, flags);
+        }
+
+
+        template<typename OutputIterator>
+        void search(const ProcInfo &info, OutputIterator out) const
+        {
+            glibtop_open_files_entry *entries;
+            glibtop_proc_open_files buf;
+
+            entries = glibtop_get_proc_open_files(&buf, info.pid);
+
+            for (unsigned i = 0; i != buf.number; ++i) {
+                if (entries[i].type & GLIBTOP_FILE_TYPE_FILE) {
+                    const string filename(entries[i].info.file.name);
+                    if (this->matches(filename))
+                        *out++ = filename;
+                }
+            }
+
+            g_free(entries);
+        }
+    };
+
+
+
+    // GUI Stuff
+
+
+    enum ProcmanLsof {
+        PROCMAN_LSOF_COL_SURFACE,
+        PROCMAN_LSOF_COL_PROCESS,
+        PROCMAN_LSOF_COL_PID,
+        PROCMAN_LSOF_COL_FILENAME,
+        PROCMAN_LSOF_NCOLS
+    };
+
+
+    struct GUI {
+
+        GtkListStore *model;
+        GtkEntry *entry;
+        GtkWindow *window;
+        GtkLabel *count;<--- Shadowed declaration
+        ProcData *procdata;
+        bool case_insensitive;
+
+
+        GUI()
+        {
+            procman_debug("New Lsof GUI %p", this);
+        }
+
+
+        ~GUI()
+        {
+            procman_debug("Destroying Lsof GUI %p", this);
+        }
+
+
+        void clear_results()
+        {
+            gtk_list_store_clear(this->model);
+            gtk_label_set_text(this->count, "");
+        }
+
+
+        void clear()
+        {
+            this->clear_results();
+            gtk_entry_set_text(this->entry, "");
+        }
+
+
+        void display_regex_error(const Glib::RegexError& error)
+        {
+            char * msg = g_strdup_printf ("<b>%s</b>\n%s\n%s",
+                                          _("Error"),
+                                          _("'%s' is not a valid Perl regular expression."),
+                                          "%s");
+            std::string message = make_string(g_strdup_printf(msg, this->pattern().c_str(), error.what().c_str()));
+            g_free(msg);
+
+            Gtk::MessageDialog dialog(message,
+                                      true, // use markup
+                                      Gtk::MESSAGE_ERROR,
+                                      Gtk::BUTTONS_OK,
+                                      true); // modal
+            dialog.run();
+        }
+
+
+        void update_count(unsigned count)
+        {
+            std::ostringstream ss;
+            ss << count;
+            string s = ss.str();
+            gtk_label_set_text(this->count, s.c_str());
+        }
+
+
+        string pattern() const
+        {
+            return gtk_entry_get_text(this->entry);
+        }
+
+
+        void search()
+        {
+            typedef std::set<string> MatchSet;
+            typedef MatchSet::const_iterator iterator;
+
+            this->clear_results();
+
+
+            try {
+                Lsof lsof(this->pattern(), this->case_insensitive);
+
+                unsigned count = 0;<--- Shadow variable
+
+                for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it) {
+                    const ProcInfo &info(*it->second);
+
+                    MatchSet matches;
+                    lsof.search(info, std::inserter(matches, matches.begin()));
+                    count += matches.size();
+
+                    for (iterator it(matches.begin()), end(matches.end()); it != end; ++it) {
+                        GtkTreeIter file;
+                        gtk_list_store_append(this->model, &file);
+                        gtk_list_store_set(this->model, &file,
+                                           PROCMAN_LSOF_COL_SURFACE, info.surface,
+                                           PROCMAN_LSOF_COL_PROCESS, info.name,
+                                           PROCMAN_LSOF_COL_PID, info.pid,
+                                           PROCMAN_LSOF_COL_FILENAME, it->c_str(),
+                                           -1);
+                    }
+                }
+
+                this->update_count(count);
+            }
+            catch (Glib::RegexError& error) {
+                this->display_regex_error(error);
+            }
+        }
+
+
+        static void search_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void search_entry_activate(GtkEntry *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void clear_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->clear();
+        }
+
+
+        static void close_button_clicked(GtkButton *, gpointer data)
+        {
+            GUI *gui = static_cast<GUI*>(data);
+            gtk_widget_destroy(GTK_WIDGET(gui->window));
+            delete gui;
+        }
+
+
+        static void case_button_toggled(GtkToggleButton *button, gpointer data)
+        {
+            bool state = gtk_toggle_button_get_active(button);
+            static_cast<GUI*>(data)->case_insensitive = state;
+        }
+
+
+        static gboolean window_delete_event(GtkWidget *, GdkEvent *, gpointer data)
+        {
+            delete static_cast<GUI*>(data);
+            return FALSE;
+        }
+
+    };
+}
+
+
+
+
+void procman_lsof(ProcData *procdata)
+{
+    GtkListStore *model = \
+        gtk_list_store_new(PROCMAN_LSOF_NCOLS,
+                           CAIRO_GOBJECT_TYPE_SURFACE, // PROCMAN_LSOF_COL_SURFACE
+                           G_TYPE_STRING,              // PROCMAN_LSOF_COL_PROCESS
+                           G_TYPE_UINT,                // PROCMAN_LSOF_COL_PID
+                           G_TYPE_STRING               // PROCMAN_LSOF_COL_FILENAME
+        );
+
+    GtkWidget *tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_object_unref(model);
+
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *renderer;
+
+    // SURFACE / PROCESS
+
+    column = gtk_tree_view_column_new();
+
+    renderer = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "surface", PROCMAN_LSOF_COL_SURFACE,
+                                        NULL);
+
+    renderer = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "text", PROCMAN_LSOF_COL_PROCESS,
+                                        NULL);
+
+    gtk_tree_view_column_set_title(column, _("Process"));
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PROCESS);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_column_set_min_width(column, 10);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), PROCMAN_LSOF_COL_PROCESS,
+                                         GTK_SORT_ASCENDING);
+
+
+    // PID
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("PID"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_PID,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PID);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    // FILENAME
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("Filename"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_FILENAME,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_FILENAME);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    GtkWidget *dialog; /* = gtk_dialog_new_with_buttons(_("Search for Open Files"), NULL,
+                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+                                                        NULL); */
+    dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(procdata->app));
+    gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
+    // gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_title(GTK_WINDOW(dialog), _("Search for Open Files"));
+
+    // g_signal_connect(G_OBJECT(dialog), "response",
+    //                           G_CALLBACK(close_dialog), NULL);
+    gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(dialog), 575, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(dialog), 12);
+    GtkWidget *mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_add(GTK_CONTAINER(dialog), mainbox);
+    gtk_box_set_spacing(GTK_BOX(mainbox), 6);
+
+
+    // Label, entry and search button
+
+    GtkWidget *hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), hbox1, FALSE, FALSE, 0);
+
+    GtkWidget *image = gtk_image_new_from_icon_name("edit-find", GTK_ICON_SIZE_DIALOG);
+    gtk_box_pack_start(GTK_BOX(hbox1), image, FALSE, FALSE, 0);
+
+
+    GtkWidget *vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox1), vbox2, TRUE, TRUE, 0);
+
+
+    GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox, TRUE, TRUE, 0);
+    GtkWidget *label = gtk_label_new_with_mnemonic(_("_Name contains:"));
+    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+    GtkWidget *entry = gtk_entry_new();
+
+    gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
+
+    GtkWidget *search_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                         "label", "gtk-find",
+                                                         "use-stock", TRUE,
+                                                         "use-underline", TRUE,
+                                                         NULL));
+
+    gtk_box_pack_start(GTK_BOX(hbox), search_button, FALSE, FALSE, 0);
+
+    GtkWidget *clear_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-clear",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    /* The default accelerator collides with the default close accelerator. */
+    gtk_button_set_label(GTK_BUTTON(clear_button), _("C_lear"));
+    gtk_box_pack_start(GTK_BOX(hbox), clear_button, FALSE, FALSE, 0);
+
+
+    GtkWidget *case_button = gtk_check_button_new_with_mnemonic(_("Case insensitive matching"));
+    GtkWidget *hbox3 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox3), case_button, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox3, FALSE, FALSE, 0);
+
+
+    GtkWidget *results_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), results_box, FALSE, FALSE, 0);
+    GtkWidget *results_label = gtk_label_new_with_mnemonic(_("S_earch results:"));
+    gtk_box_pack_start(GTK_BOX(results_box), results_label, FALSE, FALSE, 0);
+    GtkWidget *count_label = gtk_label_new(NULL);
+    gtk_box_pack_end(GTK_BOX(results_box), count_label, FALSE, FALSE, 0);
+
+    // Scrolled TreeView
+    GtkWidget *scrolled = gtk_scrolled_window_new(NULL, NULL);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
+                                   GTK_POLICY_AUTOMATIC,
+                                   GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled),
+                                        GTK_SHADOW_IN);
+    gtk_container_add(GTK_CONTAINER(scrolled), tree);
+    gtk_box_pack_start(GTK_BOX(mainbox), scrolled, TRUE, TRUE, 0);
+
+    GtkWidget *bottom_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+
+    GtkWidget *close_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-close",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    gtk_box_pack_start(GTK_BOX(mainbox), bottom_box, FALSE, FALSE, 0);
+    gtk_box_pack_end(GTK_BOX(bottom_box), close_button, FALSE, FALSE, 0);
+
+
+    GUI *gui = new GUI; // wil be deleted by the close button or delete-event
+    gui->procdata = procdata;
+    gui->model = model;
+    gui->window = GTK_WINDOW(dialog);
+    gui->entry = GTK_ENTRY(entry);
+    gui->count = GTK_LABEL(count_label);
+
+    g_signal_connect(G_OBJECT(entry), "activate",
+                     G_CALLBACK(GUI::search_entry_activate), gui);
+    g_signal_connect(G_OBJECT(clear_button), "clicked",
+                     G_CALLBACK(GUI::clear_button_clicked), gui);
+    g_signal_connect(G_OBJECT(search_button), "clicked",
+                     G_CALLBACK(GUI::search_button_clicked), gui);
+    g_signal_connect(G_OBJECT(close_button), "clicked",
+                     G_CALLBACK(GUI::close_button_clicked), gui);
+    g_signal_connect(G_OBJECT(case_button), "toggled",
+                     G_CALLBACK(GUI::case_button_toggled), gui);
+    g_signal_connect(G_OBJECT(dialog), "delete-event",
+                     G_CALLBACK(GUI::window_delete_event), gui);
+
+
+    gtk_widget_show_all(dialog);
+}
+
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/9.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/9.html new file mode 100644 index 00000000..b1d95a0b --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/9.html @@ -0,0 +1,1197 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
#include <config.h>
+
+#include <glibtop/procmap.h>
+#include <glibtop/mountlist.h>
+#include <sys/stat.h>
+#include <glib/gi18n.h>
+
+#include <string>
+#include <map>
+#include <sstream>
+#include <iomanip>
+#include <stdexcept>
+
+using std::string;
+
+
+#include "procman.h"
+#include "memmaps.h"
+#include "proctable.h"
+#include "util.h"
+
+
+/* be careful with this enum, you could break the column names */
+enum
+{
+    MMAP_COL_FILENAME,
+    MMAP_COL_VMSTART,
+    MMAP_COL_VMEND,
+    MMAP_COL_VMSZ,
+    MMAP_COL_FLAGS,
+    MMAP_COL_VMOFFSET,
+    MMAP_COL_PRIVATE_CLEAN,
+    MMAP_COL_PRIVATE_DIRTY,
+    MMAP_COL_SHARED_CLEAN,
+    MMAP_COL_SHARED_DIRTY,
+    MMAP_COL_DEVICE,
+    MMAP_COL_INODE,
+    MMAP_COL_MAX
+};
+
+
+namespace
+{
+    class OffsetFormater
+    {
+        string format;
+
+    public:
+
+        void set(const glibtop_map_entry &last_map)
+        {
+            this->format = (last_map.end <= G_MAXUINT32) ? "%08" G_GINT64_MODIFIER "x" : "%016" G_GINT64_MODIFIER "x";
+        }
+
+        string operator()(guint64 v) const
+        {
+            char buffer[17];
+            g_snprintf(buffer, sizeof buffer, this->format.c_str(), v);
+            return buffer;
+        }
+    };
+
+
+    class InodeDevices
+    {
+        typedef std::map<guint16, string> Map;
+        Map devices;
+
+    public:
+
+        void update()
+        {
+            this->devices.clear();
+
+            glibtop_mountlist list;
+            glibtop_mountentry *entries = glibtop_get_mountlist(&list, 1);
+
+            for (unsigned i = 0; i != list.number; ++i) {
+                struct stat buf;
+
+                if (stat(entries[i].devname, &buf) != -1)
+                    this->devices[buf.st_rdev] = entries[i].devname;
+            }
+
+            g_free(entries);
+        }
+
+        string get(guint64 dev64)
+        {
+            if (dev64 == 0)
+                return "";
+
+            guint16 dev = dev64 & 0xffff;
+
+            if (dev != dev64)
+                g_warning("weird device %" G_GINT64_MODIFIER "x", dev64);
+
+            Map::iterator it(this->devices.find(dev));
+
+            if (it != this->devices.end())
+                return it->second;
+
+            guint8 major, minor;
+            major = dev >> 8;
+            minor = dev;
+
+            std::ostringstream out;
+            out << std::hex
+                << std::setfill('0')
+                << std::setw(2) << unsigned(major)
+                << ':'
+                << std::setw(2) << unsigned(minor);
+
+            this->devices[dev] = out.str();
+            return out.str();
+        }
+    };
+
+
+    class MemMapsData
+    {
+    public:
+        guint timer;
+        GtkWidget *tree;
+        GSettings *settings;
+        ProcInfo *info;
+        OffsetFormater format;
+        mutable InodeDevices devices;
+        const char * const schema;
+
+        MemMapsData(GtkWidget *a_tree, GSettings *a_settings)
+            : tree(a_tree),
+            settings(a_settings),
+            schema("memmapstree")
+        {
+            procman_get_tree_state(this->settings, this->tree, this->schema);
+        }
+
+        ~MemMapsData()
+        {
+            procman_save_tree_state(this->settings, this->tree, this->schema);
+        }
+    };
+}
+
+
+struct glibtop_map_entry_cmp
+{
+    bool operator()(const glibtop_map_entry &a, const guint64 start) const
+    {
+        return a.start < start;
+    }
+
+    bool operator()(const guint64 &start, const glibtop_map_entry &a) const
+    {
+        return start < a.start;
+    }
+
+};
+
+
+static void
+update_row(GtkTreeModel *model, GtkTreeIter &row, const MemMapsData &mm, const glibtop_map_entry *memmaps)
+{
+    guint64 size;
+    string filename, device;
+    string vmstart, vmend, vmoffset;
+    char flags[5] = "----";
+
+    size = memmaps->end - memmaps->start;
+
+    if(memmaps->perm & GLIBTOP_MAP_PERM_READ)    flags [0] = 'r';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_WRITE)   flags [1] = 'w';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_EXECUTE) flags [2] = 'x';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_SHARED)  flags [3] = 's';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_PRIVATE) flags [3] = 'p';
+
+    if (memmaps->flags & (1 << GLIBTOP_MAP_ENTRY_FILENAME))
+      filename = memmaps->filename;
+
+    vmstart  = mm.format(memmaps->start);
+    vmend    = mm.format(memmaps->end);
+    vmoffset = mm.format(memmaps->offset);
+    device   = mm.devices.get(memmaps->device);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        MMAP_COL_FILENAME, filename.c_str(),
+                        MMAP_COL_VMSTART, vmstart.c_str(),
+                        MMAP_COL_VMEND, vmend.c_str(),
+                        MMAP_COL_VMSZ, size,
+                        MMAP_COL_FLAGS, flags,
+                        MMAP_COL_VMOFFSET, vmoffset.c_str(),
+                        MMAP_COL_PRIVATE_CLEAN, memmaps->private_clean,
+                        MMAP_COL_PRIVATE_DIRTY, memmaps->private_dirty,
+                        MMAP_COL_SHARED_CLEAN, memmaps->shared_clean,
+                        MMAP_COL_SHARED_DIRTY, memmaps->shared_dirty,
+                        MMAP_COL_DEVICE, device.c_str(),
+                        MMAP_COL_INODE, memmaps->inode,
+                        -1);
+}
+
+
+
+
+static void
+update_memmaps_dialog (MemMapsData *mmdata)
+{
+    GtkTreeModel *model;
+    glibtop_map_entry *memmaps;
+    glibtop_proc_map procmap;
+
+    memmaps = glibtop_get_proc_map (&procmap, mmdata->info->pid);
+    /* process has disappeared */
+    if(!memmaps or procmap.number == 0) return;
+
+    mmdata->format.set(memmaps[procmap.number - 1]);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+
+    GtkTreeIter iter;<--- Shadowed declaration
+
+    typedef std::map<guint64, GtkTreeIter> IterCache;
+    IterCache iter_cache;
+
+    /*
+      removes the old maps and
+      also fills a cache of start -> iter in order to speed
+      up add
+    */
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        while (true) {
+            char *vmstart = 0;
+            guint64 start;
+            gtk_tree_model_get(model, &iter,
+                               MMAP_COL_VMSTART, &vmstart,
+                               -1);
+
+            try {
+                std::istringstream(vmstart) >> std::hex >> start;
+            } catch (std::logic_error &e) {
+                g_warning("Could not parse %s", vmstart);
+                start = 0;
+            }
+
+            g_free(vmstart);
+
+            bool found = std::binary_search(memmaps, memmaps + procmap.number,
+                                            start, glibtop_map_entry_cmp());
+
+            if (found) {
+                iter_cache[start] = iter;
+                if (!gtk_tree_model_iter_next(model, &iter))
+                    break;
+            } else {
+                if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                    break;
+            }
+        }
+    }
+
+    mmdata->devices.update();
+
+    /*
+      add the new maps
+    */
+
+    for (guint i = 0; i != procmap.number; i++) {
+        GtkTreeIter iter;<--- Shadow variable
+        IterCache::iterator it(iter_cache.find(memmaps[i].start));
+
+        if (it != iter_cache.end())
+            iter = it->second;
+        else
+            gtk_list_store_prepend(GTK_LIST_STORE(model), &iter);
+
+        update_row(model, iter, *mmdata, &memmaps[i]);
+    }
+
+    g_free (memmaps);
+}
+
+
+
+static void
+dialog_response (GtkDialog * dialog, gint response_id, gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+
+    g_source_remove (mmdata->timer);
+
+    delete mmdata;
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+
+static MemMapsData*
+create_memmapsdata (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Filename"),
+        // xgettext: virtual memory start
+        N_("VM Start"),
+        // xgettext: virtual memory end
+        N_("VM End"),
+        // xgettext: virtual memory syze
+        N_("VM Size"),
+        N_("Flags"),
+        // xgettext: virtual memory offset
+        N_("VM Offset"),
+        // xgettext: memory that has not been modified since
+        // it has been allocated
+        N_("Private clean"),
+        // xgettext: memory that has been modified since it
+        // has been allocated
+        N_("Private dirty"),
+        // xgettext: shared memory that has not been modified
+        // since it has been allocated
+        N_("Shared clean"),
+        // xgettext: shared memory that has been modified
+        // since it has been allocated
+        N_("Shared dirty"),
+        N_("Device"),
+        N_("Inode")
+    };
+
+    model = gtk_list_store_new (MMAP_COL_MAX,
+                                G_TYPE_STRING, /* MMAP_COL_FILENAME  */
+                                G_TYPE_STRING, /* MMAP_COL_VMSTART     */
+                                G_TYPE_STRING, /* MMAP_COL_VMEND     */
+                                G_TYPE_UINT64, /* MMAP_COL_VMSZ     */
+                                G_TYPE_STRING, /* MMAP_COL_FLAGS     */
+                                G_TYPE_STRING, /* MMAP_COL_VMOFFSET  */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_DIRTY */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_DIRTY */
+                                G_TYPE_STRING, /* MMAP_COL_DEVICE     */
+                                G_TYPE_UINT64 /* MMAP_COL_INODE     */
+                                );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < MMAP_COL_MAX; i++) {
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(tree), col);
+
+        switch (i) {
+            case MMAP_COL_PRIVATE_CLEAN:
+            case MMAP_COL_PRIVATE_DIRTY:
+            case MMAP_COL_SHARED_CLEAN:
+            case MMAP_COL_SHARED_DIRTY:
+            case MMAP_COL_VMSZ:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                         &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+                break;
+        }
+
+
+        switch (i) {
+            case MMAP_COL_VMSTART:
+            case MMAP_COL_VMEND:
+            case MMAP_COL_FLAGS:
+            case MMAP_COL_VMOFFSET:
+            case MMAP_COL_DEVICE:
+                g_object_set(cell, "family", "monospace", NULL);
+                break;
+        }
+    }
+
+    return new MemMapsData(tree, procdata->settings);
+}
+
+
+static gboolean
+memmaps_timer (gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+    g_assert(model);
+
+    update_memmaps_dialog (mmdata);
+
+    return TRUE;
+}
+
+
+static void
+create_single_memmaps_dialog (GtkTreeModel *model, GtkTreePath *path,
+                              GtkTreeIter *iter, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    MemMapsData *mmdata;
+    GtkWidget *memmapsdialog;
+    GtkWidget *dialog_vbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    ProcInfo *info;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    mmdata = create_memmapsdata (procdata);
+    mmdata->info = info;
+
+    memmapsdialog = gtk_dialog_new_with_buttons (_("Memory Maps"), GTK_WINDOW (procdata->app),
+                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                 "gtk-close", GTK_RESPONSE_CLOSE,
+                                                 NULL);
+    gtk_window_set_resizable(GTK_WINDOW(memmapsdialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(memmapsdialog), 620, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(memmapsdialog), 5);
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG(memmapsdialog));
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Memory maps for process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), label, FALSE, TRUE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    gtk_container_add (GTK_CONTAINER (scrolled), mmdata->tree);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), mmdata->tree);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+
+    g_signal_connect(G_OBJECT(memmapsdialog), "response",
+                              G_CALLBACK(dialog_response), mmdata);
+
+    gtk_widget_show_all (memmapsdialog);
+
+    mmdata->timer = g_timeout_add_seconds (5, memmaps_timer, mmdata);
+
+    update_memmaps_dialog (mmdata);
+}
+
+
+void
+create_memmaps_dialog (ProcData *procdata)
+{
+    /* TODO: do we really want to open multiple dialogs ? */
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_memmaps_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/index.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/index.html new file mode 100644 index 00000000..02bb6ffc --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/index.html @@ -0,0 +1,323 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/cgroups.cpp
27variableScope398styleThe scope of the variable 'paren_offset' can be reduced.
27variableScope398styleThe scope of the variable 'off' can be reduced.
27variableScope398styleThe scope of the variable 'tmp_size' can be reduced.
55cstyleCast398styleC-style pointer casting
src/disks.cpp
202redundantAssignment563styleVariable 'res' is reassigned a value before the old one has been used.
src/gsm_color_button.c
648variableScope398styleThe scope of the variable 'color_chooser' can be reduced.
src/interface.cpp
452cstyleCast398styleC-style pointer casting
454cstyleCast398styleC-style pointer casting
src/load-graph.cpp
41shadowVariable398styleLocal variable 'n' shadows outer variable
164shadowVariable398styleLocal variable 'i' shadows outer variable
src/load-graph.h
36noExplicitConstructor398styleStruct 'LoadGraph' has a constructor with 1 argument that is not explicit.
src/lsof.cpp
164shadowVariable398styleLocal variable 'count' shadows outer variable
src/memmaps.cpp
269shadowVariable398styleLocal variable 'iter' shadows outer variable
src/msm-resources.c
9unusedStructMember563styleunion member 'Anonymous0::alignment' is never used.
9unusedStructMember563styleunion member 'Anonymous0::ptr' is never used.
src/openfiles.cpp
73nullPointerRedundantCheck476warningEither the condition 'res' is redundant or there is possible null pointer dereference: res.
205shadowVariable398styleLocal variable 'openfiles' shadows outer variable
247variableScope398styleThe scope of the variable 'column' can be reduced.
248variableScope398styleThe scope of the variable 'cell' can be reduced.
src/prettytable.h
39unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_opened'
40unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_closed'
src/procdialogs.cpp
294noExplicitConstructor398styleClass 'SpinButtonUpdater' has a constructor with 1 argument that is not explicit.
415shadowVariable398styleLocal variable 'column' shadows outer variable
475cstyleCast398styleC-style pointer casting
498cstyleCast398styleC-style pointer casting
513cstyleCast398styleC-style pointer casting
src/procman-app.cpp
348uninitMemberVar398warningMember variable 'ProcmanApp::procdata' is not initialized in the constructor.
src/procman.cpp
34uninitMemberVarPrivate398warningMember variable 'ProcData::uimanager' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::action_group' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::statusbar' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::loadavg' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::endprocessbutton' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::popup_menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::disk_list' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::notebook' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::config' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::selection' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::settings' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::app' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::frequency' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::smooth_refresh' is not initialized in the constructor.
112shadowVariable398styleLocal variable 'order' shadows outer variable
162shadowVariable398styleLocal variable 'order' shadows outer variable
src/procman.h
103uninitMemberVar398warningMember variable 'MutableProcInfo::cgroup_name' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::unit' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::session' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::seat' is not initialized in the constructor.
173noExplicitConstructor398styleClass 'ProcInfo' has a constructor with 1 argument that is not explicit.
src/procproperties.cpp
208variableScope398styleThe scope of the variable 'column' can be reduced.
209variableScope398styleThe scope of the variable 'cell' can be reduced.
src/proctable.cpp
920shadowVariable398styleLocal variable 'arguments' shadows outer variable
929shadowVariable398styleLocal variable 'tooltip' shadows outer variable
1016shadowVariable398styleLocal variable 'it' shadows outer variable
1022shadowVariable398styleLocal variable 'it' shadows outer variable
1068shadowVariable398styleLocal variable 'it' shadows outer variable
1073shadowVariable398styleLocal variable 'it' shadows outer variable
src/selinux.cpp
21varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
src/smooth_refresh.h
22noExplicitConstructor398styleClass 'SmoothRefresh' has a constructor with 1 argument that is not explicit.
src/sysinfo.cpp
126unusedPrivateFunction398styleUnused private function: 'SysInfo::get_os_type'
233cstyleCast398styleC-style pointer casting
343cstyleCast398styleC-style pointer casting
509uninitMemberVar398warningMember variable 'LSBSysInfo::lsb_fd' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::name' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::release' is not initialized in the constructor.
515missingOverridestyleThe function 'set_distro_labels' overrides a function in a base class but is not marked with a 'override' specifier.
570shadowVariable398styleLocal variable 'release' shadows outer variable
615unusedPrivateFunction398styleUnused private function: 'LSBSysInfo::sync_lsb_release'
626variableScope398styleThe scope of the variable 'codename' can be reduced.
626shadowVariable398styleLocal variable 'release' shadows outer variable
690stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
697stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
701stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
736variableScope398styleThe scope of the variable 'len' can be reduced.
738stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
1001unreadVariable563styleVariable 'table_count' is assigned a value that is never used.
+
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/stats.html b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/stats.html new file mode 100644 index 00000000..aa8922ed --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/stats.html @@ -0,0 +1,189 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+

Top 10 files for warning severity, total findings: 24
+   15  src/procman.cpp
+   4   src/procman.h
+   3   src/sysinfo.cpp
+   1   src/procman-app.cpp
+   1   src/openfiles.cpp
+

+

Top 10 files for portability severity, total findings: 1
+   1  src/selinux.cpp
+

+

Top 10 files for performance severity, total findings: 4
+   4  src/sysinfo.cpp
+

+

Top 10 files for style severity, total findings: 47
+   10  src/sysinfo.cpp
+   6   src/proctable.cpp
+   5   src/procdialogs.cpp
+   4   src/cgroups.cpp
+   3   src/openfiles.cpp
+   2   src/procproperties.cpp
+   2   src/procman.cpp
+   2   src/prettytable.h
+   2   src/msm-resources.c
+   2   src/load-graph.cpp
+

+ +
+ +
+ + diff --git a/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/style.css b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/style.css new file mode 100644 index 00000000..3897bfaf --- /dev/null +++ b/2023-05-15-085050-4501-cppcheck@d2839764fa8b_help-translations/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-05-15-174418-6156-1@e1533eb204f2_master/index.html b/2023-05-15-174418-6156-1@e1533eb204f2_master/index.html new file mode 100644 index 00000000..fb17c846 --- /dev/null +++ b/2023-05-15-174418-6156-1@e1533eb204f2_master/index.html @@ -0,0 +1,136 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@edec401d21a1
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 16.0.2 (Fedora 16.0.2-1.fc38) +
Date:Mon May 15 17:44:18 2023
+

Bug Summary

+ + + + + + + +
Bug TypeQuantityDisplay?
All Bugs14
Logic error
Use of identical expressions1
Unused code
Dead assignment1
Unreachable code12
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
Unused codeDead assignmentrootdir/src/disks.cppget_mount_opt2011View Report
Unused codeUnreachable coderootdir/src/procman-app.cppon_command_line3811View Report
Unused codeUnreachable coderootdir/src/util.cppio_rate_cell_data_func4941View Report
Unused codeUnreachable coderootdir/src/util.cppstatus_cell_data_func5911View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_gicon421View Report
Unused codeUnreachable coderootdir/src/util.cppduration_cell_data_func5351View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_na_cell_data_func3841View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_na_cell_data_func4561View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_cell_data_func4221View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_icon131View Report
Unused codeUnreachable coderootdir/src/util.cpptime_cell_data_func5641View Report
Unused codeUnreachable coderootdir/src/procman-app.cpptimeouts_changed_cb1511View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_cell_data_func3501View Report
Logic errorUse of identical expressionsusr/include/sigc++-2.0/sigc++/visit_each.hoperator()981View Report
+ + diff --git a/2023-05-15-174418-6156-1@e1533eb204f2_master/report-22e004.html b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-22e004.html new file mode 100644 index 00000000..87a54b3a --- /dev/null +++ b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-22e004.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 381, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-174418-6156-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
This statement is never executed
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2023-05-15-174418-6156-1@e1533eb204f2_master/report-491eb3.html b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-491eb3.html new file mode 100644 index 00000000..0d714214 --- /dev/null +++ b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-491eb3.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 494, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-174418-6156-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-05-15-174418-6156-1@e1533eb204f2_master/report-4d889d.html b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-4d889d.html new file mode 100644 index 00000000..5a52da7d --- /dev/null +++ b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-4d889d.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 591, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-174418-6156-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-05-15-174418-6156-1@e1533eb204f2_master/report-633ebf.html b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-633ebf.html new file mode 100644 index 00000000..ab128821 --- /dev/null +++ b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-633ebf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 42, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-174418-6156-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
This statement is never executed
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2023-05-15-174418-6156-1@e1533eb204f2_master/report-6c54e6.html b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-6c54e6.html new file mode 100644 index 00000000..52d784d7 --- /dev/null +++ b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-6c54e6.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 535, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-174418-6156-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-05-15-174418-6156-1@e1533eb204f2_master/report-6c8186.html b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-6c8186.html new file mode 100644 index 00000000..36bdd8dd --- /dev/null +++ b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-6c8186.html @@ -0,0 +1,886 @@ + + + +/usr/include/sigc++-2.0/sigc++/visit_each.h + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:usr/include/sigc++-2.0/sigc++/visit_each.h
Warning:line 98, column 64
identical expressions on both sides of logical operator
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-174418-6156-1 -x c++ procman.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright 2002, The libsigc++ Development Team
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18#ifndef _SIGC_VISIT_EACH_HPP_
19#define _SIGC_VISIT_EACH_HPP_
20
21#include <sigc++/type_traits.h>
22#include <type_traits>
23
24namespace sigc {
25
26#ifndef DOXYGEN_SHOULD_SKIP_THIS
27namespace internal {
28
29//This should really be an inner class of limit_derived_target, without the T_limit template type,
30//But the SUN CC 5.7 (not earlier versions) compiler finds it ambiguous when we specify a particular specialization of it.
31//and does not seem to allow us to tell it explicitly that it's an inner class.
32template <bool I_derived, class T_type, class T_limit>
33struct with_type;
34
35//Specialization for I_derived = false
36template <class T_type, class T_limit> struct
37with_type<false, T_type, T_limit>
38{
39 static void execute_(const T_type&, const T_limit&) {}
40};
41
42//Specialization for I_derived = true
43template <class T_type, class T_limit>
44struct with_type<true, T_type, T_limit>
45{
46 static void execute_(const T_type& _A_type, const T_limit& _A_action)
47 { _A_action.action_(_A_type); }
48};
49
50
51/// Helper struct for visit_each_type().
52template <class T_target, class T_action>
53struct limit_derived_target
54{
55 typedef limit_derived_target<T_target, T_action> T_self;
56
57 template <class T_type>
58 void operator()(const T_type& _A_type) const
59 {
60 with_type<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
61 }
62
63 limit_derived_target(const T_action& _A_action)
64 : action_(_A_action)
65 {}
66
67 T_action action_;
68};
69
70// Specialization for T_target pointer types, to provide a slightly different execute_() implementation.
71
72template <bool I_derived, class T_type, class T_limit>
73struct with_type_pointer;
74
75//Specialization for I_derived = false
76template <class T_type, class T_limit>
77struct with_type_pointer<false, T_type, T_limit>
78{
79 static void execute_(const T_type&, const T_limit&) {}
80};
81
82//Specialization for I_derived = true
83template <class T_type, class T_limit>
84struct with_type_pointer<true, T_type, T_limit>
85{
86 static void execute_(const T_type& _A_type, const T_limit& _A_action)
87 { _A_action.action_(&_A_type); }
88};
89
90template <class T_target, class T_action>
91struct limit_derived_target<T_target*, T_action>
92{
93 typedef limit_derived_target<T_target*, T_action> T_self;
94
95 template <class T_type>
96 void operator()(const T_type& _A_type) const
97 {
98 with_type_pointer<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
identical expressions on both sides of logical operator
99 }
100
101 limit_derived_target(const T_action& _A_action)
102 : action_(_A_action)
103 {}
104
105 T_action action_;
106};
107
108} /* namespace internal */
109#endif // DOXYGEN_SHOULD_SKIP_THIS
110
111// struct visitor was introduced as a result of https://bugzilla.gnome.org/show_bug.cgi?id=724496
112// The advantage of using specializations of a template struct instead of overloads of
113// a template function is described by Herb Sutter in http://www.gotw.ca/publications/mill17.htm
114// In libsigc++ the main reason for using this technique is that we can avoid using ADL
115// (argument-dependent lookup), and therefore there is no risk that a visit_each() overload
116// in e.g. Boost is selected by mistake.
117
118/** sigc::visitor<T_functor>::do_visit_each() performs a functor on each of the targets of a functor.
119 * All unknown types just call @a _A_action on them.
120 * Add specializations that specialize the @a T_functor argument for your own
121 * functor types, so that subobjects get visited. This is needed to enable
122 * auto-disconnection support for your functor types.
123 *
124 * @par Example:
125 * @code
126 * namespace some_ns
127 * {
128 * struct some_functor
129 * {
130 * void operator()() {}
131 * some_possibly_sigc_trackable_derived_type some_data_member;
132 * some_other_functor_type some_other_functor;
133 * };
134 * }
135 *
136 * namespace sigc
137 * {
138 * template <>
139 * struct visitor<some_ns::some_functor>
140 * {
141 * template <class T_action>
142 * static void do_visit_each(const T_action& _A_action,
143 * const some_ns::some_functor& _A_target)
144 * {
145 * sigc::visit_each(_A_action, _A_target.some_data_member);
146 * sigc::visit_each(_A_action, _A_target.some_other_functor);
147 * }
148 * };
149 * }
150 * @endcode
151 *
152 * @ingroup sigcfunctors
153 */
154template <class T_functor>
155struct visitor
156{
157 template <class T_action>
158 static void do_visit_each(const T_action& _A_action, const T_functor& _A_functor)
159 {
160 _A_action(_A_functor);
161 }
162};
163
164/** This function performs a functor on each of the targets of a functor.
165 *
166 * @ingroup sigcfunctors
167 */
168template <class T_action, class T_functor>
169void visit_each(const T_action& _A_action, const T_functor& _A_functor)
170{ sigc::visitor<T_functor>::do_visit_each(_A_action, _A_functor); }
171
172/** This function performs a functor on each of the targets
173 * of a functor limited to a restricted type.
174 *
175 * @ingroup sigcfunctors
176 */
177template <class T_type, class T_action, class T_functor>
178void visit_each_type(const T_action& _A_action, const T_functor& _A_functor)
179{
180 typedef internal::limit_derived_target<T_type, T_action> type_limited_action;
181
182 type_limited_action limited_action(_A_action);
183
184 //specifying the types of the template specialization prevents disconnection of bound trackable references (such as with std::ref()),
185 //probably because the visit_each<> specializations take various different template types,
186 //in various sequences, and we are probably specifying only a subset of them with this.
187 //
188 //But this is required by the AIX (and maybe IRIX MipsPro and Tru64) compilers.
189 //I guess that std::ref() therefore does not work on those platforms. murrayc
190 // sigc::visit_each<type_limited_action, T_functor>(limited_action, _A_functor);
191
192 //g++ (even slightly old ones) is our primary platform, so we could use the non-crashing version.
193 //However, the explicit version also fixes a crash in a slightly more common case: http://bugzilla.gnome.org/show_bug.cgi?id=169225
194 //Users (and distributors) of libsigc++ on AIX (and maybe IRIX MipsPro and Tru64) do
195 //need to use the version above instead, to allow compilation.
196
197 //Added 2014-03-20: The preceding comment probably does not apply any more,
198 //now when the visit_each<>() overloads have been replaced by visitor<> specializations.
199 //It's probably safe to add explicit template parameters on calls to visit_each(),
200 //visit_each_type() and visitor::do_visit_each(), if necessary.
201
202 sigc::visit_each(limited_action, _A_functor);
203}
204
205} /* namespace sigc */
206#endif
diff --git a/2023-05-15-174418-6156-1@e1533eb204f2_master/report-77634b.html b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-77634b.html new file mode 100644 index 00000000..b01df961 --- /dev/null +++ b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-77634b.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 384, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-174418-6156-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-05-15-174418-6156-1@e1533eb204f2_master/report-7bbc8c.html b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-7bbc8c.html new file mode 100644 index 00000000..118433eb --- /dev/null +++ b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-7bbc8c.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 456, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-174418-6156-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-05-15-174418-6156-1@e1533eb204f2_master/report-7ce786.html b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-7ce786.html new file mode 100644 index 00000000..68faf697 --- /dev/null +++ b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-7ce786.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 422, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-174418-6156-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-05-15-174418-6156-1@e1533eb204f2_master/report-802eaf.html b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-802eaf.html new file mode 100644 index 00000000..d0110a16 --- /dev/null +++ b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-802eaf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 13, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-174418-6156-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
This statement is never executed
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2023-05-15-174418-6156-1@e1533eb204f2_master/report-8e6c9c.html b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-8e6c9c.html new file mode 100644 index 00000000..65cfbeed --- /dev/null +++ b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-8e6c9c.html @@ -0,0 +1,1200 @@ + + + +disks.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/disks.cpp
Warning:line 201, column 13
Value stored to 'res' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name disks.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-174418-6156-1 -x c++ disks.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#ifdef __linux__1
4#include <mntent.h>
5#endif // __linux__
6
7#include <giomm.h>
8#include <giomm/themedicon.h>
9#include <gtk/gtk.h>
10#include <glibtop/mountlist.h>
11#include <glibtop/fsusage.h>
12#include <glib/gi18n.h>
13
14#include "procman.h"
15#include "disks.h"
16#include "util.h"
17#include "interface.h"
18#include "iconthemewrapper.h"
19
20namespace
21{
22 const unsigned DISK_ICON_SIZE = 24;
23}
24
25enum DiskColumns
26{
27 /* string columns* */
28 DISK_DEVICE,
29 DISK_DIR,
30 DISK_TYPE,
31 DISK_SUBVOLUME,
32 DISK_TOTAL,
33 DISK_FREE,
34 DISK_AVAIL,
35 /* USED has to be the last column */
36 DISK_USED,
37 // then unvisible columns
38 /* Surface column */
39 DISK_ICON,
40 /* numeric columns */
41 DISK_USED_PERCENTAGE,
42 DISK_N_COLUMNS
43};
44
45
46
47static void
48fsusage_stats(const glibtop_fsusage *buf,
49 guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
50 gint *percentage)
51{
52 guint64 total = buf->blocks * buf->block_size;
53
54 if (!total) {
55 /* not a real device */
56 *btotal = *bfree = *bavail = *bused = 0ULL;
57 *percentage = 0;
58 } else {
59 int percent;
60 *btotal = total;
61 *bfree = buf->bfree * buf->block_size;
62 *bavail = buf->bavail * buf->block_size;
63 *bused = *btotal - *bfree;
64 /* percent = 100.0f * *bused / *btotal; */
65 percent = 100 * *bused / (*bused + *bavail);
66 *percentage = CLAMP(percent, 0, 100)(((percent) > (100)) ? (100) : (((percent) < (0)) ? (0)
: (percent)))
;
67 }
68}
69
70
71namespace
72{
73 string get_icon_for_path(const std::string& path)
74 {
75 using namespace Glib;
76 using namespace Gio;
77
78 // FIXME: I don't know whether i should use Volume or Mount or UnixMount
79 // all i need an icon name.
80 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
81
82 std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
83
84 for (size_t i = 0; i != mounts.size(); ++i) {
85 if (mounts[i]->get_name() != path)
86 continue;
87
88 RefPtr<Icon> icon = mounts[i]->get_icon();
89 RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
90
91 if (themed_icon) {
92 char* name = 0;
93 // FIXME: not wrapped yet
94 g_object_get(G_OBJECT(themed_icon->gobj())((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((themed_icon->gobj())), (((GType) ((20) << (2)))
)))))
, "name", &name, NULL__null);
95 return make_string(name);
96 }
97 }
98
99 return "";
100 }
101}
102
103
104static Glib::RefPtr<Gdk::Pixbuf>
105get_icon_for_device(const char *mountpoint)
106{
107 procman::IconThemeWrapper icon_theme;
108 string icon_name = get_icon_for_path(mountpoint);
109 if (icon_name == "")
110 // FIXME: defaults to a safe value
111 icon_name = "drive-harddisk"; // get_icon_for_path("/");
112 return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
113}
114
115
116static gboolean
117find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
118 GtkTreeIter *result)
119{
120 GtkTreeIter iter;
121 gboolean found = FALSE(0);
122
123 if (gtk_tree_model_get_iter_first(model, &iter)) {
124 do {
125 char *dir;
126
127 gtk_tree_model_get(model, &iter,
128 DISK_DIR, &dir,
129 -1);
130
131 if (dir && !strcmp(dir, mountpoint)) {
132 *result = iter;
133 found = TRUE(!(0));
134 }
135
136 g_free(dir);
137
138 } while (!found && gtk_tree_model_iter_next(model, &iter));
139 }
140
141 return found;
142}
143
144
145
146static void
147remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
148{
149 GtkTreeIter iter;
150
151 if (!gtk_tree_model_get_iter_first(model, &iter))
152 return;
153
154 while (true) {
155 char *dir;
156 guint i;
157 gboolean found = FALSE(0);
158
159 gtk_tree_model_get(model, &iter,
160 DISK_DIR, &dir,
161 -1);
162
163 for (i = 0; i != n; ++i) {
164 if (!strcmp(dir, entries[i].mountdir)) {
165 found = TRUE(!(0));
166 break;
167 }
168 }
169
170 g_free(dir);
171
172 if (!found) {
173 if (!gtk_list_store_remove(GTK_LIST_STORE(model)((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_list_store_get_type ()))))))
, &iter))
174 break;
175 else
176 continue;
177 }
178
179 if (!gtk_tree_model_iter_next(model, &iter))
180 break;
181 }
182}
183
184#ifdef __linux__1
185static char *
186get_mount_opt(const glibtop_mountentry *entry, const char* opt)
187{
188 char *opt_value = NULL__null;
189 const struct mntent *mnt;
190 FILE *fp;
191
192 if (!(fp = setmntent(MOUNTED"/etc/mtab", "r"))) {
193 goto out;
194 }
195
196 while ((mnt = getmntent(fp))) {
197 if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
198 (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
199 char *res;
200
201 res = hasmntopt(mnt, "subvol");
Value stored to 'res' is never read
202 if ((res = hasmntopt(mnt, "subvol")) != NULL__null) {
203 char **strs = g_strsplit_set(res, "=", 2);
204
205 if (g_strv_length(strs) == 2) {
206 char *value = strs[1];
207 if (g_strcmp0 (value,"/root") == 0)
208 opt_value = g_strdup("/")g_strdup_inline ("/");
209 else
210 opt_value = g_strdup(strs[1])g_strdup_inline (strs[1]);
211 g_strfreev(strs);
212 }
213 }
214 break;
215 }
216 }
217
218 endmntent(fp);
219
220 out:
221 return opt_value;
222}
223#endif // __linux__
224
225
226static void
227add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
228{
229 Glib::RefPtr<Gdk::Pixbuf> pixbuf;
230 cairo_surface_t *surface;
231 GtkTreeIter iter;
232 glibtop_fsusage usage;
233 guint64 bused, bfree, bavail, btotal;
234 gint percentage;
235#ifdef __linux__1
236 char *subvol = NULL__null;
237#endif // __linux__
238
239 glibtop_get_fsusage(&usage, entry->mountdir);
240
241 if (not show_all_fs and usage.blocks == 0) {
242 if (find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
243 gtk_list_store_remove(list, &iter);
244 return;
245 }
246
247 fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
248#ifdef __linux__1
249 subvol = get_mount_opt(entry, "subvol");
250#endif // __linux__
251 pixbuf = get_icon_for_device(entry->mountdir);
252 surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL__null);
253
254 /* if we can find a row with the same mountpoint, we get it but we
255 still need to update all the fields.
256 This makes selection persistent.
257 */
258 if (!find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
259 gtk_list_store_append(list, &iter);
260
261 gtk_list_store_set(list, &iter,
262 DISK_ICON, surface,
263 DISK_DEVICE, entry->devname,
264 DISK_DIR, entry->mountdir,
265 DISK_TYPE, entry->type,
266#ifdef __linux__1
267
268 DISK_SUBVOLUME, subvol != NULL__null ? subvol : "",
269#else
270 DISK_SUBVOLUME, "",
271#endif // __linux__
272 DISK_USED_PERCENTAGE, percentage,
273 DISK_TOTAL, btotal,
274 DISK_FREE, bfree,
275 DISK_AVAIL, bavail,
276 DISK_USED, bused,
277 -1);
278#ifdef __linux__1
279 g_free (subvol);
280#endif // __linux__
281}
282
283
284
285int
286cb_update_disks(gpointer data)
287{
288 ProcData *const procdata = static_cast<ProcData*>(data);
289
290 GtkListStore *list;
291 glibtop_mountentry * entries;
292 glibtop_mountlist mountlist;
293 guint i;
294
295 list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)))((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_tree_view_get_model(((((GtkTreeView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((procdata->disk_list)), ((gtk_tree_view_get_type
()))))))))), ((gtk_list_store_get_type ()))))))
;
296
297 entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
298
299 remove_old_disks(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entries, mountlist.number);
300
301 for (i = 0; i < mountlist.number; i++)
302 add_disk(list, &entries[i], procdata->config.show_all_fs);
303
304 g_free(entries);
305
306 return TRUE(!(0));
307}
308
309
310static void
311cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
312{
313 ProcData * const procdata = static_cast<ProcData*>(user_data);
314
315 procman_save_tree_state(procdata->settings,
316 GTK_WIDGET(treeview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_widget_get_type ()))))))
,
317 "disktreenew");
318}
319
320
321static void
322open_dir(GtkTreeView *tree_view,
323 GtkTreePath *path,
324 GtkTreeViewColumn *column,
325 gpointer user_data)
326{
327 GtkTreeIter iter;
328 GtkTreeModel *model;
329 char *dir, *url;
330
331 model = gtk_tree_view_get_model(tree_view);
332
333 if (!gtk_tree_model_get_iter(model, &iter, path)) {
334 char *p;
335 p = gtk_tree_path_to_string(path);
336 g_warning("Cannot get iter for path '%s'\n", p);
337 g_free(p);
338 return;
339 }
340
341 gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
342
343 url = g_strdup_printf("file://%s", dir);
344
345 GError* error = 0;
346 if (!g_app_info_launch_default_for_uri(url, NULL__null, &error)) {
347 g_warning("Cannot open '%s' : %s\n", url, error->message);
348 g_error_free(error);
349 }
350
351 g_free(url);
352 g_free(dir);
353}
354
355static guint timeout_id = 0;
356static GtkTreeViewColumn *current_column;
357
358static gboolean
359save_column_width (gpointer data)
360{
361 gint width;
362 gchar *key;
363 int id;
364 GSettings *settings;
365
366 settings = g_settings_get_child (G_SETTINGS (data)((((GSettings*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((g_settings_get_type ()))))))
, "disktreenew");
367 id = gtk_tree_view_column_get_sort_column_id (current_column);
368 width = gtk_tree_view_column_get_width (current_column);
369
370 key = g_strdup_printf ("col-%d-width", id);
371 g_settings_set_int(settings, key, width);
372 g_free (key);
373
374 if (timeout_id) {
375 g_source_remove (timeout_id);
376 timeout_id = 0;
377 }
378
379 return FALSE(0);
380}
381
382static void
383cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
384{
385 current_column = GTK_TREE_VIEW_COLUMN(widget)((((GtkTreeViewColumn*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((widget)), ((gtk_tree_view_column_get_type (
)))))))
;
386
387 if (timeout_id)
388 g_source_remove (timeout_id);
389
390 timeout_id = g_timeout_add (250, save_column_width, data);
391}
392
393void
394create_disk_view(ProcData *procdata, GtkBuilder *builder)
395{
396 GtkWidget *scrolled;
397 GtkWidget *disk_tree;
398 GtkListStore *model;
399 GtkTreeViewColumn *col;
400 GtkCellRenderer *cell;
401 guint i;
402
403 const gchar * const titles[] = {
404 N_("Device")("Device"),
405 N_("Directory")("Directory"),
406 N_("Type")("Type"),
407 N_("SubVolume")("SubVolume"),
408 N_("Total")("Total"),
409 N_("Free")("Free"),
410 N_("Available")("Available"),
411 N_("Used")("Used")
412 };
413
414 scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "disks_scrolled"))), ((
gtk_widget_get_type ()))))))
;
415
416 model = gtk_list_store_new(DISK_N_COLUMNS, /* n columns */
417 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DEVICE */
418 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DIR */
419 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_TYPE */
420 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_SUBVOLUME */
421 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_TOTAL */
422 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_FREE */
423 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_AVAIL */
424 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_USED */
425 CAIRO_GOBJECT_TYPE_SURFACEcairo_gobject_surface_get_type (), /* DISK_ICON */
426 G_TYPE_INT((GType) ((6) << (2)))); /* DISK_USED_PERCENTAGE */
427
428 disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_model_get_type ()))))))
);
429 g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("row-activated"), (((GCallback) (open_dir))), (__null
), __null, (GConnectFlags) 0)
;
430 procdata->disk_list = disk_tree;
431 gtk_container_add(GTK_CONTAINER(scrolled)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((scrolled)), ((gtk_container_get_type ()))))))
, disk_tree);
432 g_object_unref(G_OBJECT(model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
);
433
434 /* icon + device */
435
436 col = gtk_tree_view_column_new();
437 cell = gtk_cell_renderer_pixbuf_new();
438 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
439 gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
440 NULL__null);
441
442 cell = gtk_cell_renderer_text_new();
443 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
444 gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
445 NULL__null);
446 gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE])gettext (titles[DISK_DEVICE]));
447 gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
448 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
449 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
450 gtk_tree_view_column_set_min_width (col, 30);
451 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
452 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
453 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
454
455 /* sizes - used */
456
457 for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
458 cell = gtk_cell_renderer_text_new();
459 col = gtk_tree_view_column_new();
460 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
461 gtk_tree_view_column_set_title(col, _(titles[i])gettext (titles[i]));
462 gtk_tree_view_column_set_sort_column_id(col, i);
463 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
464 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
465 gtk_tree_view_column_set_min_width (col, 30);
466 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
467 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
468 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
469
470 switch (i) {
471 case DISK_TOTAL:
472 case DISK_FREE:
473 case DISK_AVAIL:
474 g_object_set(cell, "xalign", 1.0f, NULL__null);
475 gtk_tree_view_column_set_cell_data_func(col, cell,
476 &procman::storage_size_cell_data_func,
477 GUINT_TO_POINTER(i)((gpointer) (gulong) (i)),
478 NULL__null);
479 break;
480
481 default:
482 gtk_tree_view_column_set_attributes(col, cell,
483 "text", i,
484 NULL__null);
485 break;
486 }
487 }
488
489 /* used + percentage */
490
491 col = gtk_tree_view_column_new();
492 cell = gtk_cell_renderer_text_new();
493 g_object_set(cell, "xalign", 1.0f, NULL__null);
494 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
495 gtk_tree_view_column_set_cell_data_func(col, cell,
496 &procman::storage_size_cell_data_func,
497 GUINT_TO_POINTER(DISK_USED)((gpointer) (gulong) (DISK_USED)),
498 NULL__null);
499
500 cell = gtk_cell_renderer_progress_new();
501 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
502 gtk_tree_view_column_set_attributes(col, cell, "value",
503 DISK_USED_PERCENTAGE, NULL__null);
504 gtk_tree_view_column_set_title(col, _(titles[DISK_USED])gettext (titles[DISK_USED]));
505 gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
506 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
507 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
508 gtk_tree_view_column_set_min_width (col, 150);
509 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
510 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
511 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
512
513 /* numeric sort */
514
515 procman_get_tree_state(procdata->settings, disk_tree,
516 "disktreenew");
517
518 g_signal_connect (G_OBJECT(disk_tree), "columns-changed",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
519 G_CALLBACK(cb_disk_columns_changed), procdata)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
;
520}
diff --git a/2023-05-15-174418-6156-1@e1533eb204f2_master/report-c673b5.html b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-c673b5.html new file mode 100644 index 00000000..166b5d62 --- /dev/null +++ b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-c673b5.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 564, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-174418-6156-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-05-15-174418-6156-1@e1533eb204f2_master/report-d507c5.html b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-d507c5.html new file mode 100644 index 00000000..6f9782ce --- /dev/null +++ b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-d507c5.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 151, column 9
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-174418-6156-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
This statement is never executed
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2023-05-15-174418-6156-1@e1533eb204f2_master/report-e8ff80.html b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-e8ff80.html new file mode 100644 index 00000000..17a0ca7c --- /dev/null +++ b/2023-05-15-174418-6156-1@e1533eb204f2_master/report-e8ff80.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 350, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-05-15-174418-6156-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 2 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-05-15-174418-6156-1@e1533eb204f2_master/scanview.css b/2023-05-15-174418-6156-1@e1533eb204f2_master/scanview.css new file mode 100644 index 00000000..cf8a5a6a --- /dev/null +++ b/2023-05-15-174418-6156-1@e1533eb204f2_master/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/2023-05-15-174418-6156-1@e1533eb204f2_master/sorttable.js b/2023-05-15-174418-6156-1@e1533eb204f2_master/sorttable.js new file mode 100644 index 00000000..32faa078 --- /dev/null +++ b/2023-05-15-174418-6156-1@e1533eb204f2_master/sorttable.js @@ -0,0 +1,492 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse',''); + cell.className = cell.className.replace('sorttable_sorted',''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j=0; j 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } + else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } + else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i=0; i=0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a,b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); + if (isNaN(bb)) bb = 0; + return aa-bb; + }, + sort_alpha: function(a,b) { + if (a[0]==b[0]) return 0; + if (a[0] 0 ) { + var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for(var i = t; i > b; --i) { + if ( comp_func(list[i], list[i-1]) < 0 ) { + var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write(" + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef _PROCMAN_PROCMAN_H_
+#define _PROCMAN_PROCMAN_H_
+
+#include <glibmm/refptr.h>
+#include <cairo-gobject.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+#include <glibtop/cpu.h>
+
+#include <time.h>
+#include <sys/types.h>
+
+#include <map>
+#include <string>
+
+struct ProcInfo;
+struct ProcData;
+struct LoadGraph;
+
+#include "smooth_refresh.h"
+#include "prettytable.h"
+
+#define GSM_GSETTINGS_SCHEMA "org.mate.system-monitor"
+
+enum
+{
+    ALL_PROCESSES,
+    MY_PROCESSES,
+    ACTIVE_PROCESSES
+};
+
+enum
+{
+    VERY_HIGH_PRIORITY,
+    HIGH_PRIORITY,
+    NORMAL_PRIORITY,
+    LOW_PRIORITY,
+    VERY_LOW_PRIORITY,
+    CUSTOM_PRIORITY
+};
+
+static const unsigned MIN_UPDATE_INTERVAL =   1 * 1000;
+static const unsigned MAX_UPDATE_INTERVAL = 100 * 1000;
+
+enum ProcmanTab
+{
+    PROCMAN_TAB_SYSINFO,
+    PROCMAN_TAB_PROCESSES,
+    PROCMAN_TAB_RESOURCES,
+    PROCMAN_TAB_DISKS
+};
+
+struct ProcConfig
+{
+    gint        width;
+    gint        height;
+    gint        xpos;
+    gint        ypos;
+    gboolean    maximized;
+    gboolean    show_kill_warning;
+    gboolean    show_tree;
+    gboolean    show_all_fs;
+    int         update_interval;
+    int         graph_update_interval;
+    int         disks_update_interval;
+    gint        whose_process;
+    gint        current_tab;
+    GdkRGBA     cpu_color[GLIBTOP_NCPU];
+    GdkRGBA     mem_color;
+    GdkRGBA     swap_color;
+    GdkRGBA     net_in_color;
+    GdkRGBA     net_out_color;
+    GdkRGBA     bg_color;
+    GdkRGBA     frame_color;
+    gint        num_cpus;
+    bool solaris_mode;
+    bool network_in_bits;
+};
+
+struct MutableProcInfo
+{
+MutableProcInfo()<--- Member variable 'MutableProcInfo::cgroup_name' is not initialized in the constructor.<--- Member variable 'MutableProcInfo::unit' is not initialized in the constructor.<--- Member variable 'MutableProcInfo::session' is not initialized in the constructor.<--- Member variable 'MutableProcInfo::seat' is not initialized in the constructor.
+  : disk_write_bytes_current(0ULL),
+    disk_read_bytes_current(0ULL),
+    disk_write_bytes_total(0ULL),
+    disk_read_bytes_total(0ULL),
+    status(0U)
+    { }
+
+    std::string user;
+
+    gchar wchan[40];
+
+    // all these members are filled with libgtop which uses
+    // guint64 (to have fixed size data) but we don't need more
+    // than an unsigned long (even for 32bit apps on a 64bit
+    // kernel) as these data are amounts, not offsets.
+    gulong vmsize;
+    gulong memres;
+    gulong memshared;
+    gulong memwritable;
+    gulong mem;
+
+#ifdef HAVE_WNCK
+    // wnck gives an unsigned long
+    gulong memxserver;
+#endif
+
+    gulong start_time;
+    guint64 cpu_time;
+    guint64 disk_write_bytes_current;
+    guint64 disk_read_bytes_current;
+    guint64 disk_write_bytes_total;
+    guint64 disk_read_bytes_total;
+    guint status;
+    guint pcpu;
+    gint nice;
+    gchar *cgroup_name;
+
+    gchar *unit;
+    gchar *session;
+    gchar *seat;
+
+    std::string owner;
+};
+
+class ProcInfo
+: public MutableProcInfo
+{
+    /* undefined */ ProcInfo& operator=(const ProcInfo&);
+    /* undefined */ ProcInfo(const ProcInfo&);
+
+    typedef std::map<guint, std::string> UserMap;
+    /* cached username */
+    static UserMap users;
+
+  public:
+
+    // TODO: use a set instead
+    // sorted by pid. The map has a nice property : it is sorted
+    // by pid so this helps a lot when looking for the parent node
+    // as ppid is nearly always < pid.
+    typedef std::map<pid_t, ProcInfo*> List;
+    typedef List::iterator Iterator;
+
+    static List all;
+
+    static ProcInfo* find(pid_t pid);
+    static Iterator begin() { return ProcInfo::all.begin(); }
+    static Iterator end() { return ProcInfo::all.end(); }
+
+    ProcInfo(pid_t pid);
+    ~ProcInfo();
+    // adds one more ref to icon
+    void set_icon(Glib::RefPtr<Gdk::Pixbuf> icon);
+    void set_user(guint uid);
+    std::string lookup_user(guint uid);
+
+    GtkTreeIter      node;
+    cairo_surface_t *surface;
+    gchar           *tooltip;
+    gchar           *name;
+    gchar           *arguments;
+    gchar           *security_context;
+
+    const pid_t      pid;
+    pid_t            ppid;
+    guint            uid;
+
+// private:
+    // tracks cpu time per process keeps growing because if a
+    // ProcInfo is deleted this does not mean that the process is
+    // not going to be recreated on the next update.  For example,
+    // if dependencies + (My or Active), the proclist is cleared
+    // on each update.  This is a workaround
+    static std::map<pid_t, guint64> cpu_times;
+};
+
+struct ProcData
+{
+    // lazy initialization
+    static ProcData* get_instance();
+
+    GtkUIManager    *uimanager;
+    GtkActionGroup    *action_group;
+    GtkWidget    *statusbar;
+    gint        tip_message_cid;
+    GtkWidget    *tree;
+    GtkWidget    *loadavg;
+    GtkWidget    *endprocessbutton;
+    GtkWidget    *popup_menu;
+    GtkWidget    *disk_list;
+    GtkWidget    *notebook;
+    ProcConfig    config;
+    LoadGraph    *cpu_graph;
+    LoadGraph    *mem_graph;
+    LoadGraph    *net_graph;
+    gint        cpu_label_fixed_width;
+    gint        net_label_fixed_width;
+    ProcInfo    *selected_process;
+    GtkTreeSelection *selection;
+    guint        timeout;
+    guint        disk_timeout;
+
+    PrettyTable    pretty_table;
+
+    GSettings       *settings;
+    GtkWidget        *app;
+    GtkUIManager    *menu;
+
+    unsigned    frequency;
+
+    SmoothRefresh  *smooth_refresh;
+
+    guint64 cpu_total_time;
+    guint64 cpu_total_time_last;
+
+    gboolean terminating;
+
+private:
+    ProcData();
+    /* undefined */ ProcData(const ProcData &);
+    /* undefined */ ProcData& operator=(const ProcData &);
+};
+
+void        procman_save_config (ProcData *data);
+void        procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+gboolean    procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+
+struct ReniceArgs
+{
+    ProcData *procdata;
+    int nice_value;
+};
+
+struct KillArgs
+{
+    ProcData *procdata;
+    int signal;
+};
+
+#endif /* _PROCMAN_PROCMAN_H_ */
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/1.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/1.html new file mode 100644 index 00000000..b83a4070 --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/1.html @@ -0,0 +1,435 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
#ifndef _PROCMAN_SMOOTH_REFRESH
+#define _PROCMAN_SMOOTH_REFRESH
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <string>
+
+using std::string;
+
+class SmoothRefresh
+{
+  public:
+
+    /*
+      smooth_refresh_new
+
+      @config_interval : pointer to config_interval so we can observe
+      config_interval changes.
+
+      @return : initialized SmoothRefresh
+    */
+    SmoothRefresh(GSettings *a_settings);
+
+    ~SmoothRefresh();
+
+    /*
+      smooth_refresh_reset
+
+      Resets state and re-read config_interval
+    */
+    void reset();
+
+    /*
+      smooth_refresh_get
+
+      Computes the new refresh_interval so that CPU usage is lower than
+      SMOOTH_REFRESH_PCPU.
+
+      @new_interval : where the new refresh_interval is stored.
+
+      @return : TRUE is refresh_interval has changed. The new refresh_interval
+      is stored in @new_interval. Else FALSE;
+    */
+    bool get(guint &new_interval);
+
+    static const string KEY;
+    static const bool KEY_DEFAULT_VALUE;
+
+  private:
+
+    unsigned get_own_cpu_usage();
+
+    static void status_changed(GSettings *settings,
+                               const gchar *key,
+                               gpointer user_data);
+
+    void load_settings_value(const gchar *key);
+
+    /*
+      fuzzy logic:
+      - decrease refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_LO
+      - increase refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_HI
+
+    */
+
+    enum
+    {
+        PCPU_HI = 22,
+        PCPU_LO = 18
+    };
+
+    /*
+      -self : procman's PID (so we call getpid() only once)
+
+      -interval : current refresh interval
+
+      -config_interval : pointer to the configuration refresh interval.
+      Used to watch configuration changes
+
+      -interval >= -config_interval
+
+      -last_pcpu : to avoid spikes, the last CPU%. See PCPU_{LO,HI}
+
+      -last_total_time:
+      -last_cpu_time: Save last cpu and process times to compute CPU%
+    */
+
+    GSettings *settings;
+    bool active;
+    guint connection;
+    guint interval;
+    unsigned  last_pcpu;
+    guint64 last_total_time;
+    guint64 last_cpu_time;
+};
+
+#endif /* _PROCMAN_SMOOTH_REFRESH */
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/10.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/10.html new file mode 100644 index 00000000..cb5e0f54 --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/10.html @@ -0,0 +1,1067 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
#include <gio/gio.h>
+
+#if defined (__ELF__) && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
+# define SECTION __attribute__ ((section (".gresource.msm"), aligned (8)))
+#else
+# define SECTION
+#endif
+
+static const SECTION union { const guint8 data[3353]; const double alignment; void * const ptr;}  msm_resource_data = { {<--- union member 'Anonymous0::alignment' is never used.<--- union member 'Anonymous0::ptr' is never used.
+  0107, 0126, 0141, 0162, 0151, 0141, 0156, 0164, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0030, 0000, 0000, 0000, 0310, 0000, 0000, 0000, 0000, 0000, 0000, 0050, 0006, 0000, 0000, 0000, 
+  0000, 0000, 0000, 0000, 0001, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0005, 0000, 0000, 0000, 0376, 0236, 0033, 0101, 0005, 0000, 0000, 0000, 
+  0310, 0000, 0000, 0000, 0024, 0000, 0114, 0000, 0334, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 
+  0113, 0120, 0220, 0013, 0002, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 0004, 0000, 0114, 0000, 
+  0350, 0000, 0000, 0000, 0354, 0000, 0000, 0000, 0324, 0265, 0002, 0000, 0377, 0377, 0377, 0377, 
+  0354, 0000, 0000, 0000, 0001, 0000, 0114, 0000, 0360, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 
+  0173, 0250, 0316, 0037, 0000, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 0014, 0000, 0166, 0000, 
+  0000, 0001, 0000, 0000, 0034, 0006, 0000, 0000, 0234, 0164, 0275, 0021, 0000, 0000, 0000, 0000, 
+  0034, 0006, 0000, 0000, 0016, 0000, 0166, 0000, 0060, 0006, 0000, 0000, 0017, 0015, 0000, 0000, 
+  0201, 0321, 0040, 0031, 0001, 0000, 0000, 0000, 0017, 0015, 0000, 0000, 0005, 0000, 0114, 0000, 
+  0024, 0015, 0000, 0000, 0030, 0015, 0000, 0000, 0155, 0141, 0164, 0145, 0055, 0163, 0171, 0163, 
+  0164, 0145, 0155, 0055, 0155, 0157, 0156, 0151, 0164, 0157, 0162, 0057, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0157, 0162, 0147, 0057, 0005, 0000, 0000, 0000, 0057, 0000, 0000, 0000, 
+  0001, 0000, 0000, 0000, 0151, 0156, 0164, 0145, 0162, 0146, 0141, 0143, 0145, 0056, 0165, 0151, 
+  0242, 0073, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0133, 0133, 0163, 0352, 0066, 
+  0020, 0176, 0317, 0257, 0160, 0375, 0332, 0161, 0010, 0227, 0320, 0164, 0006, 0070, 0323, 0166, 
+  0232, 0364, 0241, 0347, 0114, 0046, 0344, 0114, 0037, 0031, 0331, 0136, 0260, 0212, 0054, 0271, 
+  0222, 0314, 0345, 0337, 0237, 0065, 0066, 0004, 0002, 0370, 0102, 0210, 0061, 0224, 0067, 0154, 
+  0257, 0054, 0355, 0267, 0253, 0335, 0317, 0253, 0245, 0363, 0145, 0346, 0063, 0143, 0002, 0122, 
+  0121, 0301, 0273, 0146, 0375, 0366, 0316, 0064, 0200, 0073, 0302, 0245, 0174, 0324, 0065, 0277, 
+  0277, 0076, 0132, 0017, 0346, 0227, 0336, 0115, 0347, 0047, 0313, 0062, 0236, 0200, 0203, 0044, 
+  0032, 0134, 0143, 0112, 0265, 0147, 0214, 0030, 0161, 0301, 0150, 0336, 0066, 0037, 0156, 0033, 
+  0206, 0145, 0241, 0020, 0345, 0032, 0344, 0220, 0070, 0320, 0353, 0110, 0370, 0057, 0244, 0022, 
+  0224, 0301, 0250, 0335, 0065, 0107, 0172, 0374, 0263, 0371, 0066, 0113, 0363, 0266, 0321, 0062, 
+  0153, 0275, 0216, 0260, 0377, 0005, 0107, 0033, 0016, 0043, 0112, 0165, 0315, 0047, 0075, 0376, 
+  0207, 0162, 0127, 0114, 0115, 0203, 0272, 0135, 0323, 0047, 0224, 0017, 0246, 0361, 0215, 0136, 
+  0047, 0220, 0042, 0000, 0251, 0347, 0006, 0047, 0076, 0164, 0115, 0207, 0160, 0153, 0050, 0234, 
+  0120, 0231, 0275, 0107, 0302, 0024, 0164, 0152, 0113, 0201, 0055, 0121, 0115, 0065, 0003, 0323, 
+  0320, 0222, 0160, 0305, 0210, 0046, 0066, 0303, 0233, 0163, 0300, 0221, 0375, 0271, 0322, 0340, 
+  0033, 0137, 0005, 0247, 0132, 0310, 0224, 0127, 0270, 0060, 0044, 0041, 0323, 0326, 0224, 0272, 
+  0332, 0063, 0173, 0255, 0326, 0135, 0016, 0141, 0017, 0350, 0310, 0323, 0050, 0375, 0353, 0375, 
+  0272, 0264, 0343, 0121, 0346, 0356, 0120, 0375, 0167, 0061, 0133, 0323, 0333, 0306, 0253, 0255, 
+  0067, 0117, 0250, 0242, 0270, 0172, 0263, 0367, 0052, 0303, 0064, 0215, 0013, 0200, 0043, 0044, 
+  0005, 0256, 0211, 0106, 0263, 0230, 0075, 0264, 0217, 0246, 0016, 0141, 0073, 0226, 0033, 0060, 
+  0264, 0252, 0047, 0230, 0013, 0022, 0355, 0126, 0113, 0356, 0356, 0323, 0345, 0233, 0320, 0140, 
+  0013, 0061, 0216, 0025, 0342, 0313, 0253, 0143, 0050, 0224, 0041, 0351, 0023, 0071, 0242, 0334, 
+  0122, 0232, 0110, 0204, 0276, 0336, 0310, 0026, 0005, 0356, 0346, 0023, 0324, 0042, 0170, 0057, 
+  0230, 0151, 0113, 0065, 0127, 0224, 0017, 0105, 0151, 0346, 0364, 0140, 0026, 0220, 0110, 0241, 
+  0214, 0127, 0116, 0162, 0312, 0331, 0102, 0242, 0305, 0227, 0176, 0237, 0212, 0222, 0012, 0210, 
+  0203, 0061, 0143, 0017, 0104, 0251, 0376, 0263, 0373, 0141, 0055, 0206, 0365, 0235, 0264, 0241, 
+  0347, 0101, 0264, 0251, 0211, 0155, 0356, 0000, 0376, 0157, 0142, 0003, 0333, 0204, 0236, 0055, 
+  0156, 0225, 0001, 0176, 0074, 0323, 0376, 0100, 0263, 0076, 0164, 0245, 0034, 0242, 0066, 0106, 
+  0330, 0266, 0243, 0026, 0261, 0255, 0041, 0145, 0154, 0307, 0264, 0265, 0325, 0230, 0254, 0175, 
+  0270, 0362, 0103, 0034, 0354, 0374, 0037, 0234, 0060, 0063, 0234, 0355, 0165, 0332, 0207, 0074, 
+  0373, 0172, 0315, 0275, 0230, 0040, 0356, 0200, 0114, 0106, 0045, 0372, 0227, 0107, 0030, 0035, 
+  0241, 0136, 0213, 0340, 0126, 0310, 0231, 0226, 0100, 0147, 0315, 0020, 0073, 0134, 0306, 0212, 
+  0003, 0241, 0150, 0014, 0360, 0335, 0141, 0136, 0331, 0167, 0244, 0140, 0014, 0334, 0365, 0144, 
+  0037, 0071, 0050, 0050, 0005, 0152, 0240, 0222, 0247, 0145, 0144, 0213, 0143, 0173, 0252, 0362, 
+  0010, 0152, 0144, 0105, 0041, 0312, 0354, 0121, 0236, 0073, 0016, 0236, 0312, 0200, 0365, 0003, 
+  0303, 0112, 0250, 0065, 0016, 0137, 0030, 0016, 0323, 0147, 0142, 0073, 0073, 0276, 0133, 0040, 
+  0054, 0376, 0311, 0135, 0143, 0360, 0034, 0217, 0116, 0131, 0157, 0250, 0300, 0042, 0116, 0264, 
+  0142, 0213, 0004, 0001, 0020, 0174, 0221, 0003, 0331, 0130, 0034, 0337, 0135, 0044, 0070, 0100, 
+  0047, 0240, 0254, 0204, 0342, 0145, 0373, 0127, 0262, 0143, 0021, 0244, 0014, 0375, 0102, 0216, 
+  0036, 0301, 0050, 0337, 0261, 0334, 0123, 0071, 0107, 0043, 0335, 0071, 0062, 0227, 0125, 0314, 
+  0315, 0162, 0347, 0365, 0105, 0052, 0253, 0102, 0122, 0177, 0136, 0206, 0254, 0102, 0306, 0332, 
+  0203, 0312, 0247, 0146, 0177, 0374, 0014, 0273, 0046, 0377, 0242, 0214, 0165, 0077, 0234, 0116, 
+  0020, 0126, 0347, 0373, 0154, 0257, 0116, 0167, 0005, 0011, 0115, 0244, 0125, 0025, 0266, 0325, 
+  0037, 0317, 0337, 0215, 0277, 0250, 0302, 0017, 0362, 0171, 0312, 0370, 0131, 0022, 0131, 0067, 
+  0264, 0044, 0132, 0113, 0212, 0151, 0010, 0324, 0332, 0357, 0144, 0300, 0064, 0376, 0032, 0067, 
+  0046, 0204, 0205, 0013, 0267, 0142, 0156, 0124, 0201, 0250, 0255, 0217, 0071, 0063, 0036, 0265, 
+  0341, 0220, 0043, 0111, 0002, 0357, 0154, 0167, 0371, 0301, 0156, 0336, 0376, 0160, 0255, 0342, 
+  0221, 0211, 0351, 0006, 0222, 0103, 0274, 0121, 0032, 0220, 0223, 0175, 0234, 0076, 0265, 0256, 
+  0161, 0377, 0113, 0332, 0354, 0202, 0205, 0076, 0212, 0056, 0041, 0112, 0013, 0231, 0022, 0331, 
+  0152, 0056, 0101, 0037, 0047, 0137, 0040, 0050, 0201, 0133, 0370, 0300, 0212, 0271, 0112, 0063, 
+  0165, 0311, 0263, 0135, 0103, 0322, 0213, 0010, 0300, 0040, 0146, 0172, 0276, 0160, 0121, 0230, 
+  0013, 0176, 0112, 0056, 0204, 0223, 0044, 0144, 0076, 0235, 0301, 0345, 0246, 0072, 0025, 0045, 
+  0372, 0347, 0032, 0370, 0174, 0360, 0057, 0060, 0023, 0107, 0132, 0125, 0041, 0023, 0177, 0005, 
+  0037, 0223, 0260, 0201, 0206, 0067, 0372, 0123, 0022, 0134, 0263, 0162, 0161, 0347, 0274, 0146, 
+  0345, 0174, 0131, 0071, 0072, 0135, 0302, 0004, 0263, 0310, 0134, 0252, 0333, 0302, 0337, 0230, 
+  0231, 0124, 0167, 0161, 0254, 0264, 0015, 0361, 0223, 0244, 0356, 0033, 0306, 0013, 0227, 0055, 
+  0005, 0337, 0002, 0111, 0070, 0257, 0051, 0066, 0022, 0160, 0273, 0100, 0126, 0157, 0147, 0274, 
+  0324, 0023, 0276, 0030, 0001, 0007, 0261, 0253, 0256, 0221, 0043, 0010, 0051, 0334, 0361, 0145, 
+  0326, 0066, 0163, 0342, 0225, 0122, 0143, 0307, 0005, 0027, 0015, 0115, 0231, 0241, 0205, 0301, 
+  0120, 0133, 0030, 0214, 0210, 0343, 0245, 0223, 0035, 0055, 0202, 0225, 0334, 0201, 0201, 0143, 
+  0063, 0003, 0140, 0240, 0075, 0053, 0370, 0343, 0144, 0361, 0271, 0006, 0250, 0037, 0325, 0000, 
+  0007, 0034, 0111, 0235, 0342, 0341, 0225, 0362, 0136, 0024, 0345, 0255, 0177, 0220, 0125, 0160, 
+  0320, 0027, 0110, 0171, 0043, 0255, 0252, 0100, 0171, 0277, 0201, 0236, 0012, 0071, 0276, 0122, 
+  0335, 0342, 0116, 0171, 0245, 0272, 0173, 0330, 0154, 0073, 0067, 0233, 0215, 0140, 0074, 0031, 
+  0233, 0155, 0345, 0154, 0225, 0151, 0076, 0134, 0062, 0355, 0215, 0217, 0370, 0160, 0252, 0263, 
+  0042, 0137, 0057, 0313, 0125, 0237, 0023, 0377, 0112, 0063, 0203, 0026, 0232, 0260, 0101, 0162, 
+  0336, 0352, 0236, 0225, 0055, 0136, 0243, 0245, 0033, 0057, 0311, 0322, 0253, 0141, 0220, 0372, 
+  0207, 0015, 0242, 0160, 0357, 0237, 0333, 0256, 0350, 0143, 0104, 0377, 0134, 0374, 0357, 0113, 
+  0336, 0020, 0150, 0005, 0175, 0206, 0233, 0241, 0072, 0206, 0070, 0302, 0106, 0300, 0101, 0040, 
+  0267, 0341, 0137, 0034, 0120, 0133, 0121, 0327, 0063, 0050, 0235, 0221, 0045, 0077, 0215, 0322, 
+  0366, 0156, 0112, 0256, 0156, 0154, 0071, 0114, 0334, 0362, 0334, 0070, 0014, 0346, 0337, 0042, 
+  0077, 0360, 0321, 0131, 0336, 0347, 0342, 0200, 0072, 0143, 0220, 0003, 0262, 0172, 0136, 0006, 
+  0244, 0233, 0235, 0007, 0355, 0343, 0065, 0163, 0155, 0300, 0176, 0127, 0071, 0330, 0227, 0241, 
+  0376, 0202, 0101, 0157, 0225, 0016, 0372, 0045, 0026, 0176, 0076, 0122, 0146, 0313, 0255, 0134, 
+  0306, 0262, 0057, 0243, 0050, 0164, 0274, 0126, 0273, 0306, 0061, 0133, 0355, 0242, 0276, 0261, 
+  0052, 0124, 0145, 0136, 0100, 0211, 0120, 0072, 0007, 0167, 0332, 0065, 0112, 0353, 0264, 0033, 
+  0226, 0327, 0150, 0127, 0106, 0143, 0134, 0073, 0317, 0327, 0363, 0256, 0166, 0156, 0227, 0252, 
+  0361, 0265, 0225, 0273, 0102, 0045, 0274, 0002, 0273, 0245, 0171, 0314, 0020, 0062, 0254, 0106, 
+  0004, 0171, 0244, 0014, 0214, 0370, 0137, 0070, 0207, 0006, 0221, 0346, 0261, 0202, 0310, 0231, 
+  0235, 0074, 0364, 0061, 0160, 0204, 0312, 0046, 0062, 0141, 0207, 0253, 0313, 0112, 0237, 0100, 
+  0064, 0076, 0261, 0153, 0054, 0113, 0252, 0170, 0136, 0337, 0276, 0361, 0366, 0117, 0332, 0233, 
+  0037, 0325, 0360, 0311, 0023, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0160, 0162, 0145, 0146, 
+  0145, 0162, 0145, 0156, 0143, 0145, 0163, 0056, 0165, 0151, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0065, 0123, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0134, 0335, 0162, 0342, 0066, 
+  0024, 0276, 0357, 0123, 0250, 0276, 0355, 0050, 0004, 0262, 0155, 0167, 0072, 0301, 0073, 0335, 
+  0335, 0046, 0335, 0231, 0266, 0263, 0323, 0354, 0266, 0227, 0036, 0331, 0076, 0140, 0155, 0204, 
+  0344, 0112, 0002, 0102, 0257, 0372, 0054, 0175, 0264, 0076, 0111, 0217, 0177, 0010, 0140, 0300, 
+  0066, 0004, 0210, 0041, 0334, 0331, 0346, 0110, 0072, 0072, 0377, 0237, 0216, 0206, 0353, 0067, 
+  0017, 0003, 0101, 0106, 0240, 0015, 0127, 0262, 0353, 0264, 0057, 0056, 0035, 0002, 0062, 0120, 
+  0041, 0227, 0375, 0256, 0363, 0371, 0323, 0015, 0175, 0355, 0274, 0161, 0277, 0272, 0376, 0232, 
+  0122, 0162, 0013, 0022, 0064, 0263, 0020, 0222, 0061, 0267, 0021, 0351, 0013, 0026, 0002, 0271, 
+  0272, 0270, 0172, 0175, 0321, 0041, 0224, 0042, 0021, 0227, 0026, 0164, 0217, 0005, 0340, 0136, 
+  0153, 0370, 0153, 0310, 0065, 0030, 0042, 0270, 0337, 0165, 0372, 0366, 0376, 0033, 0147, 0266, 
+  0312, 0325, 0105, 0347, 0225, 0323, 0162, 0257, 0225, 0377, 0005, 0002, 0113, 0002, 0301, 0214, 
+  0351, 0072, 0267, 0366, 0376, 0303, 0200, 0365, 0301, 0041, 0074, 0354, 0072, 0074, 0171, 0154, 
+  0073, 0356, 0165, 0254, 0125, 0014, 0332, 0116, 0210, 0144, 0003, 0350, 0072, 0043, 0156, 0270, 
+  0057, 0300, 0161, 0077, 0351, 0041, 0134, 0267, 0246, 0277, 0056, 0321, 0005, 0114, 0322, 0236, 
+  0012, 0206, 0306, 0161, 0157, 0230, 0060, 0145, 0244, 0074, 0120, 0222, 0046, 0217, 0216, 0073, 
+  0346, 0062, 0124, 0143, 0032, 0010, 0265, 0070, 0242, 0225, 0261, 0132, 0203, 0345, 0316, 0241, 
+  0131, 0216, 0100, 0304, 0324, 0327, 0152, 0154, 0100, 0327, 0143, 0371, 0075, 0147, 0102, 0365, 
+  0063, 0236, 0143, 0015, 0075, 0320, 0250, 0161, 0060, 0136, 0230, 0175, 0177, 0012, 0137, 0276, 
+  0322, 0041, 0150, 0072, 0346, 0241, 0215, 0034, 0367, 0333, 0022, 0112, 0313, 0055, 0212, 0204, 
+  0130, 0315, 0244, 0021, 0314, 0062, 0024, 0120, 0327, 0231, 0000, 0256, 0161, 0067, 0061, 0026, 
+  0006, 0344, 0127, 0045, 0271, 0125, 0232, 0174, 0234, 0161, 0130, 0062, 0135, 0010, 0075, 0066, 
+  0024, 0166, 0272, 0362, 0253, 0313, 0313, 0032, 0304, 0021, 0360, 0176, 0144, 0221, 0272, 0123, 
+  0116, 0155, 0254, 0126, 0023, 0232, 0030, 0075, 0215, 0031, 0262, 0142, 0053, 0125, 0151, 0047, 
+  0061, 0320, 0210, 0047, 0224, 0231, 0124, 0347, 0151, 0203, 0210, 0213, 0220, 0244, 0316, 0042, 
+  0231, 0240, 0351, 0053, 0132, 0211, 0257, 0036, 0234, 0025, 0332, 0172, 0213, 0237, 0123, 0125, 
+  0145, 0023, 0171, 0202, 0115, 0324, 0320, 0076, 0111, 0113, 0003, 0246, 0373, 0134, 0122, 0253, 
+  0342, 0162, 0035, 0345, 0164, 0276, 0262, 0126, 0015, 0312, 0111, 0225, 0346, 0050, 0027, 0146, 
+  0321, 0277, 0035, 0027, 0035, 0335, 0362, 0200, 0211, 0022, 0172, 0023, 0263, 0000, 0103, 0214, 
+  0343, 0166, 0252, 0045, 0303, 0202, 0144, 0132, 0017, 0045, 0317, 0126, 0012, 0150, 0210, 0354, 
+  0311, 0242, 0230, 0026, 0007, 0155, 0040, 0253, 0164, 0321, 0265, 0313, 0144, 0153, 0044, 0076, 
+  0347, 0371, 0331, 0207, 0245, 0311, 0005, 0363, 0101, 0070, 0356, 0317, 0110, 0123, 0042, 0200, 
+  0241, 0001, 0232, 0361, 0110, 0131, 0034, 0003, 0103, 0077, 0010, 0240, 0132, 0165, 0133, 0304, 
+  0222, 0012, 0112, 0015, 0001, 0360, 0021, 0030, 0232, 0173, 0105, 0345, 0200, 0064, 0314, 0071, 
+  0156, 0026, 0355, 0126, 0106, 0034, 0324, 0355, 0075, 0052, 0167, 0151, 0044, 0074, 0304, 0114, 
+  0206, 0325, 0233, 0354, 0161, 0041, 0052, 0331, 0210, 0225, 0341, 0231, 0271, 0055, 0070, 0157, 
+  0353, 0161, 0361, 0126, 0256, 0311, 0072, 0012, 0115, 0003, 0176, 0225, 0106, 0337, 0025, 0263, 
+  0302, 0111, 0252, 0264, 0335, 0004, 0225, 0266, 0313, 0125, 0172, 0140, 0266, 0160, 0021, 0232, 
+  0104, 0164, 0307, 0005, 0031, 0356, 0320, 0044, 0223, 0242, 0112, 0322, 0100, 0211, 0341, 0100, 
+  0232, 0156, 0033, 0237, 0223, 0064, 0216, 0017, 0130, 0115, 0055, 0333, 0353, 0255, 0346, 0141, 
+  0156, 0255, 0012, 0043, 0244, 0264, 0136, 0077, 0371, 0162, 0210, 0162, 0143, 0323, 0350, 0236, 
+  0155, 0211, 0226, 0004, 0371, 0025, 0373, 0373, 0115, 0131, 0360, 0225, 0272, 0317, 0366, 0050, 
+  0247, 0157, 0007, 0360, 0227, 0150, 0152, 0056, 0025, 0164, 0243, 0232, 0164, 0045, 0125, 0120, 
+  0271, 0346, 0073, 0125, 0232, 0307, 0211, 0260, 0016, 0062, 0130, 0254, 0141, 0305, 0344, 0345, 
+  0166, 0160, 0020, 0023, 0330, 0257, 0214, 0332, 0235, 0035, 0132, 0037, 0212, 0162, 0146, 0172, 
+  0355, 0327, 0173, 0021, 0277, 0017, 0021, 0033, 0161, 0245, 0017, 0042, 0373, 0205, 0015, 0175, 
+  0127, 0307, 0227, 0176, 0111, 0063, 0326, 0032, 0236, 0275, 0074, 0237, 0035, 0302, 0152, 0230, 
+  0340, 0175, 0324, 0232, 0261, 0114, 0333, 0022, 0272, 0214, 0243, 0125, 0150, 0340, 0155, 0316, 
+  0164, 0131, 0055, 0211, 0162, 0021, 0100, 0005, 0227, 0100, 0007, 0052, 0134, 0261, 0001, 0146, 
+  0255, 0346, 0230, 0335, 0301, 0314, 0075, 0347, 0243, 0307, 0031, 0010, 0040, 0043, 0046, 0206, 
+  0251, 0135, 0212, 0060, 0301, 0246, 0255, 0371, 0061, 0225, 0371, 0106, 0100, 0317, 0122, 0034, 
+  0301, 0202, 0250, 0020, 0374, 0213, 0300, 0100, 0305, 0253, 0351, 0066, 0115, 0022, 0257, 0066, 
+  0267, 0125, 0317, 0100, 0220, 0071, 0321, 0001, 0064, 0237, 0143, 0207, 0124, 0361, 0025, 0376, 
+  0135, 0151, 0336, 0213, 0042, 0350, 0324, 0316, 0223, 0303, 0070, 0144, 0026, 0274, 0024, 0117, 
+  0240, 0172, 0017, 0227, 0057, 0353, 0006, 0313, 0142, 0236, 0154, 0167, 0266, 0166, 0356, 0307, 
+  0115, 0036, 0316, 0271, 0327, 0073, 0255, 0367, 0071, 0225, 0074, 0231, 0062, 0205, 0017, 0004, 
+  0215, 0117, 0311, 0320, 0374, 0120, 0121, 0100, 0017, 0045, 0246, 0205, 0304, 0225, 0053, 0071, 
+  0035, 0110, 0030, 0050, 0311, 0203, 0044, 0207, 0364, 0001, 0215, 0154, 0205, 0060, 0114, 0314, 
+  0245, 0134, 0163, 0056, 0362, 0014, 0276, 0274, 0244, 0312, 0073, 0344, 0157, 0036, 0207, 0254, 
+  0337, 0302, 0041, 0352, 0040, 0056, 0363, 0071, 0021, 0171, 0063, 0134, 0361, 0277, 0177, 0376, 
+  0055, 0233, 0127, 0360, 0201, 0117, 0223, 0003, 0301, 0102, 0275, 0136, 0074, 0077, 0341, 0175, 
+  0156, 0115, 0241, 0010, 0334, 0114, 0013, 0355, 0335, 0150, 0241, 0121, 0252, 0177, 0027, 0101, 
+  0260, 0200, 0101, 0315, 0100, 0051, 0033, 0125, 0200, 0320, 0125, 0336, 0366, 0223, 0114, 0136, 
+  0210, 0227, 0115, 0100, 0064, 0364, 0064, 0230, 0350, 0070, 0201, 0152, 0025, 0017, 0233, 0205, 
+  0210, 0120, 0263, 0061, 0345, 0062, 0304, 0202, 0321, 0046, 0265, 0132, 0221, 0174, 0077, 0006, 
+  0321, 0336, 0221, 0101, 0004, 0311, 0207, 0055, 0354, 0341, 0107, 0201, 0144, 0304, 0207, 0236, 
+  0322, 0100, 0020, 0261, 0342, 0352, 0104, 0151, 0342, 0335, 0043, 0330, 0115, 0236, 0037, 0203, 
+  0314, 0331, 0104, 0236, 0313, 0104, 0072, 0273, 0212, 0031, 0112, 0060, 0315, 0315, 0026, 0106, 
+  0342, 0275, 0347, 0043, 0036, 0002, 0171, 0367, 0361, 0063, 0031, 0032, 0326, 0007, 0342, 0117, 
+  0322, 0227, 0100, 0015, 0245, 0075, 0133, 0306, 0163, 0131, 0306, 0325, 0163, 0244, 0260, 0166, 
+  0163, 0363, 0346, 0323, 0241, 0172, 0217, 0203, 0010, 0315, 0121, 0036, 0222, 0354, 0010, 0370, 
+  0147, 0022, 0150, 0004, 0062, 0370, 0040, 0061, 0053, 0015, 0322, 0263, 0034, 0162, 0223, 0262, 
+  0125, 0062, 0315, 0227, 0241, 0261, 0274, 0067, 0161, 0334, 0344, 0230, 0266, 0204, 0016, 0060, 
+  0257, 0305, 0206, 0377, 0135, 0171, 0100, 0133, 0175, 0122, 0120, 0030, 0360, 0220, 0237, 0137, 
+  0134, 0236, 0370, 0151, 0302, 0306, 0356, 0324, 0074, 0054, 0135, 0327, 0247, 0052, 0117, 0023, 
+  0267, 0161, 0255, 0324, 0304, 0033, 0341, 0140, 0037, 0063, 0326, 0010, 0367, 0346, 0074, 0315, 
+  0104, 0152, 0054, 0023, 0020, 0056, 0270, 0261, 0173, 0106, 0340, 0126, 0003, 0170, 0271, 0201, 
+  0155, 0352, 0131, 0315, 0302, 0346, 0201, 0126, 0102, 0100, 0370, 0147, 0172, 0047, 0244, 0250, 
+  0170, 0223, 0377, 0172, 0214, 0375, 0011, 0023, 0261, 0344, 0226, 0113, 0326, 0322, 0342, 0262, 
+  0216, 0361, 0177, 0102, 0255, 0376, 0301, 0141, 0116, 0014, 0363, 0172, 0076, 0214, 0020, 0030, 
+  0332, 0245, 0241, 0217, 0063, 0127, 0371, 0010, 0244, 0260, 0230, 0032, 0054, 0121, 0023, 0053, 
+  0130, 0335, 0350, 0137, 0272, 0154, 0140, 0100, 0074, 0236, 0222, 0256, 0224, 0302, 0335, 0043, 
+  0301, 0242, 0105, 0114, 0203, 0052, 0235, 0315, 0320, 0132, 0121, 0102, 0235, 0140, 0041, 0327, 
+  0350, 0105, 0027, 0274, 0234, 0044, 0046, 0217, 0363, 0060, 0337, 0251, 0033, 0340, 0223, 0076, 
+  0133, 0203, 0342, 0372, 0042, 0150, 0257, 0024, 0055, 0316, 0100, 0263, 0036, 0367, 0322, 0312, 
+  0073, 0357, 0112, 0153, 0060, 0152, 0250, 0203, 0163, 0157, 0362, 0171, 0172, 0223, 0063, 0361, 
+  0367, 0065, 0213, 0243, 0146, 0001, 0236, 0047, 0001, 0231, 0342, 0316, 0016, 0331, 0277, 0254, 
+  0271, 0277, 0365, 0176, 0173, 0233, 0262, 0174, 0006, 0071, 0307, 0000, 0162, 0226, 0014, 0255, 
+  0241, 0015, 0323, 0203, 0037, 0063, 0154, 0333, 0200, 0235, 0011, 0264, 0320, 0212, 0075, 0255, 
+  0056, 0354, 0154, 0233, 0347, 0056, 0254, 0273, 0102, 0030, 0307, 0326, 0205, 0135, 0277, 0205, 
+  0163, 0027, 0366, 0324, 0273, 0260, 0076, 0112, 0151, 0233, 0166, 0312, 0135, 0244, 0306, 0104, 
+  0202, 0035, 0053, 0175, 0117, 0114, 0014, 0220, 0100, 0113, 0222, 0314, 0166, 0232, 0275, 0224, 
+  0272, 0301, 0365, 0004, 0032, 0266, 0057, 0247, 0347, 0122, 0271, 0150, 0355, 0033, 0332, 0233, 
+  0301, 0355, 0105, 0350, 0330, 0204, 0334, 0371, 0373, 0224, 0243, 0215, 0254, 0157, 0215, 0170, 
+  0366, 0007, 0312, 0053, 0113, 0332, 0020, 0106, 0374, 0014, 0311, 0237, 0011, 0222, 0117, 0205, 
+  0177, 0074, 0227, 0205, 0213, 0034, 0037, 0025, 0324, 0256, 0161, 0125, 0370, 0014, 0266, 0033, 
+  0003, 0266, 0227, 0114, 0355, 0310, 0301, 0366, 0336, 0100, 0364, 0124, 0120, 0047, 0174, 0215, 
+  0171, 0151, 0213, 0057, 0027, 0076, 0057, 0211, 0342, 0330, 0300, 0363, 0272, 0015, 0234, 0241, 
+  0363, 0251, 0103, 0147, 0046, 0204, 0067, 0325, 0176, 0172, 0167, 0165, 0023, 0000, 0235, 0342, 
+  0147, 0017, 0247, 0040, 0230, 0232, 0201, 0230, 0364, 0117, 0000, 0316, 0330, 0371, 0214, 0235, 
+  0137, 0310, 0175, 0305, 0251, 0343, 0274, 0324, 0333, 0212, 0213, 0373, 0077, 0052, 0334, 0161, 
+  0276, 0323, 0170, 0012, 0056, 0167, 0302, 0067, 0032, 0367, 0350, 0247, 0315, 0271, 0370, 0170, 
+  0063, 0053, 0033, 0236, 0347, 0362, 0143, 0310, 0315, 0175, 0162, 0051, 0116, 0302, 0370, 0144, 
+  0357, 0077, 0116, 0265, 0377, 0242, 0157, 0077, 0256, 0120, 0364, 0013, 0276, 0000, 0231, 0233, 
+  0004, 0115, 0044, 0062, 0102, 0031, 0235, 0357, 0077, 0036, 0305, 0242, 0263, 0126, 0105, 0147, 
+  0227, 0235, 0234, 0004, 0274, 0171, 0071, 0170, 0153, 0114, 0063, 0047, 0115, 0015, 0167, 0313, 
+  0210, 0162, 0133, 0041, 0075, 0245, 0237, 0323, 0314, 0276, 0136, 0315, 0320, 0271, 0247, 0177, 
+  0161, 0232, 0176, 0310, 0341, 0174, 0226, 0120, 0115, 0341, 0235, 0150, 0060, 0261, 0222, 0006, 
+  0127, 0240, 0355, 0166, 0366, 0277, 0207, 0171, 0243, 0036, 0113, 0321, 0171, 0312, 0222, 0201, 
+  0337, 0073, 0356, 0374, 0137, 0175, 0055, 0015, 0154, 0025, 0131, 0230, 0361, 0070, 0373, 0163, 
+  0313, 0257, 0376, 0007, 0112, 0344, 0157, 0105, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0155, 
+  0141, 0164, 0145, 0057, 0000, 0000, 0000, 0000
+} };
+
+static GStaticResource static_resource = { msm_resource_data.data, sizeof (msm_resource_data.data) - 1 /* nul terminator */, NULL, NULL, NULL };
+
+G_MODULE_EXPORT
+GResource *msm_get_resource (void);
+GResource *msm_get_resource (void)
+{
+  return g_static_resource_get_resource (&static_resource);
+}
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GLib Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __G_CONSTRUCTOR_H__
+#define __G_CONSTRUCTOR_H__
+
+/*
+  If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and
+  destructors, in a usable way, including e.g. on library unload. If not you're on
+  your own.
+
+  Some compilers need #pragma to handle this, which does not work with macros,
+  so the way you need to use this is (for constructors):
+
+  #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+  #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(my_constructor)
+  #endif
+  G_DEFINE_CONSTRUCTOR(my_constructor)
+  static void my_constructor(void) {
+   ...
+  }
+
+*/
+
+#ifndef __GTK_DOC_IGNORE__
+
+#if  __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func (void);
+#define G_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func (void);
+
+#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
+/* Visual studio 2008 and later has _Pragma */
+
+/*
+ * Only try to include gslist.h if not already included via glib.h,
+ * so that items using gconstructor.h outside of GLib (such as
+ * GResources) continue to build properly.
+ */
+#ifndef __G_LIB_H__
+#include "gslist.h"
+#endif
+
+#include <stdlib.h>
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* We do some weird things to avoid the constructors being optimized
+ * away on VS2015 if WholeProgramOptimization is enabled. First we
+ * make a reference to the array from the wrapper to make sure its
+ * references. Then we use a pragma to make sure the wrapper function
+ * symbol is always included at the link stage. Also, the symbols
+ * need to be extern (but not dllexport), even though they are not
+ * really used from another object file.
+ */
+
+/* We need to account for differences between the mangling of symbols
+ * for x86 and x64/ARM/ARM64 programs, as symbols on x86 are prefixed
+ * with an underscore but symbols on x64/ARM/ARM64 are not.
+ */
+#ifdef _M_IX86
+#define G_MSVC_SYMBOL_PREFIX "_"
+#else
+#define G_MSVC_SYMBOL_PREFIX ""
+#endif
+
+#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
+#define G_DEFINE_DESTRUCTOR(_func) G_MSVC_DTOR (_func, G_MSVC_SYMBOL_PREFIX)
+
+#define G_MSVC_CTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _wrapper(void) { _func(); g_slist_find (NULL,  _array ## _func); return 0; } \
+  __pragma(comment(linker,"/include:" _sym_prefix # _func "_wrapper")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _wrapper;
+
+#define G_MSVC_DTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _constructor(void) { atexit (_func); g_slist_find (NULL,  _array ## _func); return 0; } \
+   __pragma(comment(linker,"/include:" _sym_prefix # _func "_constructor")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined (_MSC_VER)
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* Pre Visual studio 2008 must use #pragma section */
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _wrapper(void) { _func(); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func ## _wrapper;
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _constructor(void) { atexit (_func); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined(__SUNPRO_C)
+
+/* This is not tested, but i believe it should work, based on:
+ * http://opensource.apple.com/source/OpenSSL098/OpenSSL098-35/src/fips/fips_premain.c
+ */
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  init(_func)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void);
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  fini(_func)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void);
+
+#else
+
+/* constructors not supported for this compiler */
+
+#endif
+
+#endif /* __GTK_DOC_IGNORE__ */
+#endif /* __G_CONSTRUCTOR_H__ */
+
+#ifdef G_HAS_CONSTRUCTORS
+
+#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(msmresource_constructor)
+#endif
+G_DEFINE_CONSTRUCTOR(msmresource_constructor)
+#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(msmresource_destructor)
+#endif
+G_DEFINE_DESTRUCTOR(msmresource_destructor)
+
+#else
+#warning "Constructor not supported on this compiler, linking in resources will not work"
+#endif
+
+static void msmresource_constructor (void)
+{
+  g_static_resource_init (&static_resource);
+}
+
+static void msmresource_destructor (void)
+{
+  g_static_resource_fini (&static_resource);
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/11.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/11.html new file mode 100644 index 00000000..174d418f --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/11.html @@ -0,0 +1,1039 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
#include <config.h>
+
+#include <glib/gi18n.h>
+#include <glibtop/procopenfiles.h>
+#include <sys/stat.h>
+#include <netdb.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include "procman.h"
+#include "openfiles.h"
+#include "proctable.h"
+#include "util.h"
+#include "settings-keys.h"
+
+#ifndef NI_IDN
+#define NI_IDN 0
+#endif
+
+enum
+{
+    COL_FD,
+    COL_TYPE,
+    COL_OBJECT,
+    COL_OPENFILE_STRUCT,
+    NUM_OPENFILES_COL
+};
+
+
+static const char*
+get_type_name(enum glibtop_file_type t)
+{
+    switch(t)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        return _("file");
+    case GLIBTOP_FILE_TYPE_PIPE:
+        return _("pipe");
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+        return _("IPv6 network connection");
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        return _("IPv4 network connection");
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        return _("local socket");
+    default:
+        return _("unknown type");
+    }
+}
+
+
+
+static char *
+friendlier_hostname(const char *addr_str, int port)
+{
+    struct addrinfo hints = { };
+    struct addrinfo *res = NULL;
+    char hostname[NI_MAXHOST];
+    char service[NI_MAXSERV];
+    char port_str[6];
+
+    if (!addr_str[0]) return g_strdup("");
+
+    snprintf(port_str, sizeof port_str, "%d", port);
+
+    hints.ai_family = AF_UNSPEC;
+    hints.ai_socktype = SOCK_STREAM;
+
+    if (getaddrinfo(addr_str, port_str, &hints, &res))
+        goto failsafe;
+
+    if (getnameinfo(res->ai_addr, res->ai_addrlen, hostname,<--- Null pointer dereference
+            sizeof hostname, service, sizeof service, NI_IDN))
+        goto failsafe;
+
+    if (res) freeaddrinfo(res);<--- Assuming that condition 'res' is not redundant
+        return g_strdup_printf("%s, TCP port %d (%s)", hostname, port, service);
+
+  failsafe:
+    if (res) freeaddrinfo(res);
+    return g_strdup_printf("%s, TCP port %d", addr_str, port);
+}
+
+
+
+static void
+add_new_files (gpointer key, gpointer value, gpointer data)
+{
+    glibtop_open_files_entry *openfiles = static_cast<glibtop_open_files_entry*>(value);
+
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreeIter row;
+
+    char *object;
+
+    switch(openfiles->type)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        object = g_strdup(openfiles->info.file.name);
+        break;
+
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        object = friendlier_hostname(openfiles->info.sock.dest_host,
+                         openfiles->info.sock.dest_port);
+        break;
+
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        object = g_strdup(openfiles->info.localsock.name);
+        break;
+
+    default:
+        object = g_strdup("");
+    }
+
+    gtk_list_store_insert (GTK_LIST_STORE (model), &row, 0);
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        COL_FD, openfiles->fd,
+                        COL_TYPE, get_type_name(static_cast<glibtop_file_type>(openfiles->type)),
+                        COL_OBJECT, object,
+#if GLIB_CHECK_VERSION (2, 68, 0)
+                        COL_OPENFILE_STRUCT, g_memdup2(openfiles, sizeof(*openfiles)),
+#else
+                        COL_OPENFILE_STRUCT, g_memdup(openfiles, sizeof(*openfiles)),
+#endif
+                        -1);
+
+    g_free(object);
+}
+
+static GList *old_maps = NULL;
+
+static gboolean
+classify_openfiles (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+    GHashTable *new_maps = static_cast<GHashTable*>(data);
+    GtkTreeIter *old_iter;
+    glibtop_open_files_entry *openfiles;
+    gchar *old_name;
+
+    gtk_tree_model_get (model, iter, 1, &old_name, -1);
+
+    openfiles = static_cast<glibtop_open_files_entry*>(g_hash_table_lookup (new_maps, old_name));
+    if (openfiles) {
+        g_hash_table_remove (new_maps, old_name);
+        g_free (old_name);
+        return FALSE;
+
+    }
+
+    old_iter = gtk_tree_iter_copy (iter);
+    old_maps = g_list_append (old_maps, old_iter);
+    g_free (old_name);
+    return FALSE;
+
+}
+
+
+static gboolean
+compare_open_files(gconstpointer a, gconstpointer b)
+{
+    const glibtop_open_files_entry *o1 = static_cast<const glibtop_open_files_entry *>(a);
+    const glibtop_open_files_entry *o2 = static_cast<const glibtop_open_files_entry *>(b);
+
+    /* Falta manejar los diferentes tipos! */
+    return (o1->fd == o2->fd) && (o1->type == o2->type); /* XXX! */
+}
+
+
+static void
+update_openfiles_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+    GtkTreeModel *model;
+    glibtop_open_files_entry *openfiles;<--- Shadowed declaration
+    glibtop_proc_open_files procmap;
+    GHashTable *new_maps;
+    guint i;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    if (!info)
+        return;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    openfiles = glibtop_get_proc_open_files (&procmap, info->pid);
+
+    if (!openfiles)
+        return;
+
+    new_maps = static_cast<GHashTable *>(g_hash_table_new_full (g_str_hash, compare_open_files,
+                                                                NULL, NULL));
+    for (i=0; i < procmap.number; i++)
+        g_hash_table_insert (new_maps, openfiles + i, openfiles + i);
+
+    gtk_tree_model_foreach (model, classify_openfiles, new_maps);
+
+    g_hash_table_foreach (new_maps, add_new_files, model);
+
+    while (old_maps) {
+        GtkTreeIter *iter = static_cast<GtkTreeIter*>(old_maps->data);
+        glibtop_open_files_entry *openfiles = NULL;<--- Shadow variable
+
+        gtk_tree_model_get (model, iter,
+                            COL_OPENFILE_STRUCT, &openfiles,
+                            -1);
+
+        gtk_list_store_remove (GTK_LIST_STORE (model), iter);
+        gtk_tree_iter_free (iter);
+        g_free (openfiles);
+
+        old_maps = g_list_next (old_maps);
+
+    }
+
+    g_hash_table_destroy (new_maps);
+    g_free (openfiles);
+}
+
+static void
+close_openfiles_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GSettings *settings;
+    guint timer;
+
+    settings = static_cast<GSettings*>(g_object_get_data (G_OBJECT (tree), "settings"));
+    procman_save_tree_state (settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    return ;
+}
+
+
+static GtkWidget *
+create_openfiles_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    const gchar * const titles[] = {
+        /* Translators: "FD" here means "File Descriptor". Please use
+           a very short translation if possible, and at most
+           2-3 characters for it to be able to fit in the UI. */
+        N_("FD"),
+        N_("Type"),
+        N_("Object")
+    };
+
+    model = gtk_list_store_new (NUM_OPENFILES_COL,
+                                G_TYPE_INT,        /* FD */
+                                G_TYPE_STRING,    /* Type */
+                                G_TYPE_STRING,    /* Object */
+                                G_TYPE_POINTER    /* open_files_entry */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_OPENFILES_COL-1; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        switch (i) {
+        case COL_FD:
+            g_object_set(cell, "xalign", 1.0f, NULL);
+            break;
+        }
+
+        column = gtk_tree_view_column_new_with_attributes (_(titles[i]),
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_sort_column_id (column, i);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    procman_get_tree_state (procdata->settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    return tree;
+}
+
+
+static gboolean
+openfiles_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_openfiles_dialog (tree);
+
+    return TRUE;
+}
+
+
+static void
+create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *openfilesdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    openfilesdialog = gtk_dialog_new_with_buttons (_("Open Files"), NULL,
+                                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                   "gtk-close", GTK_RESPONSE_CLOSE,
+                                                   NULL);
+    gtk_window_set_resizable (GTK_WINDOW (openfilesdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (openfilesdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (openfilesdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (openfilesdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Files opened by process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                    GTK_POLICY_AUTOMATIC,
+                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_openfiles_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+    g_object_set_data (G_OBJECT (tree), "settings", procdata->settings);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (openfilesdialog), "response",
+                      G_CALLBACK (close_openfiles_dialog), tree);
+
+    gtk_widget_show_all (openfilesdialog);
+
+    timer = g_timeout_add_seconds (5, openfiles_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_openfiles_dialog (tree);
+
+}
+
+
+void
+create_openfiles_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_openfiles_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/12.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/12.html new file mode 100644 index 00000000..c1c9bcc6 --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/12.html @@ -0,0 +1,385 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
// -*- c++ -*-
+
+#ifndef _PROCMAN_PRETTYTABLE_H_
+#define _PROCMAN_PRETTYTABLE_H_
+
+#include <glib.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <glibmm/refptr.h>
+#include <gdkmm/pixbuf.h>
+#include <giomm/filemonitor.h>
+
+#include <map>
+#include <string>
+
+#ifdef HAVE_WNCK
+extern "C" {
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h>
+}
+#endif
+
+#include "iconthemewrapper.h"
+
+class ProcInfo;
+
+using std::string;
+
+class PrettyTable
+{
+ public:
+    PrettyTable();
+    ~PrettyTable();
+
+    void set_icon(ProcInfo &);
+
+private:
+
+#ifdef HAVE_WNCK
+    static void on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_opened'
+    static void on_application_closed(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_closed'
+
+    void register_application(pid_t pid, Glib::RefPtr<Gdk::Pixbuf> icon);
+    void unregister_application(pid_t pid);
+#endif
+
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_theme(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_default(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_gio(const ProcInfo &);
+#ifdef HAVE_WNCK
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_wnck(const ProcInfo &);
+#endif
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_name(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_for_kernel(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_dummy(const ProcInfo &);
+
+    bool get_default_icon_name(const string &cmd, string &name);
+    void file_monitor_event (Glib::RefPtr<Gio::File>,
+                             Glib::RefPtr<Gio::File>,
+                             Gio::FileMonitorEvent);
+    void init_gio_app_cache ();
+
+    typedef std::map<string, Glib::RefPtr<Gdk::Pixbuf> > IconCache;
+    typedef std::map<pid_t, Glib::RefPtr<Gdk::Pixbuf> > IconsForPID;
+    typedef std::map<string, Glib::RefPtr<Gio::AppInfo> > AppCache;
+    typedef std::map<string, Glib::RefPtr<Gio::FileMonitor> > DesktopDirMonitors;
+
+    IconsForPID apps;
+    IconCache defaults;
+    DesktopDirMonitors monitors;
+    AppCache gio_apps;
+    procman::IconThemeWrapper theme;
+};
+
+#endif /* _PROCMAN_PRETTYTABLE_H_ */
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/13.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/13.html new file mode 100644 index 00000000..b7c3450b --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/13.html @@ -0,0 +1,1417 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
/* Procman - dialogs
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+
+#include <signal.h>
+#include <string.h>
+
+#include "procdialogs.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "procactions.h"
+#include "util.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "procman_gksu.h"
+#include "procman_pkexec.h"
+#include "cgroups.h"
+
+#define GET_WIDGET(x) GTK_WIDGET(gtk_builder_get_object(builder, x))
+
+static GtkWidget *renice_dialog = NULL;
+static GtkWidget *prefs_dialog = NULL;
+static gint new_nice_value = 0;
+
+
+static void
+kill_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    struct KillArgs *kargs = static_cast<KillArgs*>(data);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    if (id == GTK_RESPONSE_OK)
+        kill_process (kargs->procdata, kargs->signal);
+
+    g_free (kargs);
+}
+
+void
+procdialog_create_kill_dialog (ProcData *procdata, int signal)
+{
+    GtkWidget *kill_alert_dialog;
+    gchar *primary, *secondary, *button_text;
+    struct KillArgs *kargs;
+
+    kargs = g_new(KillArgs, 1);
+    kargs->procdata = procdata;
+    kargs->signal = signal;
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if ( selected_count == 1 ) {
+        ProcInfo *selected_process = NULL;
+        // get the last selected row
+        gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &selected_process);
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing single process*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        } else {
+            /*xgettext: primary alert message for ending single process*/
+            primary = g_strdup_printf (_("Are you sure you want to end the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        }
+    } else {
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the %d selected processes?"),
+                                       selected_count);
+        } else {
+            /*xgettext: primary alert message for ending multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to end the %d selected processes?"),
+                                       selected_count);
+
+        }
+    }
+
+    if ( signal == SIGKILL ) {
+        /*xgettext: secondary alert message*/
+        secondary = _("Killing a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be killed.");
+        button_text = ngettext("_Kill Process", "_Kill Processes", selected_count);
+    } else {
+        /*xgettext: secondary alert message*/
+        secondary = _("Ending a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be ended.");
+        button_text = ngettext("_End Process", "_End Processes", selected_count);
+    }
+
+    kill_alert_dialog = gtk_message_dialog_new (GTK_WINDOW (procdata->app),
+                                                static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
+                                                GTK_MESSAGE_WARNING,
+                                                GTK_BUTTONS_NONE,
+                                                "%s",
+                                                primary);
+    g_free (primary);
+
+    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (kill_alert_dialog),
+                                              "%s",
+                                              secondary);
+
+    gtk_dialog_add_buttons (GTK_DIALOG (kill_alert_dialog),
+                            "gtk-cancel", GTK_RESPONSE_CANCEL,
+                            button_text, GTK_RESPONSE_OK,
+                            NULL);
+
+    gtk_dialog_set_default_response (GTK_DIALOG (kill_alert_dialog),
+                                     GTK_RESPONSE_CANCEL);
+
+    g_signal_connect (G_OBJECT (kill_alert_dialog), "response",
+                      G_CALLBACK (kill_dialog_button_pressed), kargs);
+
+    gtk_widget_show_all (kill_alert_dialog);
+}
+
+static void
+renice_scale_changed (GtkAdjustment *adj, gpointer data)
+{
+    GtkWidget *label = GTK_WIDGET (data);
+
+    new_nice_value = int(gtk_adjustment_get_value (adj));
+    gchar* text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (new_nice_value));
+    gtk_label_set_text (GTK_LABEL (label), text);
+    g_free(text);
+
+}
+
+static void
+renice_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (id == 100) {
+        if (new_nice_value == -100)
+            return;
+        renice(procdata, new_nice_value);
+    }
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+    renice_dialog = NULL;
+}
+
+void
+procdialog_create_renice_dialog (ProcData *procdata)
+{
+    ProcInfo  *info;
+    GtkWidget *dialog = NULL;
+    GtkWidget *dialog_vbox;
+    GtkWidget *vbox;
+    GtkWidget *label;
+    GtkWidget *priority_label;
+    GtkWidget *grid;
+    GtkAdjustment *renice_adj;
+    GtkWidget *hscale;
+    GtkWidget *button;
+    GtkWidget *icon;
+    gchar     *text;
+    gchar     *dialog_title;
+
+    if (renice_dialog)
+        return;
+
+    gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &info);
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if (!info)
+        return;
+
+    if ( selected_count == 1 ) {
+        dialog_title = g_strdup_printf (_("Change Priority of Process “%s†(PID: %u)"),
+                                        info->name, info->pid);
+    } else {
+        dialog_title = g_strdup_printf (_("Change Priority of %d Selected Processes"),
+                                        selected_count);
+    }
+
+    dialog = gtk_dialog_new_with_buttons (dialog_title, NULL,
+                                          GTK_DIALOG_DESTROY_WITH_PARENT,
+                                          "gtk-cancel", GTK_RESPONSE_CANCEL,
+                                          NULL);
+    g_free (dialog_title);
+
+    renice_dialog = dialog;
+    gtk_window_set_resizable (GTK_WINDOW (renice_dialog), FALSE);
+    gtk_container_set_border_width (GTK_CONTAINER (renice_dialog), 5);
+
+    button = gtk_button_new_with_mnemonic (_("Change _Priority"));
+    gtk_widget_set_can_default (button, TRUE);
+
+    icon = gtk_image_new_from_icon_name ("gtk-apply", GTK_ICON_SIZE_BUTTON);
+    gtk_button_set_image (GTK_BUTTON (button), icon);
+
+    gtk_dialog_add_action_widget (GTK_DIALOG (renice_dialog), button, 100);
+    gtk_dialog_set_default_response (GTK_DIALOG (renice_dialog), 100);
+    new_nice_value = -100;
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+    gtk_box_set_spacing (GTK_BOX (dialog_vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), vbox, TRUE, TRUE, 0);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+
+    grid = gtk_grid_new ();
+    gtk_grid_set_column_spacing (GTK_GRID(grid), 12);
+    gtk_grid_set_row_spacing (GTK_GRID(grid), 6);
+    gtk_box_pack_start (GTK_BOX (vbox), grid, TRUE, TRUE, 0);
+
+    label = gtk_label_new_with_mnemonic (_("_Nice value:"));
+    gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 2);
+
+    renice_adj = gtk_adjustment_new (info->nice, RENICE_VAL_MIN, RENICE_VAL_MAX, 1, 1, 0);
+    new_nice_value = 0;
+    hscale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, renice_adj);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), hscale);
+    gtk_scale_set_digits (GTK_SCALE (hscale), 0);
+    gtk_widget_set_hexpand (hscale, TRUE);
+    gtk_grid_attach (GTK_GRID (grid), hscale, 1, 0, 1, 1);
+    text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (info->nice));
+    priority_label = gtk_label_new (text);
+    gtk_grid_attach (GTK_GRID (grid), priority_label, 1, 1, 1, 1);
+    g_free(text);
+
+    text = g_strconcat("<small><i><b>", _("Note:"), "</b> ",
+        _("The priority of a process is given by its nice value. A lower nice value corresponds to a higher priority."),
+        "</i></small>", NULL);
+    label = gtk_label_new (_(text));
+    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+    g_free (text);
+
+    g_signal_connect (G_OBJECT (dialog), "response",
+                      G_CALLBACK (renice_dialog_button_pressed), procdata);
+    g_signal_connect (G_OBJECT (renice_adj), "value_changed",
+                      G_CALLBACK (renice_scale_changed), priority_label);
+
+    gtk_widget_show_all (dialog);
+
+
+}
+
+static void
+prefs_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    if (id == GTK_RESPONSE_HELP)
+    {
+        GError* error = 0;
+        if (!g_app_info_launch_default_for_uri("help:mate-system-monitor/mate-system-monitor-prefs", NULL, &error))
+        {
+            g_warning("Could not display preferences help : %s", error->message);
+            g_error_free(error);
+        }
+    }
+    else
+    {
+        gtk_widget_destroy (GTK_WIDGET (dialog));
+        prefs_dialog = NULL;
+    }
+}
+
+
+class SpinButtonUpdater
+{
+public:
+    SpinButtonUpdater(const string& key)
+        : key(key)
+    { }
+
+    static gboolean callback(GtkWidget *widget, GdkEventFocus *event, gpointer data)
+    {
+        SpinButtonUpdater* updater = static_cast<SpinButtonUpdater*>(data);
+        gtk_spin_button_update(GTK_SPIN_BUTTON(widget));
+        updater->update(GTK_SPIN_BUTTON(widget));
+        return FALSE;
+    }
+
+private:
+
+    void update(GtkSpinButton* spin)
+    {
+        int new_value = int(1000 * gtk_spin_button_get_value(spin));
+        g_settings_set_int(ProcData::get_instance()->settings,
+                           this->key.c_str(), new_value);
+
+        procman_debug("set %s to %d", this->key.c_str(), new_value);
+    }
+
+    const string key;
+};
+
+
+static void
+field_toggled (const gchar *child_schema, GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+    GtkTreeIter iter;
+    GtkTreeViewColumn *column;
+    gboolean toggled;
+    GSettings *settings = g_settings_get_child (ProcData::get_instance()->settings, child_schema);
+    gchar *key;
+    int id;
+
+    if (!path)
+        return;
+
+    gtk_tree_model_get_iter (model, &iter, path);
+
+    gtk_tree_model_get (model, &iter, 2, &column, -1);
+    toggled = gtk_cell_renderer_toggle_get_active (cell);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, !toggled, -1);
+    gtk_tree_view_column_set_visible (column, !toggled);
+
+    id = gtk_tree_view_column_get_sort_column_id (column);
+
+    key = g_strdup_printf ("col-%d-visible", id);
+    g_settings_set_boolean (settings, key, !toggled);
+    g_free (key);
+
+    gtk_tree_path_free (path);
+}
+
+static void
+proc_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("proctree", cell, path_str, data);
+}
+
+static void
+disk_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("disktreenew", cell, path_str, data);
+}
+
+static void
+create_field_page(GtkBuilder* builder, GtkWidget *tree, const gchar *widgetname)
+{
+    GtkTreeView *treeview;
+    GList *it, *columns;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;<--- Shadowed declaration
+    GtkCellRenderer *cell;
+    gchar *full_widgetname;
+
+    full_widgetname = g_strdup_printf ("%s_columns", widgetname);
+    treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, full_widgetname));
+    g_free (full_widgetname);
+
+    model = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER);
+
+    gtk_tree_view_set_model (GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(model));
+    g_object_unref (G_OBJECT (model));
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_toggle_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "active", 0,
+                                         NULL);
+
+    if (g_strcmp0 (widgetname, "proctree") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (proc_field_toggled), model);
+    else if (g_strcmp0 (widgetname, "disktreenew") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (disk_field_toggled), model);
+
+    gtk_tree_view_column_set_clickable (column, TRUE);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "text", 1,
+                                         NULL);
+
+    gtk_tree_view_column_set_title (column, "Not Shown");
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    for(it = columns; it; it = it->next)
+    {
+        GtkTreeViewColumn *column = static_cast<GtkTreeViewColumn*>(it->data);<--- Shadow variable
+        GtkTreeIter iter;
+        const gchar *title;
+        gboolean visible;
+        gint column_id;
+
+        title = gtk_tree_view_column_get_title (column);
+        if (!title)
+            title = _("Icon");
+
+        column_id = gtk_tree_view_column_get_sort_column_id(column);
+        if ((column_id == COL_CGROUP) && (!cgroups_enabled()))
+            continue;
+
+        if ((column_id == COL_UNIT ||
+             column_id == COL_SESSION ||
+             column_id == COL_SEAT ||
+             column_id == COL_OWNER)
+#ifdef HAVE_SYSTEMD
+            && !LOGIND_RUNNING()
+#endif
+                )
+            continue;
+
+        visible = gtk_tree_view_column_get_visible (column);
+
+        gtk_list_store_append (model, &iter);
+        gtk_list_store_set (model, &iter, 0, visible, 1, title, 2, column,-1);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procdialog_create_preferences_dialog (ProcData *procdata)
+{
+    typedef SpinButtonUpdater SBU;
+
+    static SBU interval_updater("update-interval");
+    static SBU graph_interval_updater("graph-update-interval");
+    static SBU disks_interval_updater("disks-interval");
+
+    GtkWidget *notebook;
+    GtkAdjustment *adjustment;
+    GtkWidget *spin_button;
+    GtkWidget *check_button;
+    GtkWidget *smooth_button;
+    GtkBuilder *builder;
+    gfloat update;
+
+    if (prefs_dialog)
+        return;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/preferences.ui");
+
+    prefs_dialog = GET_WIDGET("preferences_dialog");
+    notebook = GET_WIDGET("notebook");
+    spin_button = GET_WIDGET("processes_interval_spinner");
+
+    update = (gfloat) procdata->config.update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0,
+                                   MIN_UPDATE_INTERVAL / 1000,
+                                   MAX_UPDATE_INTERVAL / 1000,
+                                   0.25,
+                                   1.0,
+                                   0);
+
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK (SBU::callback), &interval_updater);
+
+    smooth_button = GET_WIDGET("smooth_button");
+    g_settings_bind(procdata->settings, SmoothRefresh::KEY.c_str(), smooth_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    check_button = GET_WIDGET("check_button");
+    g_settings_bind(procdata->settings, "kill-dialog", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    GtkWidget *solaris_button = GET_WIDGET("solaris_button");
+    g_settings_bind(procdata->settings, procman::settings::solaris_mode.c_str(), solaris_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->tree, "proctree");
+
+    update = (gfloat) procdata->config.graph_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0, 0.25,
+                                                      100.0, 0.25, 1.0, 0);
+
+    spin_button = GET_WIDGET("resources_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &graph_interval_updater);
+
+    GtkWidget *bits_button = GET_WIDGET("bits_button");
+    g_settings_bind(procdata->settings, procman::settings::network_in_bits.c_str(), bits_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+
+    update = (gfloat) procdata->config.disks_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new (update / 1000.0, 1.0,
+                                                       100.0, 1.0, 1.0, 0);
+
+    spin_button = GET_WIDGET("devices_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &disks_interval_updater);
+
+    check_button = GET_WIDGET("all_devices_check");
+    g_settings_bind(procdata->settings, "show-all-fs", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->disk_list, "disktreenew");
+
+    gtk_widget_show_all (prefs_dialog);
+    g_signal_connect (G_OBJECT (prefs_dialog), "response",
+                       G_CALLBACK (prefs_dialog_button_pressed), procdata);
+
+    switch (procdata->config.current_tab) {
+    case PROCMAN_TAB_SYSINFO:
+    case PROCMAN_TAB_PROCESSES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
+        break;
+    case PROCMAN_TAB_RESOURCES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 1);
+        break;
+    case PROCMAN_TAB_DISKS:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 2);
+        break;
+    }
+
+    gtk_builder_connect_signals (builder, NULL);
+    g_object_unref (G_OBJECT (builder));
+}
+
+
+static char *
+procman_action_to_command(ProcmanActionType type,
+                          gint pid,
+                          gint extra_value)
+{
+    switch (type) {
+    case PROCMAN_ACTION_KILL:
+           return g_strdup_printf("kill -s %d %d", extra_value, pid);
+    case PROCMAN_ACTION_RENICE:
+        return g_strdup_printf("renice %d %d", extra_value, pid);
+    default:
+        g_assert_not_reached();
+    }
+}
+
+
+/*
+ * type determines whether if dialog is for killing process or renice.
+ * type == PROCMAN_ACTION_KILL,   extra_value -> signal to send
+ * type == PROCMAN_ACTION_RENICE, extra_value -> new priority.
+ */
+gboolean
+procdialog_create_root_password_dialog(ProcmanActionType type,
+                                       ProcData *procdata,
+                                       gint pid,
+                                       gint extra_value)
+{
+    char * command;
+    gboolean ret = FALSE;
+
+    command = procman_action_to_command(type, pid, extra_value);
+
+    procman_debug("Trying to run '%s' as root", command);
+
+    if (procman_has_pkexec())
+        ret = procman_pkexec_create_root_password_dialog(command);
+    else if (procman_has_gksu())
+        ret = procman_gksu_create_root_password_dialog(command);
+
+    g_free(command);
+    return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/14.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/14.html new file mode 100644 index 00000000..3c8a776c --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/14.html @@ -0,0 +1,1109 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
#include <glib/gi18n.h>
+#include <glibtop.h>
+#include <glibtop/close.h>
+#include <glibtop/cpu.h>
+#include <glibtop/sysinfo.h>
+
+#include "procman-app.h"
+#include "procman.h"
+#include "interface.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "argv.h"
+#include "util.h"
+
+static void
+mount_changed(const Glib::RefPtr<Gio::Mount>&)
+{
+    cb_update_disks(ProcData::get_instance());
+}
+
+
+static void
+init_volume_monitor(ProcData *procdata)
+{
+    using namespace Gio;
+    using namespace Glib;
+
+    RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+    monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
+}
+
+static gboolean
+has_key (gchar **keys, const gchar *key)
+{
+    gchar **loop = keys;
+
+    while (*loop) {
+        if (!strcmp (*loop++, key))
+            return TRUE;
+    }
+
+    return FALSE;
+}
+
+static void
+tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_tree = g_settings_get_boolean(settings, key);
+
+    g_object_set(G_OBJECT(procdata->tree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
+    proctable_update (procdata);
+}
+
+
+static void
+network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
+    // force scale to be redrawn
+    procdata->net_graph->clear_background();
+}
+
+static void
+view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.whose_process = g_settings_get_int (settings, key);
+    procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2);
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "kill-dialog")) {
+        procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
+    }
+}
+
+static void
+timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "update-interval")) {
+        procdata->config.update_interval = g_settings_get_int (settings, key);
+        procdata->config.update_interval =
+            MAX (procdata->config.update_interval, 1000);
+
+        procdata->smooth_refresh->reset();
+
+        if(procdata->timeout) {
+            g_source_remove (procdata->timeout);
+            procdata->timeout = g_timeout_add (procdata->config.update_interval,
+                                               cb_timeout,
+                                               procdata);
+        }
+    }
+    else if (g_str_equal (key, "graph-update-interval")){
+        procdata->config.graph_update_interval = g_settings_get_int (settings, key);
+        procdata->config.graph_update_interval =
+            MAX (procdata->config.graph_update_interval,
+                 250);
+        load_graph_change_speed(procdata->cpu_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->mem_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->net_graph,
+                                procdata->config.graph_update_interval);
+    }
+    else if (g_str_equal(key, "disks-interval")) {
+        procdata->config.disks_update_interval = g_settings_get_int (settings, key);
+        procdata->config.disks_update_interval =
+            MAX (procdata->config.disks_update_interval, 1000);
+
+        if(procdata->disk_timeout) {
+            g_source_remove (procdata->disk_timeout);
+            procdata->disk_timeout = \
+                g_timeout_add (procdata->config.disks_update_interval,
+                               cb_update_disks,
+                               procdata);
+        }
+    }
+    else {
+        g_assert_not_reached();
+    }
+}
+
+static void
+color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    gchar *color = g_settings_get_string (settings, key);
+
+    if (g_str_has_prefix (key, "cpu-color")) {
+        for (int i = 0; i < procdata->config.num_cpus; i++) {
+            string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
+            if (cpu_key == key) {
+                gdk_rgba_parse (&procdata->config.cpu_color[i], color);
+                procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
+                break;
+            }
+        }
+    }
+    else if (g_str_equal (key, "mem-color")) {
+        gdk_rgba_parse (&procdata->config.mem_color, color);
+        procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
+    }
+    else if (g_str_equal (key, "swap-color")) {
+        gdk_rgba_parse (&procdata->config.swap_color, color);
+        procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
+    }
+    else if (g_str_equal (key, "net-in-color")) {
+        gdk_rgba_parse (&procdata->config.net_in_color, color);
+        procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
+    }
+    else if (g_str_equal (key, "net-out-color")) {
+        gdk_rgba_parse (&procdata->config.net_out_color, color);
+        procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
+    }
+    else {
+        g_assert_not_reached();
+    }
+    g_free(color);
+}
+
+static void
+show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
+
+    cb_update_disks (data);
+}
+
+static ProcData *
+procman_data_new (GSettings *settings)
+{
+    GSettingsSchema *schema;
+    ProcData *pd;
+    gchar *color;
+    gchar **keys;
+    glibtop_cpu cpu;
+
+    pd = ProcData::get_instance();
+
+    g_settings_get (settings, "window-state", "(iiii)",
+                    &pd->config.width, &pd->config.height,
+                    &pd->config.xpos, &pd->config.ypos);
+
+    pd->config.maximized = g_settings_get_boolean(settings, "maximized");
+
+    pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
+    g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd);
+
+    pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
+    std::string detail_string("changed::" + procman::settings::solaris_mode);
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd);
+
+    pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
+    detail_string = "changed::" + procman::settings::network_in_bits;
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd);
+
+    pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
+    g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd);
+    pd->config.update_interval = g_settings_get_int (settings, "update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.graph_update_interval = g_settings_get_int (settings,
+                                                           "graph-update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",
+                      G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd);
+
+
+    /* show_all_fs */
+    pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
+    g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd);
+
+
+    pd->config.whose_process = g_settings_get_int (settings, "view-as");
+    g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd);
+    pd->config.current_tab = g_settings_get_int (settings, "current-tab");
+
+    glibtop_get_cpu (&cpu);
+    pd->frequency = cpu.frequency;
+    pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
+
+    g_object_get (settings, "settings-schema", &schema, NULL);
+    keys = g_settings_schema_list_keys (schema);
+    g_settings_schema_unref (schema);
+
+    for (int i = 0; i < pd->config.num_cpus; i++) {
+        gchar *key;
+        key = g_strdup_printf ("cpu-color%d", i);
+
+        if (has_key (keys, key))
+            color = g_settings_get_string (settings, key);
+        else
+            color = g_strdup ("#f25915e815e8");
+        detail_string = std::string("changed::") + std::string(key);
+        g_signal_connect (G_OBJECT(settings), detail_string.c_str(),
+                          G_CALLBACK(color_changed_cb), pd);
+        gdk_rgba_parse (&pd->config.cpu_color[i], color);
+        g_free (color);
+        g_free (key);
+    }
+    g_strfreev (keys);
+
+    color = g_settings_get_string (settings, "mem-color");
+    if (!color)
+        color = g_strdup ("#000000ff0082");
+    g_signal_connect (G_OBJECT(settings), "changed::mem-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.mem_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "swap-color");
+    if (!color)
+        color = g_strdup ("#00b6000000ff");
+    g_signal_connect (G_OBJECT(settings), "changed::swap-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.swap_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-in-color");
+    if (!color)
+        color = g_strdup ("#000000f200f2");
+    g_signal_connect (G_OBJECT(settings), "changed::net-in-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_in_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-out-color");
+    if (!color)
+        color = g_strdup ("#00f2000000c1");
+    g_signal_connect (G_OBJECT(settings), "changed::net-out-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_out_color, color);
+    g_free (color);
+
+    /* Sanity checks */
+    GdkDisplay *display;
+    GdkMonitor *monitor;
+    GdkRectangle monitor_geometry;
+
+    display = gdk_display_get_default ();
+    monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
+    if (monitor == NULL) {
+        monitor = gdk_display_get_monitor (display, 0);
+    }
+    gdk_monitor_get_geometry (monitor, &monitor_geometry);
+
+    pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width);
+    pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height);
+    pd->config.update_interval = MAX (pd->config.update_interval, 1000);
+    pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250);
+    pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000);
+    pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2);
+    pd->config.current_tab = CLAMP(pd->config.current_tab,
+                                   PROCMAN_TAB_SYSINFO,
+                                   PROCMAN_TAB_DISKS);
+
+    // delayed initialization as SmoothRefresh() needs ProcData
+    // i.e. we can't call ProcData::get_instance
+    pd->smooth_refresh = new SmoothRefresh(settings);
+
+    pd->terminating = FALSE;
+
+    return pd;
+}
+
+static void
+procman_free_data (ProcData *procdata)
+{
+
+    proctable_free_table (procdata);
+    delete procdata->smooth_refresh;
+}
+
+ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)<--- Member variable 'ProcmanApp::procdata' is not initialized in the constructor.
+{
+    Glib::set_application_name(_("System Monitor"));
+}
+
+Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
+{
+    return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
+}
+
+void ProcmanApp::on_activate()
+{
+    gtk_window_present (GTK_WINDOW (procdata->app));
+}
+
+static void
+set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
+{
+    gtk_notebook_set_current_page(notebook, tab);
+    cb_change_current_page(notebook, tab, procdata);
+}
+
+int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
+{
+    int argc = 0;
+    char** argv = command_line->get_arguments(argc);
+
+    Glib::OptionContext context;
+    context.set_summary(_("A simple process and system monitor."));
+    context.set_ignore_unknown_options(true);
+    procman::OptionGroup option_group;
+    context.set_main_group(option_group);
+
+    try {
+        context.parse(argc, argv);
+    } catch (const Glib::Error& ex) {
+        g_error("Arguments parse error : %s", ex.what().c_str());
+    }
+
+    if (option_group.show_system_tab) {
+        procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_SYSINFO, procdata);
+    } else if (option_group.show_processes_tab) {
+        procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_PROCESSES, procdata);
+    } else if (option_group.show_resources_tab) {
+        procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_RESOURCES, procdata);
+    } else if (option_group.show_file_systems_tab) {
+        procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_DISKS, procdata);
+    }
+
+    on_activate ();
+
+    return 0;
+}
+
+void ProcmanApp::on_startup()
+{
+    Gtk::Application::on_startup();
+
+    GSettings *settings;
+
+    Gtk::Window::set_default_icon_name ("utilities-system-monitor");
+
+    settings = g_settings_new (GSM_GSETTINGS_SCHEMA);
+
+    glibtop_init ();
+
+    procdata = procman_data_new (settings);
+    procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA);
+
+    create_main_window (procdata);
+    init_volume_monitor (procdata);
+
+    Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app));
+    window->show();
+    window->set_name ("mate-system-monitor");
+
+    add_window (*window);
+}
+
+void ProcmanApp::on_shutdown()
+{
+    procman_free_data(procdata);
+    glibtop_close();
+}
+
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/15.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/15.html new file mode 100644 index 00000000..caf6d784 --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/15.html @@ -0,0 +1,671 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+
+#include <locale.h>
+
+#include <gtkmm.h>
+#include <glib/gi18n.h>
+
+#include "procman-app.h"
+#include "procman.h"
+#include "proctable.h"
+
+ProcData::ProcData()<--- Member variable 'ProcData::uimanager' is not initialized in the constructor.<--- Member variable 'ProcData::action_group' is not initialized in the constructor.<--- Member variable 'ProcData::statusbar' is not initialized in the constructor.<--- Member variable 'ProcData::loadavg' is not initialized in the constructor.<--- Member variable 'ProcData::endprocessbutton' is not initialized in the constructor.<--- Member variable 'ProcData::popup_menu' is not initialized in the constructor.<--- Member variable 'ProcData::disk_list' is not initialized in the constructor.<--- Member variable 'ProcData::notebook' is not initialized in the constructor.<--- Member variable 'ProcData::config' is not initialized in the constructor.<--- Member variable 'ProcData::selection' is not initialized in the constructor.<--- Member variable 'ProcData::settings' is not initialized in the constructor.<--- Member variable 'ProcData::app' is not initialized in the constructor.<--- Member variable 'ProcData::menu' is not initialized in the constructor.<--- Member variable 'ProcData::frequency' is not initialized in the constructor.<--- Member variable 'ProcData::smooth_refresh' is not initialized in the constructor.
+    : tree(NULL),
+      cpu_graph(NULL),
+      mem_graph(NULL),
+      net_graph(NULL),
+      selected_process(NULL),
+      timeout(0),
+      disk_timeout(0),
+      cpu_total_time(1),
+      cpu_total_time_last(1)
+{ }
+
+ProcData* ProcData::get_instance()
+{
+    static ProcData instance;
+    return &instance;
+}
+
+gboolean
+procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns, *it;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    sort_col = g_settings_get_int (pt_settings, "sort-col");
+
+    order = static_cast<GtkSortType>(g_settings_get_int (pt_settings, "sort-order"));
+
+    if (sort_col != -1)
+        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
+                                              sort_col,
+                                              order);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        for (it = columns; it; it = it->next)
+        {
+            GtkTreeViewColumn *column;
+            gint width;
+            gboolean visible;
+            int id;
+            gchar *key;
+
+            column = static_cast<GtkTreeViewColumn*>(it->data);
+            id = gtk_tree_view_column_get_sort_column_id (column);
+
+            key = g_strdup_printf ("col-%d-width", id);
+            g_settings_get (pt_settings, key, "i", &width);
+            g_free (key);
+
+            key = g_strdup_printf ("col-%d-visible", id);
+            visible = g_settings_get_boolean (pt_settings, key);
+            g_free (key);
+
+            gtk_tree_view_column_set_visible (column, visible);
+            if (visible) {
+                /* ensure column is really visible */
+                width = MAX(width, 20);
+                gtk_tree_view_column_set_fixed_width(column, width);
+            }
+        }
+
+        GVariant     *value;
+        GVariantIter iter;
+        int          sortIndex;
+
+        GSList *order = NULL;<--- Shadow variable
+
+        value = g_settings_get_value(pt_settings, "columns-order");
+        g_variant_iter_init(&iter, value);
+
+        while (g_variant_iter_loop (&iter, "i", &sortIndex))
+            order = g_slist_append(order, GINT_TO_POINTER(sortIndex));
+
+        proctable_set_columns_order(GTK_TREE_VIEW(tree), order);
+
+        g_variant_unref(value);
+        g_slist_free(order);
+    }
+
+    g_object_unref(pt_settings);
+    pt_settings = NULL;
+
+    g_list_free(columns);
+
+    return TRUE;
+}
+
+void
+procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    if (ProcData::get_instance()->terminating)
+        return;
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    if (gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (model), &sort_col,
+                                              &order)) {
+        g_settings_set_int (pt_settings, "sort-col", sort_col);
+        g_settings_set_int (pt_settings, "sort-order", order);
+    }
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        GSList *order;<--- Shadow variable
+        GSList *order_node;
+        GVariantBuilder *builder;
+        GVariant *order_variant;
+
+        order = proctable_get_columns_order(GTK_TREE_VIEW(tree));
+
+        builder = g_variant_builder_new (G_VARIANT_TYPE ("ai"));
+
+        for (order_node = order; order_node; order_node = order_node->next)
+            g_variant_builder_add(builder, "i", GPOINTER_TO_INT(order_node->data));
+
+        order_variant = g_variant_new("ai", builder);
+        g_settings_set_value(pt_settings, "columns-order", order_variant);
+
+        g_slist_free(order);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procman_save_config (ProcData *data)
+{
+    GSettings *settings = data->settings;
+
+    g_assert(data);
+
+    data->config.maximized = gdk_window_get_state(gtk_widget_get_window (data->app)) & GDK_WINDOW_STATE_MAXIMIZED;
+    if (!data->config.maximized) {
+        // we only want to store/overwrite size and position info with non-maximized state info
+        data->config.width  = gdk_window_get_width (gtk_widget_get_window (data->app));
+        data->config.height = gdk_window_get_height(gtk_widget_get_window (data->app));
+
+        gtk_window_get_position(GTK_WINDOW(data->app), &data->config.xpos, &data->config.ypos);
+
+        g_settings_set (settings, "window-state", "(iiii)",
+                        data->config.width, data->config.height,
+                        data->config.xpos, data->config.ypos);
+    }
+    g_settings_set_boolean (settings, "maximized", data->config.maximized);
+
+    g_settings_set_int (settings, "current-tab", data->config.current_tab);
+}
+
+int
+main (int argc, char *argv[])
+{
+    bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+    textdomain (GETTEXT_PACKAGE);
+    setlocale (LC_ALL, "");
+
+    Glib::RefPtr<ProcmanApp> application = ProcmanApp::create();
+    return application->run (argc, argv);
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/16.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/16.html new file mode 100644 index 00000000..91267585 --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/16.html @@ -0,0 +1,913 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
/* Process properties dialog
+ * Copyright (C) 2010 Krishnan Parthasarathi <krishnan.parthasarathi@gmail.com>
+ *                    Robert Ancell <robert.ancell@canonical.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <glibtop/procmem.h>
+#include <glibtop/procmap.h>
+#include <glibtop/procstate.h>
+
+#include "procman.h"
+#include "procproperties.h"
+#include "proctable.h"
+#include "util.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
+enum
+{
+    COL_PROP = 0,
+    COL_VAL,
+    NUM_COLS,
+};
+
+typedef struct _proc_arg {
+    const gchar *prop;
+    gchar *val;
+} proc_arg;
+
+static void
+get_process_memory_writable (ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info (ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+static gchar*
+format_memsize(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
+}
+
+static gchar*
+format_size(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size(size);
+}
+
+static void
+fill_proc_properties (GtkWidget *tree, ProcInfo *info)
+{
+    guint i;
+    GtkListStore *store;
+
+    if (!info)
+        return;
+
+    get_process_memory_info(info);
+
+    proc_arg proc_props[] = {
+        { N_("Process Name"), g_strdup_printf("%s", info->name)},
+        { N_("User"), g_strdup_printf("%s (%d)", info->user.c_str(), info->uid)},
+        { N_("Status"), g_strdup(format_process_state(info->status))},
+        { N_("Memory"), format_memsize(info->mem)},
+        { N_("Virtual Memory"), format_memsize(info->vmsize)},
+        { N_("Resident Memory"), format_memsize(info->memres)},
+        { N_("Writable Memory"), format_memsize(info->memwritable)},
+        { N_("Shared Memory"), format_memsize(info->memshared)},
+#ifdef HAVE_WNCK
+        { N_("X Server Memory"), format_memsize(info->memxserver)},
+#endif
+        { N_("Disk Read Total"), format_size(info->disk_read_bytes_total)},
+        { N_("Disk Write Total"), format_size(info->disk_write_bytes_total)},
+        { N_("CPU"), g_strdup_printf("%d%%", info->pcpu)},
+        { N_("CPU Time"), procman::format_duration_for_display(100 * info->cpu_time / ProcData::get_instance()->frequency) },
+        { N_("Started"), procman_format_date_for_display(info->start_time) },
+        { N_("Nice"), g_strdup_printf("%d", info->nice)},
+        { N_("Priority"), g_strdup_printf("%s", procman::get_nice_level(info->nice)) },
+        { N_("ID"), g_strdup_printf("%d", info->pid)},
+        { N_("Security Context"), info->security_context ? g_strdup_printf("%s", info->security_context) : g_strdup(_("N/A"))},
+        { N_("Command Line"), g_strdup_printf("%s", info->arguments)},
+        { N_("Waiting Channel"), g_strdup_printf("%s", info->wchan)},
+        { N_("Control Group"), info->cgroup_name ? g_strdup_printf("%s", info->cgroup_name) : g_strdup(_("N/A"))},
+        { NULL, NULL}
+    };
+
+    store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
+    for (i = 0; proc_props[i].prop; i++) {
+        GtkTreeIter iter;
+
+        if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL(store), &iter, NULL, i)) {
+            gtk_list_store_append(store, &iter);
+            gtk_list_store_set(store, &iter, COL_PROP, _(proc_props[i].prop), -1);
+        }
+
+        gtk_list_store_set(store, &iter, COL_VAL, g_strstrip(proc_props[i].val), -1);
+        g_free(proc_props[i].val);
+    }
+}
+
+static void
+update_procproperties_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    fill_proc_properties(tree, info);
+}
+
+static void
+close_procprop_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    guint timer;
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static GtkWidget *
+create_procproperties_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    model = gtk_list_store_new (NUM_COLS,
+                                G_TYPE_STRING,	/* Property */
+                                G_TYPE_STRING	/* Value */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_COLS; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        column = gtk_tree_view_column_new_with_attributes (NULL,
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tree), FALSE);
+    fill_proc_properties(tree, procdata->selected_process);
+
+    return tree;
+}
+
+static gboolean
+procprop_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_procproperties_dialog (tree);
+
+    return TRUE;
+}
+
+static void
+create_single_procproperties_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                     GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *procpropdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    procpropdialog = gtk_dialog_new_with_buttons (_("Process Properties"), NULL,
+                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                  "gtk-close", GTK_RESPONSE_CLOSE,
+                                                  NULL);
+    gtk_window_set_resizable (GTK_WINDOW (procpropdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (procpropdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (procpropdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (procpropdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("Properties of process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_procproperties_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (procpropdialog), "response",
+                      G_CALLBACK (close_procprop_dialog), tree);
+
+    gtk_widget_show_all (procpropdialog);
+
+    timer = g_timeout_add_seconds (5, procprop_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_procproperties_dialog (tree);
+}
+
+void
+create_procproperties_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_procproperties_dialog,
+                                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/17.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/17.html new file mode 100644 index 00000000..3ce08395 --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/17.html @@ -0,0 +1,2635 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
/* Procman tree view and process updating
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <cairo-gobject.h>
+#include <string.h>
+#include <math.h>
+#include <glib/gi18n.h>
+#include <glib/gprintf.h>
+#include <glibtop.h>
+#include <glibtop/loadavg.h>
+#include <glibtop/proclist.h>
+#include <glibtop/procio.h>
+#include <glibtop/procstate.h>
+#include <glibtop/procmem.h>
+#include <glibtop/procmap.h>
+#include <glibtop/proctime.h>
+#include <glibtop/procuid.h>
+#include <glibtop/procargs.h>
+#include <glibtop/prockernel.h>
+#include <glibtop/mem.h>
+#include <glibtop/swap.h>
+#include <sys/stat.h>
+#include <pwd.h>
+#include <time.h>
+
+#include <set>
+#include <list>
+
+#ifdef HAVE_SYSTEMD
+#include <systemd/sd-login.h>
+#endif
+
+#include "procman.h"
+#include "selection.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "util.h"
+#include "interface.h"
+#include "selinux.h"
+#include "cgroups.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
+ProcInfo::UserMap ProcInfo::users;
+ProcInfo::List ProcInfo::all;
+std::map<pid_t, guint64> ProcInfo::cpu_times;
+
+
+ProcInfo* ProcInfo::find(pid_t pid)
+{
+    Iterator it(ProcInfo::all.find(pid));
+    return (it == ProcInfo::all.end() ? NULL : it->second);
+}
+
+void
+get_last_selected (GtkTreeModel *model, GtkTreePath *path,
+           GtkTreeIter *iter, gpointer data)
+{
+    ProcInfo **info = static_cast<ProcInfo**>(data);
+
+    gtk_tree_model_get (model, iter, COL_POINTER, info, -1);
+}
+
+static void
+cb_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "proctree");
+}
+
+static void
+cb_sort_changed (GtkTreeSortable *model, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state (procdata->settings,
+                             GTK_WIDGET (procdata->tree),
+                             "proctree");
+}
+
+
+static GtkTreeViewColumn*
+my_gtk_tree_view_get_column_with_sort_column_id(GtkTreeView *treeview, int id)
+{
+    GList *columns, *it;
+    GtkTreeViewColumn *col = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(it = columns; it; it = it->next)
+    {
+        if(gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(it->data)) == id)
+        {
+            col = static_cast<GtkTreeViewColumn*>(it->data);
+            break;
+        }
+    }
+
+    g_list_free(columns);
+
+    return col;
+}
+
+
+void
+proctable_set_columns_order(GtkTreeView *treeview, GSList *order)
+{
+    GtkTreeViewColumn* last = NULL;
+    GSList *it;
+
+    for(it = order; it; it = it->next)
+    {
+        int id;
+        GtkTreeViewColumn *cur;
+
+        id = GPOINTER_TO_INT(it->data);
+
+        cur = my_gtk_tree_view_get_column_with_sort_column_id(treeview, id);
+
+        if(cur && cur != last)
+        {
+            gtk_tree_view_move_column_after(treeview, cur, last);
+            last = cur;
+        }
+    }
+}
+
+
+GSList*
+proctable_get_columns_order(GtkTreeView *treeview)
+{
+    GList *columns, *col;
+    GSList *order = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(col = columns; col; col = col->next)
+    {
+        int id;
+
+        id = gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(col->data));
+        order = g_slist_prepend(order, GINT_TO_POINTER(id));
+    }
+
+    g_list_free(columns);
+
+    order = g_slist_reverse(order);
+
+    return order;
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "proctree");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_proctable_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+static gboolean
+search_equal_func(GtkTreeModel *model,
+                  gint column,
+                  const gchar *key,
+                  GtkTreeIter *iter,
+                  gpointer search_data)
+{
+    char* name;
+    char* user;
+    gboolean found;
+
+    gtk_tree_model_get(model, iter,
+                       COL_NAME, &name,
+                       COL_USER, &user,
+                       -1);
+
+    found = !((name && strcasestr(name, key))
+              || (user && strcasestr(user, key)));
+
+    g_free(name);
+    g_free(user);
+
+    return found;
+}
+
+
+
+GtkWidget *
+proctable_new (ProcData * const procdata)
+{
+    GtkWidget *proctree;
+    GtkTreeStore *model;
+    GtkTreeSelection *selection;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell_renderer;
+
+    const gchar *titles[] = {
+        N_("Process Name"),
+        N_("User"),
+        N_("Status"),
+        N_("Virtual Memory"),
+        N_("Resident Memory"),
+        N_("Writable Memory"),
+        N_("Shared Memory"),
+        N_("X Server Memory"),
+        /* xgettext:no-c-format */ N_("% CPU"),
+        N_("CPU Time"),
+        N_("Started"),
+        N_("Nice"),
+        N_("ID"),
+        N_("Security Context"),
+        N_("Command Line"),
+        N_("Memory"),
+        /* xgettext: combined noun, the function the process is waiting in, see wchan ps(1) */
+        N_("Waiting Channel"),
+        N_("Control Group"),
+        N_("Unit"),
+        N_("Session"),
+        /* TRANSLATORS: Seat = i.e. the physical seat the session of the process belongs to, only
+	for multi-seat environments. See http://en.wikipedia.org/wiki/Multiseat_configuration */
+        N_("Seat"),
+        N_("Owner"),
+        N_("Disk Read Total"),
+        N_("Disk Write Total"),
+        N_("Disk Read"),
+        N_("Disk Write"),
+        N_("Priority"),
+        NULL,
+        "POINTER"
+    };
+
+    gint i;
+
+    model = gtk_tree_store_new (NUM_COLUMNS,
+                                G_TYPE_STRING,              /* Process Name */
+                                G_TYPE_STRING,              /* User         */
+                                G_TYPE_UINT,                /* Status       */
+                                G_TYPE_ULONG,               /* VM Size      */
+                                G_TYPE_ULONG,               /* Resident Memory */
+                                G_TYPE_ULONG,               /* Writable Memory */
+                                G_TYPE_ULONG,               /* Shared Memory */
+                                G_TYPE_ULONG,               /* X Server Memory */
+                                G_TYPE_UINT,                /* % CPU        */
+                                G_TYPE_UINT64,              /* CPU time     */
+                                G_TYPE_ULONG,               /* Started      */
+                                G_TYPE_INT,                 /* Nice         */
+                                G_TYPE_UINT,                /* ID           */
+                                G_TYPE_STRING,              /* Security Context */
+                                G_TYPE_STRING,              /* Arguments    */
+                                G_TYPE_ULONG,               /* Memory       */
+                                G_TYPE_STRING,              /* wchan        */
+                                G_TYPE_STRING,              /* Cgroup       */
+                                G_TYPE_STRING,              /* Unit         */
+                                G_TYPE_STRING,              /* Session      */
+                                G_TYPE_STRING,              /* Seat         */
+                                G_TYPE_STRING,              /* Owner        */
+                                G_TYPE_UINT64,              /* Disk read total */
+                                G_TYPE_UINT64,              /* Disk write total*/
+                                G_TYPE_UINT64,              /* Disk read    */
+                                G_TYPE_UINT64,              /* Disk write   */
+                                G_TYPE_STRING,              /* Priority     */
+                                CAIRO_GOBJECT_TYPE_SURFACE, /* Icon         */
+                                G_TYPE_POINTER,             /* ProcInfo     */
+                                G_TYPE_STRING               /* Sexy tooltip */
+        );
+
+    proctree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (proctree), COL_TOOLTIP);
+    g_object_set(G_OBJECT(proctree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+    gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (proctree),
+                                         search_equal_func,
+                                         NULL,
+                                         NULL);
+    g_object_unref (G_OBJECT (model));
+
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree));
+    gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+
+    column = gtk_tree_view_column_new ();
+
+    cell_renderer = gtk_cell_renderer_pixbuf_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "surface", COL_SURFACE,
+                                         NULL);
+
+    cell_renderer = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "text", COL_NAME,
+                                         NULL);
+    gtk_tree_view_column_set_title (column, _(titles[0]));
+    gtk_tree_view_column_set_sort_column_id (column, COL_NAME);
+    gtk_tree_view_column_set_resizable (column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+    gtk_tree_view_column_set_min_width (column, 20);
+    gtk_tree_view_column_set_reorderable (column, TRUE);
+    g_signal_connect(G_OBJECT(column), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (proctree), column);
+    gtk_tree_view_set_expander_column (GTK_TREE_VIEW (proctree), column);
+
+
+    for (i = COL_USER; i <= COL_PRIORITY; i++) {
+
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+#ifndef HAVE_WNCK
+        if (i == COL_MEMXSERVER) {
+          continue;
+        }
+#endif
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(proctree), col);
+
+        // type
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_CPU_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::duration_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_START_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::time_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_STATUS:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::status_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::io_rate_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_PRIORITY:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::priority_cell_data_func,
+                                                        GUINT_TO_POINTER(COL_NICE),
+                                                        NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+        }
+
+        // sorting
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+            case COL_CPU:
+            case COL_CPU_TIME:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_START_TIME:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::number_compare_func, GUINT_TO_POINTER(i),
+                                                NULL);
+                break;
+            case COL_PRIORITY:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::priority_compare_func,
+                                                GUINT_TO_POINTER(COL_NICE), NULL);
+                break;
+            default:
+                break;
+        }
+
+        // xalign
+        switch(i)
+        {
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMWRITABLE:
+            case COL_MEMSHARED:
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_CPU:
+            case COL_NICE:
+            case COL_PID:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_CPU_TIME:
+            case COL_MEM:
+                g_object_set(G_OBJECT(cell), "xalign", 1.0f, NULL);
+                break;
+        }
+
+        // sizing
+        switch (i) {
+            case COL_ARGS:
+                gtk_tree_view_column_set_min_width(col, 150);
+                break;
+            default:
+                gtk_tree_view_column_set_min_width(col, 20);
+                break;
+        }
+    }
+
+    procdata->tree = proctree;
+
+    procman_get_tree_state (procdata->settings, proctree, "proctree");
+
+    /* Override column settings by hiding this column if it's meaningless: */
+    if (!can_show_security_context_column ()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id (GTK_TREE_VIEW (proctree), COL_SECURITYCONTEXT);
+        gtk_tree_view_column_set_visible (column, FALSE);
+    }
+
+    if (!cgroups_enabled()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), COL_CGROUP);
+        gtk_tree_view_column_set_visible(column, FALSE);
+    }
+
+#ifdef HAVE_SYSTEMD
+    if (!LOGIND_RUNNING())
+#endif
+    {
+        for (i = COL_UNIT; i <= COL_OWNER; i++) {
+            column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), i);
+            gtk_tree_view_column_set_visible(column, FALSE);
+        }
+    }
+
+    g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree))),
+                      "changed",
+                      G_CALLBACK (cb_row_selected), procdata);
+    g_signal_connect (G_OBJECT (proctree), "popup_menu",
+                      G_CALLBACK (cb_tree_popup_menu), procdata);
+    g_signal_connect (G_OBJECT (proctree), "button_press_event",
+                      G_CALLBACK (cb_tree_button_pressed), procdata);
+
+    g_signal_connect (G_OBJECT(proctree), "columns-changed",
+                      G_CALLBACK(cb_columns_changed), procdata);
+
+    g_signal_connect (G_OBJECT (model), "sort-column-changed",
+                      G_CALLBACK (cb_sort_changed), procdata);
+
+    return proctree;
+}
+
+
+ProcInfo::~ProcInfo()
+{
+    g_free(this->name);
+    g_free(this->tooltip);
+    g_free(this->arguments);
+    g_free(this->security_context);
+    g_free(this->cgroup_name);
+    g_free(this->unit);
+    g_free(this->session);
+    g_free(this->seat);
+    cairo_surface_destroy(this->surface);
+}
+
+
+static void
+get_process_name (ProcInfo *info,
+                  const gchar *cmd, const GStrv args)
+{
+    if (args) {
+        // look for /usr/bin/very_long_name
+        // and also /usr/bin/interpreter /usr/.../very_long_name
+        // which may have use prctl to alter 'cmd' name
+        for (int i = 0; i != 2 && args[i]; ++i) {
+            char* basename;
+            basename = g_path_get_basename(args[i]);
+
+            if (g_str_has_prefix(basename, cmd)) {
+                info->name = basename;
+                return;
+            }
+
+            g_free(basename);
+        }
+    }
+
+    info->name = g_strdup (cmd);
+}
+
+std::string
+ProcInfo::lookup_user(guint uid)
+{
+    typedef std::pair<ProcInfo::UserMap::iterator, bool> Pair;
+    ProcInfo::UserMap::value_type hint(uid, "");
+    Pair p(ProcInfo::users.insert(hint));
+
+    // procman_debug("User lookup for uid %u: %s", uid, (p.second ? "MISS" : "HIT"));
+
+    if (p.second) {
+        struct passwd* pwd;
+        pwd = getpwuid(uid);
+
+        if (pwd && pwd->pw_name)
+            p.first->second = pwd->pw_name;
+        else {
+            char username[16];
+            g_sprintf(username, "%u", uid);
+            p.first->second = username;
+        }
+    }
+
+    return p.first->second;
+}
+
+void
+ProcInfo::set_user(guint uid)
+{
+    if (G_LIKELY(this->uid == uid))
+        return;
+
+    this->uid = uid;
+    this->user = lookup_user(uid);
+}
+
+static void get_process_memory_writable(ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info(ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+
+static void
+update_info_mutable_cols(ProcInfo *info)
+{
+    ProcData * const procdata = ProcData::get_instance();
+    GtkTreeModel *model;
+    model = gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->tree));
+
+    using procman::tree_store_update;
+
+    tree_store_update(model, &info->node, COL_STATUS, info->status);
+    tree_store_update(model, &info->node, COL_USER, info->user.c_str());
+    tree_store_update(model, &info->node, COL_VMSIZE, info->vmsize);
+    tree_store_update(model, &info->node, COL_MEMRES, info->memres);
+    tree_store_update(model, &info->node, COL_MEMWRITABLE, info->memwritable);
+    tree_store_update(model, &info->node, COL_MEMSHARED, info->memshared);
+#ifdef HAVE_WNCK
+    tree_store_update(model, &info->node, COL_MEMXSERVER, info->memxserver);
+#endif
+    tree_store_update(model, &info->node, COL_CPU, info->pcpu);
+    tree_store_update(model, &info->node, COL_CPU_TIME, info->cpu_time);
+    tree_store_update(model, &info->node, COL_DISK_READ_TOTAL, info->disk_read_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_TOTAL, info->disk_write_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_READ_CURRENT, info->disk_read_bytes_current);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_CURRENT, info->disk_write_bytes_current);
+    tree_store_update(model, &info->node, COL_START_TIME, info->start_time);
+    tree_store_update(model, &info->node, COL_NICE, info->nice);
+    tree_store_update(model, &info->node, COL_MEM, info->mem);
+    tree_store_update(model, &info->node, COL_WCHAN, info->wchan);
+    tree_store_update(model, &info->node, COL_CGROUP, info->cgroup_name);
+    tree_store_update(model, &info->node, COL_UNIT, info->unit);
+    tree_store_update(model, &info->node, COL_SESSION, info->session);
+    tree_store_update(model, &info->node, COL_SEAT, info->seat);
+    tree_store_update(model, &info->node, COL_OWNER, info->owner.c_str());
+}
+
+
+
+static void
+insert_info_to_tree (ProcInfo *info, ProcData *procdata, bool forced = false)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    if (procdata->config.show_tree) {
+
+        ProcInfo *parent = 0;
+
+        if (not forced)
+            parent = ProcInfo::find(info->ppid);
+
+        if (parent) {
+            GtkTreePath *parent_node = gtk_tree_model_get_path(model, &parent->node);
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, &parent->node, 0);
+
+            if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(procdata->tree), parent_node)
+#ifdef __linux__
+                // on linuxes we don't want to expand kthreadd by default (always has pid 2)
+                && (parent->pid != 2)
+#endif
+            )
+                gtk_tree_view_expand_row(GTK_TREE_VIEW(procdata->tree), parent_node, FALSE);
+            gtk_tree_path_free(parent_node);
+        } else
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, NULL, 0);
+    }
+    else
+        gtk_tree_store_insert (GTK_TREE_STORE (model), &info->node, NULL, 0);
+
+    gtk_tree_store_set (GTK_TREE_STORE (model), &info->node,
+                        COL_POINTER, info,
+                        COL_NAME, info->name,
+                        COL_ARGS, info->arguments,
+                        COL_TOOLTIP, info->tooltip,
+                        COL_PID, info->pid,
+                        COL_SECURITYCONTEXT, info->security_context,
+                        -1);
+
+    procdata->pretty_table.set_icon(*info);
+
+    procman_debug("inserted %d%s", info->pid, (forced ? " (forced)" : ""));
+}
+
+
+/* Removing a node with children - make sure the children are queued
+** to be readded.
+*/
+template<typename List>
+static void
+remove_info_from_tree (ProcData *procdata, GtkTreeModel *model,
+                       ProcInfo *current, List &orphans, unsigned lvl = 0)
+{
+    GtkTreeIter child_node;
+
+    if (std::find(orphans.begin(), orphans.end(), current) != orphans.end()) {
+        procman_debug("[%u] %d already removed from tree", lvl, int(current->pid));
+        return;
+    }
+
+    procman_debug("[%u] pid %d, %d children", lvl, int(current->pid),
+                  gtk_tree_model_iter_n_children(model, &current->node));
+
+    // it is not possible to iterate&erase over a treeview so instead we
+    // just pop one child after another and recursively remove it and
+    // its children
+
+    while (gtk_tree_model_iter_children(model, &child_node, &current->node)) {
+        ProcInfo *child = 0;
+        gtk_tree_model_get(model, &child_node, COL_POINTER, &child, -1);
+        remove_info_from_tree(procdata, model, child, orphans, lvl + 1);
+    }
+
+    g_assert(not gtk_tree_model_iter_has_child(model, &current->node));
+
+    if (procdata->selected_process == current)
+        procdata->selected_process = NULL;
+
+    orphans.push_back(current);
+    gtk_tree_store_remove(GTK_TREE_STORE(model), &current->node);
+    procman::poison(current->node, 0x69);
+}
+
+static void
+get_process_systemd_info(ProcInfo *info)
+{
+#ifdef HAVE_SYSTEMD
+    uid_t uid;
+
+    if (!LOGIND_RUNNING())
+        return;
+
+    free(info->unit);
+    info->unit = NULL;
+    sd_pid_get_unit(info->pid, &info->unit);
+
+    free(info->session);
+    info->session = NULL;
+    sd_pid_get_session(info->pid, &info->session);
+
+    free(info->seat);
+    info->seat = NULL;
+
+    if (info->session != NULL)
+        sd_session_get_seat(info->session, &info->seat);
+
+    if (sd_pid_get_owner_uid(info->pid, &uid) >= 0)
+        info->owner = info->lookup_user(uid);
+    else
+        info->owner = "";
+#endif
+}
+
+static void
+update_info (ProcData *procdata, ProcInfo *info)
+{
+    glibtop_proc_state procstate;
+    glibtop_proc_uid procuid;
+    glibtop_proc_time proctime;
+    glibtop_proc_kernel prockernel;
+    glibtop_proc_io procio;
+
+    glibtop_get_proc_kernel(&prockernel, info->pid);
+    g_strlcpy(info->wchan, prockernel.wchan, sizeof info->wchan);
+
+    glibtop_get_proc_state (&procstate, info->pid);
+    info->status = procstate.state;
+
+    glibtop_get_proc_uid (&procuid, info->pid);
+    glibtop_get_proc_time (&proctime, info->pid);
+    glibtop_get_proc_io (&procio, info->pid);
+
+    get_process_memory_info(info);
+
+    info->set_user(procstate.uid);
+
+    // if the cpu time has increased reset the status to running
+    // regardless of kernel state (https://bugzilla.gnome.org/606579)
+    guint64 difference = proctime.rtime - info->cpu_time;
+    if (difference > 0)
+        info->status = GLIBTOP_PROCESS_RUNNING;
+    info->pcpu = difference * 100 / procdata->cpu_total_time;
+    info->pcpu = MIN(info->pcpu, 100);
+
+    if (not procdata->config.solaris_mode)
+      info->pcpu *= procdata->config.num_cpus;
+
+    ProcInfo::cpu_times[info->pid] = info->cpu_time = proctime.rtime;
+    info->nice = procuid.nice;
+
+    gdouble update_interval_seconds = procdata->config.update_interval / 1000.0;
+    difference = procio.disk_wbytes - info->disk_write_bytes_total;
+    info->disk_write_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+    difference = procio.disk_rbytes - info->disk_read_bytes_total;
+    info->disk_read_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+
+    info->disk_write_bytes_total = procio.disk_wbytes;
+    info->disk_read_bytes_total = procio.disk_rbytes;
+
+    // set the ppid only if one can exist
+    // i.e. pid=0 can never have a parent
+    if (info->pid > 0) {
+        info->ppid = procuid.ppid;
+    }
+
+    g_assert(info->pid != info->ppid);
+    g_assert(info->ppid != -1 || info->pid == 0);
+
+    /* get cgroup data */
+    get_process_cgroup_info(info);
+
+    get_process_systemd_info(info);
+}
+
+
+ProcInfo::ProcInfo(pid_t pid)
+    : node(),
+      surface(),
+      tooltip(NULL),
+      name(NULL),
+      arguments(NULL),
+      security_context(NULL),
+      pid(pid),
+      ppid(-1),
+      uid(-1)
+{
+    ProcInfo * const info = this;
+    glibtop_proc_state procstate;
+    glibtop_proc_time proctime;
+    glibtop_proc_args procargs;
+    gchar** arguments;<--- Shadow variable
+
+    glibtop_get_proc_state (&procstate, pid);
+    glibtop_get_proc_time (&proctime, pid);
+    arguments = glibtop_get_proc_argv (&procargs, pid, 0);
+
+    /* FIXME : wrong. name and arguments may change with exec* */
+    get_process_name (info, procstate.cmd, static_cast<const GStrv>(arguments));
+
+    std::string tooltip = make_string(g_strjoinv(" ", arguments));<--- Shadow variable
+    if (tooltip.empty())
+        tooltip = procstate.cmd;
+
+    info->tooltip = g_markup_escape_text(tooltip.c_str(), -1);
+
+    info->arguments = g_strescape(tooltip.c_str(), "\\\"");
+    g_strfreev(arguments);
+
+    guint64 cpu_time = proctime.rtime;
+    std::map<pid_t, guint64>::iterator it(ProcInfo::cpu_times.find(pid));
+    if (it != ProcInfo::cpu_times.end())
+    {
+        if (proctime.rtime >= it->second)
+          cpu_time = it->second;
+    }
+    info->cpu_time = cpu_time;
+    info->start_time = proctime.start_time;
+
+    get_process_selinux_context (info);
+    info->cgroup_name = NULL;
+    get_process_cgroup_info(info);
+
+    info->unit = info->session = info->seat = NULL;
+    get_process_systemd_info(info);
+}
+
+static void
+refresh_list (ProcData *procdata, const pid_t* pid_list, const guint n)
+{
+    typedef std::list<ProcInfo*> ProcList;
+    ProcList addition;
+
+    GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+    guint i;
+
+    // Add or update processes in the process list
+    for(i = 0; i < n; ++i) {
+        ProcInfo *info = ProcInfo::find(pid_list[i]);
+
+        if (!info) {
+            info = new ProcInfo(pid_list[i]);
+            ProcInfo::all[info->pid] = info;
+            addition.push_back(info);
+        }
+
+        update_info (procdata, info);
+    }
+
+
+    // Remove dead processes from the process list and from the
+    // tree. children are queued to be readded at the right place
+    // in the tree.
+
+    const std::set<pid_t> pids(pid_list, pid_list + n);
+
+    ProcInfo::Iterator it(ProcInfo::begin());<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration
+
+    while (it != ProcInfo::end()) {
+        ProcInfo * const info = it->second;
+        ProcInfo::Iterator next(it);
+        ++next;
+
+        if (pids.find(info->pid) == pids.end()) {
+            procman_debug("ripping %d", info->pid);
+            remove_info_from_tree(procdata, model, info, addition);
+            addition.remove(info);
+            ProcInfo::all.erase(it);
+            delete info;
+        }
+
+        it = next;
+    }
+
+    // INVARIANT
+    // pid_list == ProcInfo::all + addition
+
+
+    if (procdata->config.show_tree) {
+
+        // insert process in the tree. walk through the addition list
+        // (new process + process that have a new parent). This loop
+        // handles the dependencies because we cannot insert a process
+        // until its parent is in the tree.
+
+        std::set<pid_t> in_tree(pids);
+
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            in_tree.erase((*it)->pid);
+
+
+        while (not addition.empty()) {
+            procman_debug("looking for %d parents", int(addition.size()));
+            ProcList::iterator it(addition.begin());<--- Shadow variable
+
+            while (it != addition.end()) {
+                procman_debug("looking for %d's parent with ppid %d",
+                              int((*it)->pid), int((*it)->ppid));
+
+
+                // inserts the process in the treeview if :
+                // - it has no parent (ppid = -1),
+                //   ie it is for example the [kernel] on FreeBSD
+                // - it is init
+                // - its parent is already in tree
+                // - its parent is unreachable
+                //
+                // rounds == 2 means that addition contains processes with
+                // unreachable parents
+                //
+                // FIXME: this is broken if the unreachable parent becomes active
+                // i.e. it gets active or changes ower
+                // so we just clear the tree on __each__ update
+                // see proctable_update_list (ProcData * const procdata)
+
+
+                if ((*it)->ppid <= 0 or in_tree.find((*it)->ppid) != in_tree.end()) {
+                    insert_info_to_tree(*it, procdata);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ProcInfo *parent = ProcInfo::find((*it)->ppid);
+                // if the parent is unreachable
+                if (not parent) {
+                    // or std::find(addition.begin(), addition.end(), parent) == addition.end()) {
+                    insert_info_to_tree(*it, procdata, true);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ++it;
+            }
+        }
+    }
+    else {
+        // don't care of the tree
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            insert_info_to_tree(*it, procdata);
+    }
+
+
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)<--- Shadow variable
+        update_info_mutable_cols(it->second);
+}
+
+
+static void
+proctable_update_list (ProcData * const procdata)
+{
+    pid_t* pid_list;
+    glibtop_proclist proclist;
+    glibtop_cpu cpu;
+    gint which, arg;
+    procman::SelectionMemento selection;
+
+    switch (procdata->config.whose_process) {
+        case ALL_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL;
+            arg = 0;
+            break;
+
+        case ACTIVE_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL | GLIBTOP_EXCLUDE_IDLE;
+            arg = 0;
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+
+        default:
+            which = GLIBTOP_KERN_PROC_UID;
+            arg = getuid ();
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+    }
+
+    pid_list = glibtop_get_proclist (&proclist, which, arg);
+
+    /* FIXME: total cpu time elapsed should be calculated on an individual basis here
+    ** should probably have a total_time_last gint in the ProcInfo structure */
+    glibtop_get_cpu (&cpu);
+    procdata->cpu_total_time = MAX(cpu.total - procdata->cpu_total_time_last, 1);
+    procdata->cpu_total_time_last = cpu.total;
+
+    // FIXME: not sure if glibtop always returns a sorted list of pid
+    // but it is important otherwise refresh_list won't find the parent
+    std::sort(pid_list, pid_list + proclist.number);
+
+    refresh_list (procdata, pid_list, proclist.number);
+
+    selection.restore(procdata->tree);
+
+    g_free (pid_list);
+
+    /* proclist.number == g_list_length(procdata->info) == g_hash_table_size(procdata->pids) */
+}
+
+
+void
+proctable_update (ProcData * const procdata)
+{
+    char* string;
+
+    string = make_loadavg_string();
+    gtk_label_set_text (GTK_LABEL(procdata->loadavg), string);
+    g_free (string);
+
+    proctable_update_list (procdata);
+}
+
+
+void
+proctable_free_table (ProcData * const procdata)
+{
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)
+        delete it->second;
+
+    ProcInfo::all.clear();
+}
+
+
+void
+proctable_clear_tree (ProcData * const procdata)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    gtk_tree_store_clear (GTK_TREE_STORE (model));
+
+    proctable_free_table (procdata);
+
+    update_sensitivity(procdata);
+}
+
+
+char*
+make_loadavg_string(void)
+{
+    glibtop_loadavg buf;
+
+    glibtop_get_loadavg(&buf);
+
+    return g_strdup_printf(
+        _("Load averages for the last 1, 5, 15 minutes: "
+          "%0.2f, %0.2f, %0.2f"),
+        buf.loadavg[0],
+        buf.loadavg[1],
+        buf.loadavg[2]);
+}
+
+
+
+void
+ProcInfo::set_icon(Glib::RefPtr<Gdk::Pixbuf> icon)
+{
+  this->surface = gdk_cairo_surface_create_from_pixbuf (icon->gobj(), 0, NULL);
+
+  GtkTreeModel *model;
+  model = gtk_tree_view_get_model(GTK_TREE_VIEW(ProcData::get_instance()->tree));
+  gtk_tree_store_set(GTK_TREE_STORE(model), &this->node,
+                     COL_SURFACE, this->surface,
+                    -1);
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/18.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/18.html new file mode 100644 index 00000000..4e691255 --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/18.html @@ -0,0 +1,405 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
#include <config.h>
+
+#include <glib.h>
+
+#include "selinux.h"
+#include "procman.h"
+#include "util.h"
+
+
+static int (*getpidcon)(pid_t, char**);
+static void (*freecon)(char*);
+static int (*is_selinux_enabled)(void);
+
+static gboolean has_selinux;
+
+static gboolean load_selinux(void)
+{
+    return load_symbols("libselinux.so.1",
+                        "getpidcon", &getpidcon,
+                        "freecon", &freecon,
+                        "is_selinux_enabled", &is_selinux_enabled,
+                        NULL);
+}
+
+
+
+void
+get_process_selinux_context (ProcInfo *info)
+{
+    char *con;
+
+    if (has_selinux && !getpidcon (info->pid, &con)) {
+        info->security_context = g_strdup (con);
+        freecon (con);
+    }
+}
+
+
+
+gboolean
+can_show_security_context_column (void)
+{
+    if (!(has_selinux = load_selinux()))
+        return FALSE;
+
+    switch (is_selinux_enabled()) {
+        case 1:
+            /* We're running on an SELinux kernel */
+            return TRUE;
+
+        case -1:
+            /* Error; hide the security context column */
+
+        case 0:
+            /* We're not running on an SELinux kernel:
+               hide the security context column */
+
+        default:
+            g_warning("SELinux was found but is not enabled.\n");
+            return FALSE;
+    }
+}
+
+
+
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/19.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/19.html new file mode 100644 index 00000000..913bbae3 --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/19.html @@ -0,0 +1,2359 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
#include <config.h>
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <glibmm.h>
+#include <glib/gi18n.h>
+
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+
+#include <glibtop/fsusage.h>
+#include <glibtop/mountlist.h>
+#include <glibtop/mem.h>
+#include <glibtop/sysinfo.h>
+
+#include <unistd.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#include <math.h>
+#include <errno.h>
+
+#include <exception>
+#include <string>
+#include <vector>
+#include <fstream>
+#include <sstream>
+#include <sys/utsname.h>
+
+#include "sysinfo.h"
+#include "procman.h"
+#include "util.h"
+
+
+using std::string;
+using std::vector;
+
+
+namespace {
+
+    class SysInfo
+    {
+    public:
+        string hostname;
+        string distro_name;
+        string distro_release;
+        string kernel;
+        string mate_version;
+        guint64 memory_bytes;
+        guint64 free_space_bytes;
+
+        string graphics;
+        string processors;
+
+        SysInfo()
+        {
+            this->load_processors_info();
+            this->load_graphics_info();
+            this->load_memory_info();
+            this->load_disk_info();
+            this->load_uname_info();
+            this->load_mate_version();
+        }
+
+        virtual ~SysInfo()
+        { }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Virtual function in base class
+        {
+            g_object_set(G_OBJECT(name),
+                        "label",
+                        ("<big><big><b>" + this->distro_name + "</b></big></big>").c_str(),
+                        NULL);
+
+            char* markup;
+#ifdef __linux__
+            if (this->distro_release != "")
+            {
+                /* Translators: The first string parameter is release version (codename),
+                 * the second one is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("Release %s %s"),
+                                         this->distro_release.c_str(),
+                                         SysInfo::get_os_type().c_str());
+            }
+            else
+            {
+                /* Translators: The string parameter is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("%s Version"),
+                                         SysInfo::get_os_type().c_str());
+            }
+#else
+            /* Translators: The string parameter is release version (codename) */
+            markup = g_strdup_printf(_("Release %s"),
+                                     this->distro_release.c_str());
+#endif
+
+            g_object_set(G_OBJECT(release),
+                         "label",
+                         markup,
+                         NULL);
+
+            g_free(markup);
+        }
+
+        static string release()
+        {
+            return uname().release;
+        }
+
+        static string system()
+        {
+            return uname().sysname;
+        }
+
+    private:
+
+        void load_memory_info()
+        {
+            glibtop_mem mem;
+
+            glibtop_get_mem(&mem);
+            this->memory_bytes = mem.total;
+        }
+
+        static string get_os_type ()<--- Unused private function: 'SysInfo::get_os_type'
+        {
+            int bits;
+
+            if (GLIB_SIZEOF_VOID_P == 8)
+                bits = 64;
+            else
+                bits = 32;
+
+            /* translators: This is the type of architecture, for example:
+             * "64-bit" or "32-bit" */
+            char* bytes = g_strdup_printf (_("%d-bit"), bits);
+            string retval(bytes);
+            g_free(bytes);
+            return retval;
+        }
+
+        typedef struct
+        {
+            const char* regex;
+            const char* replacement;
+        } ReplaceStrings;
+
+        static char* remove_duplicate_whitespace (const char* old)
+        {
+            char* result;
+            GRegex* re;
+            GError* error = NULL;
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+
+            re = g_regex_new ("[ \t\n\r]+", G_REGEX_MULTILINE, flags, &error);
+            if (re == NULL) {
+                g_warning ("Error building regex: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+            result = g_regex_replace (re, old, -1, 0, " ", flags, &error);
+            g_regex_unref (re);
+            if (result == NULL) {
+                g_warning ("Error replacing string: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+
+            return result;
+        }
+
+        static char* prettify_info (const char *info)
+        {
+            char* pretty;
+            const GRegexCompileFlags cflags = static_cast<GRegexCompileFlags>(0);
+            const GRegexMatchFlags mflags = static_cast<GRegexMatchFlags>(0);
+
+            static const ReplaceStrings rs[] = {
+                { "Intel[(]R[)]", "Intel\302\256"},
+                { "Core[(]TM[)]", "Core\342\204\242"},
+                { "Atom[(]TM[)]", "Atom\342\204\242"},
+            };
+
+            pretty = g_markup_escape_text (info, -1);
+
+            for (uint i = 0; i < G_N_ELEMENTS (rs); i++) {
+                GError* error;
+                GRegex* re;
+                char* result;
+
+                error = NULL;
+
+                re = g_regex_new (rs[i].regex, cflags, mflags, &error);
+                if (re == NULL) {
+                    g_warning ("Error building regex: %s", error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                result = g_regex_replace_literal (re, pretty, -1, 0,
+                                             rs[i].replacement, mflags, &error);
+
+                g_regex_unref (re);
+
+                if (error != NULL) {
+                    g_warning ("Error replacing %s: %s", rs[i].regex, error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                g_free (pretty);
+                pretty = result;
+            }
+
+            return pretty;
+        }
+
+        static char* get_renderer_from_helper (gboolean discrete_gpu)
+        {
+            int status;
+            const char *argv[] = { LIBEXECDIR "/mate-session-check-accelerated", NULL };
+            g_auto(GStrv) envp = NULL;
+            g_autofree char *renderer = NULL;
+            g_autoptr(GError) error = NULL;
+
+            if (discrete_gpu)
+            {
+                envp = g_get_environ ();
+                envp = g_environ_setenv (envp, "DRI_PRIME", "1", TRUE);
+            }
+
+            if (!g_spawn_sync (NULL, (char **) argv, envp, G_SPAWN_DEFAULT, NULL, NULL, &renderer, NULL, &status, &error))
+            {
+                g_debug ("Failed to get %s GPU: %s",
+                         discrete_gpu ? "discrete" : "integrated",
+                         error->message);
+                return NULL;
+            }
+
+            if (!g_spawn_check_exit_status (status, NULL))
+                return NULL;
+
+            if (renderer == NULL || *renderer == '\0')
+                return NULL;
+
+            return prettify_info (renderer);
+        }
+
+
+        void load_graphics_info()
+        {
+            g_autofree char *renderer = NULL;
+
+            try
+            {
+                g_autoptr(GDBusProxy) session_proxy = NULL;
+                g_autoptr(GVariant) renderer_variant = NULL;
+                g_autoptr(GError) error = NULL;
+
+                session_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                               G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL,
+                                                               "org.gnome.SessionManager",
+                                                               "/org/gnome/SessionManager",
+                                                               "org.gnome.SessionManager",
+                                                               NULL, &error);
+                if (error != NULL)
+                {
+                    throw std::runtime_error ("Unable to connect to create a proxy for org.gnome.SessionManager");
+                }
+
+                renderer_variant = g_dbus_proxy_get_cached_property (session_proxy, "Renderer");
+                if (!renderer_variant)
+                {
+                    throw std::runtime_error ("Unable to retrieve org.gnome.SessionManager.Renderer property.");
+                }
+
+                renderer = prettify_info (g_variant_get_string (renderer_variant, NULL));
+            }
+            catch (std::exception& e)
+            {
+                g_warning ("%s", e.what());
+            }
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (FALSE);
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (TRUE);
+
+            if (renderer)
+            {
+                this->graphics = g_strdup (renderer);
+            }
+            else
+            {
+                this->graphics = _("Unknown");
+            }
+        }
+
+        void load_processors_info()
+        {
+            const glibtop_sysinfo *info = glibtop_get_sysinfo();
+
+            GHashTable* counts;
+            GString* cpu;
+            GHashTableIter iter;
+            gpointer key, value;
+
+            counts = g_hash_table_new (g_str_hash, g_str_equal);
+
+            /* count duplicates */
+            for (uint i = 0; i != info->ncpu; ++i) {
+                const char* const keys[] = { "model name", "cpu", "Processor" };
+                char* model;
+                int* count;
+
+                model = NULL;
+
+                for (int j = 0; model == NULL && j != G_N_ELEMENTS (keys); ++j) {
+                    model = static_cast<char*>(g_hash_table_lookup (info->cpuinfo[i].values,
+                                                 keys[j]));
+                }
+
+                if (model == NULL)
+                    continue;
+
+                count = static_cast<int*>(g_hash_table_lookup (counts, model));
+                if (count == NULL)
+                    g_hash_table_insert (counts, model, GINT_TO_POINTER (1));
+                else
+                    g_hash_table_replace (counts, model, GINT_TO_POINTER (GPOINTER_TO_INT (count) + 1));
+            }
+
+            cpu = g_string_new (NULL);
+            g_hash_table_iter_init (&iter, counts);
+            while (g_hash_table_iter_next (&iter, &key, &value)) {
+                char* stripped;
+                int   count;
+
+                count = GPOINTER_TO_INT (value);
+                stripped = remove_duplicate_whitespace ((const char *)key);
+                if (count > 1)
+                    g_string_append_printf (cpu, "%s \303\227 %d ", stripped, count);
+                else
+                    g_string_append_printf (cpu, "%s ", stripped);
+                g_free (stripped);
+            }
+
+            g_hash_table_destroy (counts);
+            this->processors = string(prettify_info (cpu->str));
+            g_string_free (cpu, TRUE);
+        }
+
+        void load_disk_info()
+        {
+            GHashTable *devices;
+            glibtop_mountentry *entries;
+            glibtop_mountlist mountlist;
+
+            entries = glibtop_get_mountlist(&mountlist, 0);
+            devices = g_hash_table_new(g_str_hash, g_str_equal);
+            this->free_space_bytes = 0;
+
+            for (guint i = 0; i != mountlist.number; ++i) {
+                if ((string(entries[i].mountdir).compare("/") == 0) && \
+                    (string(entries[i].type).compare("zfs") == 0)) {
+                    // Root filesystem is ZFS based: Calculate usage based on "/".
+                    glibtop_fsusage usage;
+                    glibtop_get_fsusage(&usage, "/");
+                    this->free_space_bytes = usage.bavail * usage.block_size;
+                    break;
+                }
+
+                if (string(entries[i].devname).find("/dev/") != 0)
+                    continue;
+
+                if (string(entries[i].mountdir).find("/media/") == 0)
+                    continue;
+
+                /* avoid adding a device more than once such as for btrfs filesystem */
+                if (g_hash_table_contains (devices, entries[i].devname))
+                    continue;
+                else
+                    g_hash_table_insert (devices, entries[i].devname, entries[i].mountdir);
+
+                glibtop_fsusage usage;
+                glibtop_get_fsusage(&usage, entries[i].mountdir);
+                this->free_space_bytes += usage.bavail * usage.block_size;
+            }
+
+            g_hash_table_destroy (devices);
+            g_free(entries);
+        }
+
+        static const struct utsname & uname()
+        {
+            static struct utsname name;
+
+            if (!name.sysname[0]) {
+                ::uname(&name);
+            }
+
+            return name;
+        }
+
+        void load_uname_info()
+        {
+            this->hostname = uname().nodename;
+#if defined(__linux__)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().machine;
+#elif defined(__sun) && defined(__SVR4)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().version + ' ' + uname().machine;
+#else
+            this->kernel = string(uname().version) + ' ' + uname().machine;
+#endif
+        }
+
+
+        void load_mate_version()
+        {
+            xmlDocPtr document;
+            xmlXPathContextPtr context;
+            const string nodes[3] = { "string(/mate-version/platform)",
+                                      "string(/mate-version/minor)",
+                                      "string(/mate-version/micro)" };
+            string values[3];
+
+            if (not (document = xmlParseFile(DATADIR "/mate-about/mate-version.xml")))
+                return;
+
+            if (not (context = xmlXPathNewContext(document)))
+                return;
+
+            for (size_t i = 0; i != 3; ++i)
+            {
+                xmlXPathObjectPtr xpath;
+                xpath = xmlXPathEvalExpression(BAD_CAST nodes[i].c_str(), context);
+
+                if (xpath and xpath->type == XPATH_STRING)
+                    values[i] = reinterpret_cast<const char*>(xpath->stringval);
+
+                xmlXPathFreeObject(xpath);
+            }
+
+            xmlXPathFreeContext(context);
+            xmlFreeDoc(document);
+
+            if (!values[0].empty() && !values[1].empty() && !values[2].empty())
+                this->mate_version = values[0] + '.' + values[1] + '.' + values[2];
+        }
+    };
+
+    class FreeBSDSysInfo
+        : public SysInfo
+    {
+    public:
+	FreeBSDSysInfo()
+        {
+            this->load_freebsd_info();
+        }
+
+    private:
+        void load_freebsd_info()
+        {
+            this->distro_name = "FreeBSD";
+            this->distro_release = release();
+        }
+    };
+
+    class SolarisSysInfo
+        : public SysInfo
+    {
+    public:
+        SolarisSysInfo()
+        {
+            this->load_solaris_info();
+        }
+
+    private:
+        void load_solaris_info()
+        {
+            std::ifstream input("/etc/release");
+
+            if (input) {
+                std::string s;
+                std::getline(input, s);
+                std::size_t found = s.find("OpenIndiana ");
+                if (found!=std::string::npos) {
+                    this->distro_name = "OpenIndiana";
+                    this->distro_release = s.substr(found + strlen("OpenIndiana "));
+                } else if (!s.empty()) {
+                    this->distro_release = s;
+                }
+            }
+
+            if (this->distro_release.empty()) {
+                this->distro_name = "Solaris";
+            }
+        }
+    };
+
+
+    class LSBSysInfo
+        : public SysInfo
+    {
+    public:
+        LSBSysInfo()<--- Member variable 'LSBSysInfo::lsb_fd' is not initialized in the constructor.<--- Member variable 'LSBSysInfo::name' is not initialized in the constructor.<--- Member variable 'LSBSysInfo::release' is not initialized in the constructor.
+            : re(Glib::Regex::create("^.+?:\\s*(.+)\\s*$"))
+        {
+            // start();
+        }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Function in derived class
+        {
+            this->name = name;
+            this->release = release;
+
+            this->start();
+        }
+
+
+    private:
+
+        sigc::connection child_watch;
+        int lsb_fd;
+        GtkWidget* name;
+        GtkWidget* release;<--- Shadowed declaration<--- Shadowed declaration
+
+        void strip_description(string &s) const
+        {
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+            GMatchInfo* info = 0;
+
+           if (g_regex_match(this->re->gobj(), s.c_str(), flags, &info)) {
+               s = make_string(g_match_info_fetch(info, 1));
+               g_match_info_free(info);
+           }
+        }
+
+        std::istream& get_value(std::istream &is, string &s) const
+        {
+            if (std::getline(is, s))
+                this->strip_description(s);
+            return is;
+        }
+
+
+        void read_lsb(Glib::Pid pid, int status)
+        {
+            this->child_watch.disconnect();
+
+            if (!WIFEXITED(status) or WEXITSTATUS(status) != 0) {
+                g_error("Child %d failed with status %d", int(pid), status);
+                return;
+            }
+
+            Glib::RefPtr<Glib::IOChannel> channel = Glib::IOChannel::create_from_fd(this->lsb_fd);
+            Glib::ustring content;
+
+            while (channel->read_to_end(content) == Glib::IO_STATUS_AGAIN)
+                ;
+
+            channel->close();
+            Glib::spawn_close_pid(pid);
+
+            procman_debug("lsb_release output = '%s'", content.c_str());
+
+            string release, codename;<--- Shadow variable
+            std::istringstream input(content);
+
+            this->get_value(input, this->distro_name)
+                and this->get_value(input, release)
+                and this->get_value(input, codename);
+
+            this->distro_release = release;
+            if (codename != "" && codename != "n/a")
+                this->distro_release += " (" + codename + ')';
+
+            this->SysInfo::set_distro_labels(this->name, this->release);
+        }
+
+
+        void start()
+        {
+            std::vector<string> argv(2);
+            argv[0] = "lsb_release";
+            argv[1] = "-irc";
+
+            Glib::SpawnFlags flags = Glib::SPAWN_DO_NOT_REAP_CHILD
+                | Glib::SPAWN_SEARCH_PATH
+                | Glib::SPAWN_STDERR_TO_DEV_NULL;
+
+            Glib::Pid child;
+
+            try {
+                Glib::spawn_async_with_pipes("/", // wd
+                                             argv,
+                                             flags,
+                                             sigc::slot<void>(), // child setup
+                                             &child,
+                                             0, // stdin
+                                             &this->lsb_fd); // stdout
+            } catch (Glib::SpawnError &e) {
+                g_error("g_spawn_async_with_pipes error: %s", e.what().c_str());
+                return;
+            }
+
+            sigc::slot<void,GPid, int> slot = sigc::mem_fun(this, &LSBSysInfo::read_lsb);
+            this->child_watch = Glib::signal_child_watch().connect(slot, child);
+        }
+
+
+        void sync_lsb_release()<--- Unused private function: 'LSBSysInfo::sync_lsb_release'
+        {
+            char *out= 0;
+            GError *error = 0;
+            int status;
+
+            if (g_spawn_command_line_sync("lsb_release -irc",
+                                          &out,
+                                          0,
+                                          &status,
+                                          &error)) {
+                string release, codename;<--- Shadow variable
+                if (!error and WIFEXITED(status) and WEXITSTATUS(status) == 0) {
+                    std::istringstream input(out);
+                    this->get_value(input, this->distro_name)
+                        and this->get_value(input, release)
+                        and this->get_value(input, codename);
+                    this->distro_release = release;
+                if (codename != "" && codename != "n/a")
+                    this->distro_release += " (" + codename + ')';
+                }
+            }
+
+            if (error)
+                g_error_free(error);
+
+            g_free(out);
+        }
+
+    private:
+        Glib::RefPtr<Glib::Regex> re;
+    };
+
+
+    class NetBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        NetBSDSysInfo()
+        {
+            this->load_netbsd_info();
+        }
+
+    private:
+        void load_netbsd_info()
+        {
+            this->distro_name = "NetBSD";
+
+            std::ifstream input("/etc/release");
+
+            if (input)
+                std::getline(input, this->distro_release);
+        }
+    };
+
+
+    class GenericSysInfo
+        : public SysInfo
+    {
+    public:
+        GenericSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            std::ifstream input("/etc/os-release");
+
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int start;
+                    std::getline(input, s);
+                    if (s.find("NAME=") == 0) {
+                        start = strlen("NAME=");
+                        if ((s.at(start) == '\"') && (s.at(s.size() - 1) == '\"')) {
+                            this->distro_name = s.substr(start + 1, s.size() - start - 2);
+                        } else {
+                            this->distro_name = s.substr(start);
+                        }
+                    } else if (s.find("VERSION=") == 0) {
+                        start = strlen("VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    } else if (s.find("# VERSION=") == 0) {
+                        start = strlen("# VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    }
+                }
+                input.close();
+                input.clear();
+            }
+            if (this->distro_release.empty()) {
+                input.open("/etc/debian_version");
+                if (input) {
+                    getline(input, this->distro_release);
+                }
+            }
+        }
+    };
+
+    class MintSysInfo
+        : public SysInfo
+    {
+    public:
+        MintSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            this->distro_name = "Linux Mint";
+            std::ifstream input("/etc/linuxmint/info");
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int len;
+                    std::getline(input, s);
+                    if (s.find("DESCRIPTION=") == 0) {
+                        len = strlen("DESCRIPTION=");
+                        // also strip the surrounding quotes
+                       this->distro_release = s.substr(len + 1, s.size() - len - 2);
+                   }
+                }
+            }
+        }
+    };
+
+    class OpenBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        OpenBSDSysInfo()
+        {
+            this->load_openbsd_info();
+        }
+
+    private:
+        void load_openbsd_info()
+        {
+            this->distro_name = "OpenBSD";
+            this->distro_release = this->kernel;
+
+            std::ifstream input("/etc/motd");
+
+            if (input)
+                std::getline(input, this->kernel);
+        }
+    };
+
+    SysInfo* get_sysinfo()
+    {
+        if (g_file_test ("/etc/linuxmint/info", G_FILE_TEST_EXISTS)) {
+            return new MintSysInfo;
+        }
+        else if (g_file_test ("/etc/os-release", G_FILE_TEST_EXISTS)) {
+            return new GenericSysInfo;
+        }
+        else if (char *p = g_find_program_in_path("lsb_release")) {
+            g_free(p);
+            return new LSBSysInfo;
+        }
+        else if (SysInfo::system() == "FreeBSD") {
+            return new FreeBSDSysInfo;
+        }
+        else if (SysInfo::system() == "SunOS") {
+            return new SolarisSysInfo;
+        }
+        else if (SysInfo::system() == "NetBSD") {
+            return new NetBSDSysInfo;
+        }
+        else if (SysInfo::system() == "OpenBSD") {
+            return new OpenBSDSysInfo;
+        }
+
+        return new SysInfo;
+    }
+}
+
+
+#define X_PAD  0
+#define Y_PAD  0
+#define LOGO_W 92
+#define LOGO_H 351
+#define RADIUS 5
+
+static gboolean sysinfo_logo_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    GtkStyle *style;
+    cairo_t *cr;
+    cairo_pattern_t *cp;
+
+    cr = gdk_cairo_create(gtk_widget_get_window(widget));
+
+    gtk_widget_get_allocation (widget, &allocation);
+    cairo_translate(cr, allocation.x, allocation.y);
+
+    cairo_move_to(cr, X_PAD + RADIUS, Y_PAD);
+    cairo_line_to(cr, X_PAD + LOGO_W - RADIUS, Y_PAD);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + RADIUS, RADIUS, -0.5 * M_PI, 0);
+    cairo_line_to(cr, X_PAD + LOGO_W, Y_PAD + LOGO_H - RADIUS);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0, 0.5 * M_PI);
+    cairo_line_to(cr, X_PAD + RADIUS, Y_PAD + LOGO_H);
+    cairo_arc(cr, X_PAD + RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0.5 * M_PI, -1.0 * M_PI);
+    cairo_line_to(cr, X_PAD, Y_PAD + RADIUS);
+    cairo_arc(cr,  X_PAD + RADIUS, Y_PAD + RADIUS, RADIUS, -1.0 * M_PI, -0.5 * M_PI);
+
+    cp = cairo_pattern_create_linear(0, Y_PAD, 0, Y_PAD + LOGO_H);
+    style = gtk_widget_get_style (widget);
+    cairo_pattern_add_color_stop_rgba(cp, 0.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      1.0);
+    cairo_pattern_add_color_stop_rgba(cp, 1.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      0.0);
+    cairo_set_source(cr, cp);
+    cairo_fill(cr);
+
+    cairo_pattern_destroy(cp);
+    cairo_destroy(cr);
+
+    return FALSE;
+}
+
+static GtkWidget*
+add_section(GtkBox *vbox , const char * title, int num_row, int num_col, GtkWidget **out_frame)
+{
+    GtkWidget *table;
+
+    GtkWidget *frame = gtk_frame_new(title);
+    gtk_frame_set_label_align(GTK_FRAME(frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
+
+    table = gtk_grid_new();
+    gtk_grid_set_row_spacing(GTK_GRID(table), 6);
+    gtk_grid_set_column_spacing(GTK_GRID(table), 6);
+    gtk_widget_set_margin_start (GTK_WIDGET(table), 12);
+    gtk_container_set_border_width(GTK_CONTAINER(table), 6);
+    gtk_container_add(GTK_CONTAINER(frame), table);
+
+    if(out_frame)
+        *out_frame = frame;
+
+    return table;
+}
+
+
+static GtkWidget*
+add_row(GtkGrid * table, const char * label, const char * value, int row)
+{
+    GtkWidget *header = gtk_label_new(NULL);
+    gtk_label_set_markup(GTK_LABEL(header), label);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        table, header,
+        0, row, 1, 1);
+
+    GtkWidget *label_widget = gtk_label_new(value);
+    gtk_label_set_selectable(GTK_LABEL(label_widget), TRUE);
+    gtk_widget_set_can_focus(label_widget, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (label_widget), 0.0);
+    gtk_grid_attach(
+        table, label_widget,
+        1, row, 1, 1);
+
+    return label_widget;
+}
+
+
+static GtkWidget *
+procman_create_sysinfo_view(void)
+{
+    GtkWidget *hbox;
+    GtkWidget *vbox;
+
+    SysInfo *data = get_sysinfo();;
+
+    GtkWidget * logo;
+
+    GtkWidget *distro_frame;
+    GtkWidget *distro_release_label;
+    GtkWidget *distro_table;
+
+    GtkWidget *hardware_table;
+    GtkWidget *disk_space_table;
+
+    GtkWidget *header;
+
+    gchar *markup;
+
+    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);
+
+    /* left-side logo */
+    if (g_file_test (DATADIR "/pixmaps/mate-system-monitor/distribution/side.png", G_FILE_TEST_EXISTS)) {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/distribution/side.png");
+    }
+    else {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/side.png");
+    }
+    gtk_widget_set_valign (logo, GTK_ALIGN_START);
+    gtk_widget_set_margin_start (logo, 5);
+    gtk_widget_set_margin_end (logo, 5);
+    gtk_widget_set_margin_top (logo, 12);
+    gtk_widget_set_margin_bottom (logo, 12);
+    gtk_box_pack_start(GTK_BOX(hbox), logo, FALSE, FALSE, 0);
+
+    g_signal_connect(G_OBJECT(logo), "draw", G_CALLBACK(sysinfo_logo_draw), NULL);
+
+    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
+    gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
+
+    // hostname
+
+    markup = g_strdup_printf("<big><big><b><u>%s</u></b></big></big>",
+                             data->hostname.c_str());
+    GtkWidget *hostname_frame = gtk_frame_new(markup);
+    g_free(markup);
+    gtk_frame_set_label_align(GTK_FRAME(hostname_frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(hostname_frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(hostname_frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), hostname_frame, FALSE, FALSE, 0);
+
+
+    /* distro section */
+
+    unsigned table_size = 2;
+    if (data->mate_version != "")
+        table_size++;
+    distro_table = add_section(GTK_BOX(vbox), "???", table_size, 1, &distro_frame);
+
+    unsigned table_count = 0;
+
+    distro_release_label = gtk_label_new("???");
+    gtk_label_set_selectable(GTK_LABEL(distro_release_label), TRUE);
+    gtk_widget_set_can_focus(distro_release_label, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (distro_release_label), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), distro_release_label,
+        0, table_count, 1, 1);
+    table_count++;
+    data->set_distro_labels(gtk_frame_get_label_widget(GTK_FRAME(distro_frame)), distro_release_label);
+
+    markup = g_strdup_printf(_("Kernel %s"), data->kernel.c_str());
+    header = gtk_label_new(markup);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    g_free(markup);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), header,
+        0, table_count, 1, 1);
+    table_count++;
+
+    if (data->mate_version != "")
+    {
+        markup = g_strdup_printf(_("MATE %s"), data->mate_version.c_str());
+        header = gtk_label_new(markup);
+        gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+        gtk_widget_set_can_focus(header, FALSE);
+        g_free(markup);
+        gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+        gtk_grid_attach(
+            GTK_GRID(distro_table), header,
+            0, table_count, 1, 1);
+        table_count++;<--- Variable 'table_count' is assigned a value that is never used.
+    }
+
+    /* hardware section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("Hardware"));
+    hardware_table = add_section(GTK_BOX(vbox), markup, 1, 3, NULL);
+    g_free(markup);
+
+    markup = g_format_size_full(data->memory_bytes, G_FORMAT_SIZE_IEC_UNITS);
+    add_row(GTK_GRID(hardware_table), _("Memory:"), markup, 0);
+    g_free(markup);
+
+    add_row(GTK_GRID(hardware_table), _("Processor:"),
+            data->processors.c_str(), 1);
+    add_row(GTK_GRID(hardware_table), _("Graphics:"),
+            data->graphics.c_str(), 2);
+
+    /* disk space section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("System Status"));
+    disk_space_table = add_section(GTK_BOX(vbox), markup, 1, 2, NULL);
+    g_free(markup);
+
+    markup = g_format_size(data->free_space_bytes);
+    add_row(GTK_GRID(disk_space_table), _("Available disk space:"), markup, 0);
+    g_free(markup);
+
+    return hbox;
+}
+
+
+
+namespace procman
+{
+    void build_sysinfo_ui()
+    {
+        static GtkWidget* ui;
+
+        if (!ui) {
+            ProcData* procdata = ProcData::get_instance();
+            ui = procman_create_sysinfo_view();
+            GtkBox* box = GTK_BOX(gtk_notebook_get_nth_page(GTK_NOTEBOOK(procdata->notebook),
+                                                            PROCMAN_TAB_SYSINFO));
+            gtk_box_pack_start(box, ui, TRUE, TRUE, 0);
+            gtk_widget_show_all(ui);
+        }
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/2.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/2.html new file mode 100644 index 00000000..0154b48f --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/2.html @@ -0,0 +1,489 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
#ifndef _PROCMAN_LOAD_GRAPH_H_
+#define _PROCMAN_LOAD_GRAPH_H_
+
+#include <glib.h>
+#include <glibtop/cpu.h>
+
+enum
+{
+    LOAD_GRAPH_CPU,
+    LOAD_GRAPH_MEM,
+    LOAD_GRAPH_NET
+};
+
+enum {
+    CPU_TOTAL,
+    CPU_USED,
+    N_CPU_STATES
+};
+
+struct LoadGraphLabels
+{
+    GtkWidget *cpu[GLIBTOP_NCPU];
+    GtkWidget *memory;
+    GtkWidget *swap;
+    GtkWidget *net_in;
+    GtkWidget *net_in_total;
+    GtkWidget *net_out;
+    GtkWidget *net_out_total;
+};
+
+struct LoadGraph {
+
+    static const unsigned NUM_POINTS = 60 + 2;
+    static const unsigned GRAPH_MIN_HEIGHT = 40;
+
+    LoadGraph(guint type);
+    ~LoadGraph();
+
+    unsigned num_bars() const;
+    void clear_background();
+
+    double fontsize;
+    double rmargin;
+    double indent;
+
+    guint n;
+    gint type;
+    guint speed;
+    guint draw_width, draw_height;
+    guint render_counter;
+    guint frames_per_unit;
+    guint graph_dely;
+    guint real_draw_height;
+    double graph_delx;
+    guint graph_buffer_offset;
+
+    std::vector<GdkRGBA> colors;
+
+    std::vector<float> data_block;
+    gfloat* data[NUM_POINTS];
+
+    GtkWidget *main_widget;
+    GtkWidget *disp;
+
+    cairo_pattern_t *background;
+
+    guint timer_index;
+
+    gboolean draw;
+
+    LoadGraphLabels labels;
+    GtkWidget *mem_color_picker;
+    GtkWidget *swap_color_picker;
+
+    /* union { */
+        struct {
+            guint now; /* 0 -> current, 1 -> last
+                    now ^ 1 each time */
+            /* times[now], times[now ^ 1] is last */
+            guint64 times[2][GLIBTOP_NCPU][N_CPU_STATES];
+        } cpu;
+
+        struct {
+            guint64 last_in, last_out;
+#if GLIB_CHECK_VERSION(2,61,2)
+            gint64 time;
+#else
+            GTimeVal time;
+#endif
+            guint64 max;
+            unsigned values[NUM_POINTS];
+            size_t cur;
+        } net;
+    /* }; */
+};
+
+/* Force a drawing update */
+void
+load_graph_queue_draw (LoadGraph *g);
+
+/* Start load graph. */
+void
+load_graph_start (LoadGraph *g);
+
+/* Stop load graph. */
+void
+load_graph_stop (LoadGraph *g);
+
+/* Change load graph speed and restart it if it has been previously started */
+void
+load_graph_change_speed (LoadGraph *g,
+                         guint new_speed);
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+#endif /* _PROCMAN_LOAD_GRAPH_H_ */
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/3.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/3.html new file mode 100644 index 00000000..e0d59e5d --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/3.html @@ -0,0 +1,645 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
#include <config.h>
+
+#include <cstring>
+#include <glib/gi18n.h>
+
+#include "cgroups.h"
+#include "util.h"
+
+gboolean
+cgroups_enabled(void)
+{
+    static gboolean initialized = FALSE;
+    static gboolean has_cgroups;
+
+    if (!initialized) {
+        initialized = TRUE;
+        has_cgroups = g_file_test("/proc/cgroups", G_FILE_TEST_EXISTS);
+    }
+
+    return has_cgroups;
+}
+
+static void
+append_cgroup_name(char *line, gchar **current_cgroup_name)
+{
+    gchar *controller, *path, *tmp, *path_plus_space;
+    int paren_offset, off, tmp_size;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return;
+
+    *(path - 1) = '\0';
+    g_strdelimit(controller, ",", '/');
+
+    if ((std::strcmp(path, "/") == 0) || (std::strncmp(controller, "name=", 5) == 0))
+        return;
+
+    if (*current_cgroup_name == NULL) {
+        *current_cgroup_name = g_strdup_printf("%s (%s)", path, controller);
+        return;
+    }
+
+    /* add a space to the end of the path string */
+    path_plus_space = g_strdup_printf("%s ", path);
+
+    if ((tmp = g_strstr_len(*current_cgroup_name, -1, path_plus_space))) {
+        tmp_size = strlen(*current_cgroup_name) + strlen(controller) + 1;
+        paren_offset = g_strstr_len(tmp + strlen(path), -1, ")") - *current_cgroup_name;
+        *(*current_cgroup_name + paren_offset) = '\0';
+        tmp = (gchar *)g_strnfill(tmp_size, '\0');
+        off = g_strlcat(tmp, *current_cgroup_name, tmp_size);
+        *(tmp + off) = '/';
+        off++;
+        off += g_strlcat(tmp + off, controller, tmp_size);
+        *(tmp + off) = ')';
+        off++;
+        g_strlcat(tmp + off, *current_cgroup_name + paren_offset + 1, tmp_size);
+    } else
+        tmp = g_strdup_printf("%s, %s(%s)", *current_cgroup_name, path_plus_space, controller);
+
+    g_free(path_plus_space);
+    g_free(*current_cgroup_name);
+    *current_cgroup_name = tmp;
+}
+
+static int
+check_cgroup_changed(gchar *line, gchar *current_cgroup_set)
+{
+    /* check if line is contained in current_cgroup_set */
+    gchar *controller, *path, *tmp, *found, *close_paren, *open_paren;
+    int ret = 0;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return 1;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return 1;
+
+    *(path - 1) = '\0';
+
+    if (std::strncmp(controller, "name=", 5) == 0)
+        goto out;
+
+    /* if there are multiple controllers just report string has changed */
+    if (g_strstr_len(controller, -1, ",")) {
+        ret = 1;
+        goto out;
+    }
+
+    if (!current_cgroup_set) {
+        if (std::strcmp(path, "/") != 0)
+            ret = 1;
+        goto out;
+    }
+
+    /* special case for root cgroup */
+    tmp = current_cgroup_set;
+    if (std::strcmp(path, "/") == 0) {
+        while ((found = g_strstr_len(tmp, -1, controller))) {
+            close_paren = g_strstr_len(found, -1, ")");
+            open_paren = g_strstr_len(found, -1, "(");
+            if (close_paren) {
+                if (!open_paren || (close_paren < open_paren)) {
+                    ret = 1;
+                    goto out;
+                }
+            }
+            tmp = found + strlen(controller);
+        }
+        goto out;
+    }
+
+    tmp = current_cgroup_set;
+    while ((found = g_strstr_len(tmp, -1, path))) {
+            found = found + strlen(path);
+            close_paren = g_strstr_len(found, -1, ")");
+            if (*found == ' ') {
+                if (g_strstr_len(found + 1, close_paren - found, controller))
+                    goto out;
+            }
+            tmp = close_paren + 1;
+    }
+    ret = 1;
+out:
+    *(path - 1) = ':';
+    return ret;
+}
+
+void
+get_process_cgroup_info(ProcInfo *info)
+{
+    gchar *path;
+    gchar *cgroup_name = NULL;
+    int cgroups_changed = 0;
+    gchar *text;
+    char **lines;
+    int i;
+
+    if (!cgroups_enabled())
+        return;
+
+    /* read out of /proc/pid/cgroup */
+    path = g_strdup_printf("/proc/%d/cgroup", info->pid);
+    if (!path)
+        return;
+    if(!g_file_get_contents(path, &text, NULL, NULL))
+        goto out;
+    lines = g_strsplit(text, "\n", -1);
+    g_free(text);
+    if (!lines)
+        goto out;
+
+    for (i = 0; lines[i] != NULL; i++) {
+        if (lines[i][0] == '\0')
+            continue;
+        if (check_cgroup_changed(lines[i], info->cgroup_name)) {
+            cgroups_changed = 1;
+            break;
+        }
+    }
+
+    if (cgroups_changed) {
+        for (i = 0; lines[i] != NULL; i++) {
+            if (lines[i][0] == '\0')
+                continue;
+            append_cgroup_name(lines[i], &cgroup_name);
+        }
+        if (info->cgroup_name)
+            g_free(info->cgroup_name);
+        if (!cgroup_name)
+            info->cgroup_name = g_strdup("");
+        else
+            info->cgroup_name = cgroup_name;
+    }
+
+    g_strfreev(lines);
+out:
+    g_free(path);
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/4.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/4.html new file mode 100644 index 00000000..cc9dbf88 --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/4.html @@ -0,0 +1,1277 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
#include <config.h>
+
+#ifdef __linux__
+#include <mntent.h>
+#endif // __linux__
+
+#include <giomm.h>
+#include <giomm/themedicon.h>
+#include <gtk/gtk.h>
+#include <glibtop/mountlist.h>
+#include <glibtop/fsusage.h>
+#include <glib/gi18n.h>
+
+#include "procman.h"
+#include "disks.h"
+#include "util.h"
+#include "interface.h"
+#include "iconthemewrapper.h"
+
+namespace
+{
+  const unsigned DISK_ICON_SIZE = 24;
+}
+
+enum DiskColumns
+{
+    /* string columns* */
+    DISK_DEVICE,
+    DISK_DIR,
+    DISK_TYPE,
+    DISK_SUBVOLUME,
+    DISK_TOTAL,
+    DISK_FREE,
+    DISK_AVAIL,
+    /* USED has to be the last column */
+    DISK_USED,
+    // then unvisible columns
+    /* Surface column */
+    DISK_ICON,
+    /* numeric columns */
+    DISK_USED_PERCENTAGE,
+    DISK_N_COLUMNS
+};
+
+
+
+static void
+fsusage_stats(const glibtop_fsusage *buf,
+              guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
+              gint *percentage)
+{
+    guint64 total = buf->blocks * buf->block_size;
+
+    if (!total) {
+        /* not a real device */
+        *btotal = *bfree = *bavail = *bused = 0ULL;
+        *percentage = 0;
+    } else {
+        int percent;
+        *btotal = total;
+        *bfree = buf->bfree * buf->block_size;
+        *bavail = buf->bavail * buf->block_size;
+        *bused = *btotal - *bfree;
+        /* percent = 100.0f * *bused / *btotal; */
+        percent = 100 * *bused / (*bused + *bavail);
+        *percentage = CLAMP(percent, 0, 100);
+    }
+}
+
+
+namespace
+{
+    string get_icon_for_path(const std::string& path)
+    {
+        using namespace Glib;
+        using namespace Gio;
+
+        // FIXME: I don't know whether i should use Volume or Mount or UnixMount
+        // all i need an icon name.
+        RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+        std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
+
+        for (size_t i = 0; i != mounts.size(); ++i) {
+            if (mounts[i]->get_name() != path)
+                continue;
+
+            RefPtr<Icon> icon = mounts[i]->get_icon();
+            RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
+
+            if (themed_icon) {
+                char* name = 0;
+                // FIXME: not wrapped yet
+                g_object_get(G_OBJECT(themed_icon->gobj()), "name", &name, NULL);
+                return make_string(name);
+            }
+        }
+
+        return "";
+    }
+}
+
+
+static Glib::RefPtr<Gdk::Pixbuf>
+get_icon_for_device(const char *mountpoint)
+{
+    procman::IconThemeWrapper icon_theme;
+    string icon_name = get_icon_for_path(mountpoint);
+    if (icon_name == "")
+        // FIXME: defaults to a safe value
+        icon_name = "drive-harddisk"; // get_icon_for_path("/");
+    return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
+}
+
+
+static gboolean
+find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
+                   GtkTreeIter *result)
+{
+    GtkTreeIter iter;
+    gboolean found = FALSE;
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        do {
+            char *dir;
+
+            gtk_tree_model_get(model, &iter,
+                               DISK_DIR, &dir,
+                               -1);
+
+            if (dir && !strcmp(dir, mountpoint)) {
+                *result = iter;
+                found = TRUE;
+            }
+
+            g_free(dir);
+
+        } while (!found && gtk_tree_model_iter_next(model, &iter));
+    }
+
+    return found;
+}
+
+
+
+static void
+remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
+{
+    GtkTreeIter iter;
+
+    if (!gtk_tree_model_get_iter_first(model, &iter))
+        return;
+
+    while (true) {
+        char *dir;
+        guint i;
+        gboolean found = FALSE;
+
+        gtk_tree_model_get(model, &iter,
+                           DISK_DIR, &dir,
+                           -1);
+
+        for (i = 0; i != n; ++i) {
+            if (!strcmp(dir, entries[i].mountdir)) {
+                found = TRUE;
+                break;
+            }
+        }
+
+        g_free(dir);
+
+        if (!found) {
+            if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                break;
+            else
+                continue;
+        }
+
+        if (!gtk_tree_model_iter_next(model, &iter))
+            break;
+    }
+}
+
+#ifdef __linux__
+static char *
+get_mount_opt(const glibtop_mountentry *entry, const char* opt)
+{
+    char *opt_value = NULL;
+    const struct mntent *mnt;
+    FILE *fp;
+
+    if (!(fp = setmntent(MOUNTED, "r"))) {
+        goto out;
+    }
+
+    while ((mnt = getmntent(fp))) {
+        if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
+            (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
+            char *res;
+
+            res = hasmntopt(mnt, "subvol");<--- res is assigned
+            if ((res = hasmntopt(mnt, "subvol")) != NULL) {<--- res is overwritten
+                char **strs = g_strsplit_set(res, "=", 2);
+
+                if (g_strv_length(strs) == 2) {
+                    char *value = strs[1];
+                    if (g_strcmp0 (value,"/root") == 0)
+                       opt_value = g_strdup("/");
+                    else
+                        opt_value = g_strdup(strs[1]);
+                    g_strfreev(strs);
+                }
+            }
+            break;
+        }
+    }
+
+    endmntent(fp);
+
+  out:
+     return opt_value;
+}
+#endif // __linux__
+
+
+static void
+add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
+{
+    Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+    cairo_surface_t *surface;
+    GtkTreeIter iter;
+    glibtop_fsusage usage;
+    guint64 bused, bfree, bavail, btotal;
+    gint percentage;
+#ifdef __linux__
+    char *subvol = NULL;
+#endif // __linux__
+
+    glibtop_get_fsusage(&usage, entry->mountdir);
+
+    if (not show_all_fs and usage.blocks == 0) {
+        if (find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+            gtk_list_store_remove(list, &iter);
+        return;
+    }
+
+    fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
+#ifdef __linux__
+    subvol = get_mount_opt(entry, "subvol");
+#endif // __linux__
+    pixbuf = get_icon_for_device(entry->mountdir);
+    surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL);
+
+    /* if we can find a row with the same mountpoint, we get it but we
+       still need to update all the fields.
+       This makes selection persistent.
+    */
+    if (!find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+        gtk_list_store_append(list, &iter);
+
+    gtk_list_store_set(list, &iter,
+                       DISK_ICON, surface,
+                       DISK_DEVICE, entry->devname,
+                       DISK_DIR, entry->mountdir,
+                       DISK_TYPE, entry->type,
+#ifdef __linux__
+
+                       DISK_SUBVOLUME, subvol != NULL ? subvol : "",
+#else
+                       DISK_SUBVOLUME, "",
+#endif // __linux__
+                       DISK_USED_PERCENTAGE, percentage,
+                       DISK_TOTAL, btotal,
+                       DISK_FREE, bfree,
+                       DISK_AVAIL, bavail,
+                       DISK_USED, bused,
+                       -1);
+#ifdef __linux__
+    g_free (subvol);
+#endif // __linux__
+}
+
+
+
+int
+cb_update_disks(gpointer data)
+{
+    ProcData *const procdata = static_cast<ProcData*>(data);
+
+    GtkListStore *list;
+    glibtop_mountentry * entries;
+    glibtop_mountlist mountlist;
+    guint i;
+
+    list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)));
+
+    entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
+
+    remove_old_disks(GTK_TREE_MODEL(list), entries, mountlist.number);
+
+    for (i = 0; i < mountlist.number; i++)
+        add_disk(list, &entries[i], procdata->config.show_all_fs);
+
+    g_free(entries);
+
+    return TRUE;
+}
+
+
+static void
+cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "disktreenew");
+}
+
+
+static void
+open_dir(GtkTreeView       *tree_view,
+         GtkTreePath       *path,
+         GtkTreeViewColumn *column,
+         gpointer           user_data)
+{
+    GtkTreeIter iter;
+    GtkTreeModel *model;
+    char *dir, *url;
+
+    model = gtk_tree_view_get_model(tree_view);
+
+    if (!gtk_tree_model_get_iter(model, &iter, path)) {
+        char *p;
+        p = gtk_tree_path_to_string(path);
+        g_warning("Cannot get iter for path '%s'\n", p);
+        g_free(p);
+        return;
+    }
+
+    gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
+
+    url = g_strdup_printf("file://%s", dir);
+
+    GError* error = 0;
+    if (!g_app_info_launch_default_for_uri(url, NULL, &error)) {
+        g_warning("Cannot open '%s' : %s\n", url, error->message);
+        g_error_free(error);
+    }
+
+    g_free(url);
+    g_free(dir);
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "disktreenew");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+void
+create_disk_view(ProcData *procdata, GtkBuilder *builder)
+{
+    GtkWidget *scrolled;
+    GtkWidget *disk_tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *col;
+    GtkCellRenderer *cell;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Device"),
+        N_("Directory"),
+        N_("Type"),
+        N_("SubVolume"),
+        N_("Total"),
+        N_("Free"),
+        N_("Available"),
+        N_("Used")
+    };
+
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"));
+
+    model = gtk_list_store_new(DISK_N_COLUMNS,             /* n columns */
+                               G_TYPE_STRING,              /* DISK_DEVICE */
+                               G_TYPE_STRING,              /* DISK_DIR */
+                               G_TYPE_STRING,              /* DISK_TYPE */
+                               G_TYPE_STRING,              /* DISK_SUBVOLUME */
+                               G_TYPE_UINT64,              /* DISK_TOTAL */
+                               G_TYPE_UINT64,              /* DISK_FREE */
+                               G_TYPE_UINT64,              /* DISK_AVAIL */
+                               G_TYPE_UINT64,              /* DISK_USED */
+                               CAIRO_GOBJECT_TYPE_SURFACE, /* DISK_ICON */
+                               G_TYPE_INT);                /* DISK_USED_PERCENTAGE */
+
+    disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL);
+    procdata->disk_list = disk_tree;
+    gtk_container_add(GTK_CONTAINER(scrolled), disk_tree);
+    g_object_unref(G_OBJECT(model));
+
+    /* icon + device */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
+                                        NULL);
+
+    cell = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
+                                        NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 30);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* sizes - used */
+
+    for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_min_width (col, 30);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+        switch (i) {
+            case DISK_TOTAL:
+            case DISK_FREE:
+            case DISK_AVAIL:
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+        default:
+            gtk_tree_view_column_set_attributes(col, cell,
+                                                "text", i,
+                                                NULL);
+            break;
+        }
+    }
+
+    /* used + percentage */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_text_new();
+    g_object_set(cell, "xalign", 1.0f, NULL);
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_cell_data_func(col, cell,
+                                            &procman::storage_size_cell_data_func,
+                                            GUINT_TO_POINTER(DISK_USED),
+                                            NULL);
+
+    cell = gtk_cell_renderer_progress_new();
+    gtk_tree_view_column_pack_start(col, cell, TRUE);
+    gtk_tree_view_column_set_attributes(col, cell, "value",
+                                        DISK_USED_PERCENTAGE, NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_USED]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 150);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* numeric sort */
+
+    procman_get_tree_state(procdata->settings, disk_tree,
+                   "disktreenew");
+
+    g_signal_connect (G_OBJECT(disk_tree), "columns-changed",
+                      G_CALLBACK(cb_disk_columns_changed), procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/5.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/5.html new file mode 100644 index 00000000..17de817b --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/5.html @@ -0,0 +1,2141 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
+852
+853
+854
+855
+856
+857
+858
+859
+860
+861
+862
+863
+864
+865
+866
+867
+868
+869
+870
+871
+872
+873
+874
+875
+876
+877
+878
+879
+880
+881
+882
+883
+884
+885
+886
+887
+888
+889
+890
+891
+892
+893
+894
+895
+896
+897
+898
+899
+900
+901
+902
+903
+904
+905
+906
+907
+908
+909
+910
+911
+912
+913
+914
+915
+916
+917
+918
+919
+920
+921
+922
+923
+924
+925
+926
+927
+928
+929
+930
+931
+932
+933
+934
+935
+936
+937
+938
+939
+940
+941
+942
+943
+944
+945
+946
/*
+ * Mate system monitor color pickers
+ * Copyright (C) 2007 Karl Lattimer <karl@qdh.org.uk>
+ * Copyright (C) 2012-2021 MATE Developers
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with the software; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <gdk/gdkkeysyms.h>
+#include <math.h>
+#include <cairo.h>
+#include <librsvg/rsvg.h>
+
+#include "gsm_color_button.h"
+
+typedef struct {
+    GtkWidget *cc_dialog;		/* Color chooser dialog */
+
+    gchar *title;            /* Title for the color selection window */
+
+    GdkRGBA color;
+
+    gdouble fraction;        /* Only used by GSMCP_TYPE_PIE */
+    guint type;
+    cairo_surface_t *image_buffer;
+    gdouble highlight;
+    gboolean button_down;
+    gboolean in_button;
+} GSMColorButtonPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GSMColorButton, gsm_color_button, GTK_TYPE_DRAWING_AREA)
+
+/* Properties */
+enum
+{
+    PROP_0,
+    PROP_PERCENTAGE,
+    PROP_TITLE,
+    PROP_COLOR,
+    PROP_TYPE
+};
+
+/* Signals */
+enum
+{
+    COLOR_SET,
+    LAST_SIGNAL
+};
+
+#define GSMCP_MIN_WIDTH 15
+#define GSMCP_MIN_HEIGHT 15
+
+static void gsm_color_button_finalize (GObject * object);
+static void gsm_color_button_set_property (GObject * object, guint param_id,
+                                           const GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_get_property (GObject * object, guint param_id,
+                                           GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_realize (GtkWidget * widget);
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width);
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height);
+static void gsm_color_button_size_allocate (GtkWidget * widget,
+                                            GtkAllocation * allocation);
+static void gsm_color_button_unrealize (GtkWidget * widget);
+static void gsm_color_button_state_changed (GtkWidget * widget,
+                                            GtkStateType previous_state);
+static void gsm_color_button_style_set (GtkWidget * widget,
+                                        GtkStyle * previous_style);
+static gint gsm_color_button_pressed (GtkWidget * widget,
+                                      GdkEventButton * event);
+static gint gsm_color_button_released (GtkWidget * widget,
+                                       GdkEventButton * event);
+static gboolean gsm_color_button_enter_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+static gboolean gsm_color_button_leave_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+/* source side drag signals */
+static void gsm_color_button_drag_begin (GtkWidget * widget,
+                                         GdkDragContext * context,
+                                         gpointer data);
+static void gsm_color_button_drag_data_get (GtkWidget * widget,
+                                            GdkDragContext * context,
+                                            GtkSelectionData * selection_data,
+                                            guint info, guint time,
+                                            GSMColorButton * color_button);
+
+/* target side drag signals */
+static void gsm_color_button_drag_data_received (GtkWidget * widget,
+                                                 GdkDragContext * context,
+                                                 gint x,
+                                                 gint y,
+                                                 GtkSelectionData *
+                                                 selection_data, guint info,
+                                                 guint32 time,
+                                                 GSMColorButton *
+                                                 color_button);
+
+static guint color_button_signals[LAST_SIGNAL] = { 0 };
+
+static const GtkTargetEntry drop_types[] = { {"application/x-color", 0, 0} };
+
+static void
+gsm_color_button_class_init (GSMColorButtonClass * klass)
+{
+    GObjectClass *gobject_class;
+    GtkWidgetClass *widget_class;
+
+    gobject_class = G_OBJECT_CLASS (klass);
+    widget_class = GTK_WIDGET_CLASS (klass);
+
+    gobject_class->get_property = gsm_color_button_get_property;
+    gobject_class->set_property = gsm_color_button_set_property;
+    gobject_class->finalize = gsm_color_button_finalize;
+    widget_class->state_changed = gsm_color_button_state_changed;
+    widget_class->get_preferred_width = gsm_color_button_get_preferred_width;
+    widget_class->get_preferred_height = gsm_color_button_get_preferred_height;
+    widget_class->size_allocate = gsm_color_button_size_allocate;
+    widget_class->realize = gsm_color_button_realize;
+    widget_class->unrealize = gsm_color_button_unrealize;
+    widget_class->style_set = gsm_color_button_style_set;
+    widget_class->button_release_event = gsm_color_button_released;
+    widget_class->button_press_event = gsm_color_button_pressed;
+    widget_class->enter_notify_event = gsm_color_button_enter_notify;
+    widget_class->leave_notify_event = gsm_color_button_leave_notify;
+
+    klass->color_set = NULL;
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_PERCENTAGE,
+                                     g_param_spec_double ("fraction",
+                                                          _("Fraction"),
+                                     // TRANSLATORS: description of the pie color picker's (mem, swap) filled percentage property
+                                                          _("Percentage full for pie color pickers"),
+                                                          0, 1, 0.5,
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TITLE,
+                                     g_param_spec_string ("title",
+                                                          _("Title"),
+                                                          _("The title of the color selection dialog"),
+                                                          _("Pick a Color"),
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_COLOR,
+                                     g_param_spec_boxed ("color",
+                                                         _("Current Color"),
+                                                         _("The selected color"),
+                                                         GDK_TYPE_RGBA,
+                                                         G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TYPE,
+                                     g_param_spec_uint ("type", _("Type"),
+                                                        _("Type of color picker"),
+                                                        0, 4, 0,
+                                                        G_PARAM_READWRITE));
+
+    color_button_signals[COLOR_SET] = g_signal_new ("color_set",
+                                                    G_TYPE_FROM_CLASS
+                                                    (gobject_class),
+                                                    G_SIGNAL_RUN_FIRST,
+                                                    G_STRUCT_OFFSET
+                                                    (GSMColorButtonClass,
+                                                    color_set), NULL, NULL,
+                                                    g_cclosure_marshal_VOID__VOID,
+                                                    G_TYPE_NONE, 0);
+
+}
+
+static cairo_surface_t *
+fill_image_buffer_from_file (cairo_t *cr, const char *filePath)
+{
+    GError *error = NULL;
+    RsvgHandle *handle;
+    cairo_surface_t *tmp_surface;
+    cairo_t *tmp_cr;
+
+    handle = rsvg_handle_new_from_file (filePath, &error);
+
+    if (handle == NULL) {
+        g_warning("rsvg_handle_new_from_file(\"%s\") failed: %s",
+              filePath, (error ? error->message : "unknown error"));
+    if (error)
+          g_error_free(error);
+    return NULL;
+    }
+
+    tmp_surface = cairo_surface_create_similar (cairo_get_target (cr),
+                                                CAIRO_CONTENT_COLOR_ALPHA,
+                                                32, 32);
+    tmp_cr = cairo_create (tmp_surface);
+    rsvg_handle_render_cairo (handle, tmp_cr);
+    cairo_destroy (tmp_cr);
+    g_object_unref (handle);
+    return tmp_surface;
+}
+
+static void
+render (GtkWidget * widget)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GdkRGBA *color;
+    GdkRGBA tmp_color = priv->color;
+    color = &tmp_color;
+    cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
+    cairo_path_t *path = NULL;
+    gint width, height;
+    gdouble radius, arc_start, arc_end;
+    gdouble highlight_factor;
+
+    if (priv->highlight > 0) {
+        highlight_factor = 0.125 * priv->highlight;
+
+    if (color->red + highlight_factor > 1.0)
+        color->red = 1.0;
+    else
+        color->red = color->red + highlight_factor;
+
+    if (color->blue + highlight_factor > 1.0)
+        color->blue = 1.0;
+    else
+      color->blue = color->blue + highlight_factor;
+
+    if (color->green + highlight_factor > 1.0)
+        color->green = 1.0;
+    else
+        color->green = color->green + highlight_factor;
+    }
+    gdk_cairo_set_source_rgba (cr, color);
+
+    width = gdk_window_get_width(gtk_widget_get_window(widget));
+    height = gdk_window_get_height(gtk_widget_get_window(widget));
+
+    switch (priv->type)
+        {
+        case GSMCP_TYPE_CPU:
+            //gtk_widget_set_size_request (widget, GSMCP_MIN_WIDTH, GSMCP_MIN_HEIGHT);
+            cairo_paint (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1);
+            cairo_stroke (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.4);
+            cairo_rectangle (cr, 1.5, 1.5, width - 3, height - 3);
+            cairo_stroke (cr);
+            break;
+        case GSMCP_TYPE_PIE:
+            if (width < 32)        // 32px minimum size
+                gtk_widget_set_size_request (widget, 32, 32);
+            if (width < height)
+                radius = width / 2;
+            else
+                radius = height / 2;
+
+            arc_start = -G_PI_2 + 2 * G_PI * priv->fraction;
+            arc_end = -G_PI_2;
+
+            cairo_set_line_width (cr, 1);
+
+            // Draw external stroke and fill
+            if (priv->fraction < 0.01) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_end);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    arc_end, arc_start);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_start);
+            }
+            cairo_fill_preserve (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.7);
+            cairo_stroke (cr);
+
+            // Draw internal highlight
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.45);
+            cairo_set_line_width (cr, 1);
+
+            if (priv->fraction < 0.03) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_end - (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    arc_end - (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+            }
+            cairo_stroke (cr);
+
+            // Draw external shape
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.2);
+            cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 1.25, 0,
+                G_PI * 2);
+            cairo_stroke (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_IN:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                    fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/download.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 8.5, 1.5);
+            cairo_line_to (cr, 23.5, 1.5);
+            cairo_line_to (cr, 23.5, 11.5);
+            cairo_line_to (cr, 29.5, 11.5);
+            cairo_line_to (cr, 16.5, 27.5);
+            cairo_line_to (cr, 15.5, 27.5);
+            cairo_line_to (cr, 2.5, 11.5);
+            cairo_line_to (cr, 8.5, 11.5);
+            cairo_line_to (cr, 8.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_OUT:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/upload.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 16.5, 1.5);
+            cairo_line_to (cr, 29.5, 17.5);
+            cairo_line_to (cr, 23.5, 17.5);
+            cairo_line_to (cr, 23.5, 27.5);
+            cairo_line_to (cr, 8.5, 27.5);
+            cairo_line_to (cr, 8.5, 17.5);
+            cairo_line_to (cr, 2.5, 17.5);
+            cairo_line_to (cr, 15.5, 1.5);
+            cairo_line_to (cr, 16.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        }
+    cairo_destroy (cr);
+}
+
+/* Handle exposure events for the color picker's drawing area */
+static gboolean draw (GtkWidget * widget, cairo_t * cr, gpointer data)
+{
+    render (GTK_WIDGET (data));
+
+    return FALSE;
+}
+
+static void
+gsm_color_button_realize (GtkWidget * widget)
+{
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->realize (widget);
+    render (widget);
+}
+
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width)
+{
+    g_return_if_fail (widget != NULL && minimum_width != NULL && natural_width != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_width = GSMCP_MIN_WIDTH;
+    *natural_width = GSMCP_MIN_WIDTH;
+}
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height)
+{
+    g_return_if_fail (widget != NULL && minimum_height != NULL && natural_height != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_height = GSMCP_MIN_HEIGHT;
+    *natural_height = GSMCP_MIN_HEIGHT;
+}
+
+static void
+gsm_color_button_size_allocate (GtkWidget * widget,
+                                GtkAllocation * allocation)
+{
+    g_return_if_fail (widget != NULL || allocation != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    gtk_widget_set_allocation (widget, allocation);
+
+    if (gtk_widget_get_realized (widget))
+    {
+        gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y,
+                                allocation->width, allocation->height);
+    }
+}
+
+static void
+gsm_color_button_unrealize (GtkWidget * widget)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->unrealize (widget);
+}
+
+static void
+gsm_color_button_style_set (GtkWidget * widget, GtkStyle * previous_style)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->style_set (widget,
+                                                                 previous_style);
+
+}
+
+static void
+gsm_color_button_state_changed (GtkWidget * widget,
+                                GtkStateType previous_state)
+{
+}
+
+static void
+gsm_color_button_drag_data_received (GtkWidget * widget,
+                                     GdkDragContext * context,
+                                     gint x,
+                                     gint y,
+                                     GtkSelectionData * selection_data,
+                                     guint info,
+                                     guint32 time,
+                                     GSMColorButton * color_button)
+{
+    gint length;
+    guint16 *dropped;
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    length = gtk_selection_data_get_length (selection_data);
+
+    if (length < 0)
+        return;
+
+    /* We accept drops with the wrong format, since the KDE color
+     * chooser incorrectly drops application/x-color with format 8.
+     */
+    if (length != 8)
+    {
+        g_warning (_("Received invalid color data\n"));
+        return;
+    }
+
+    dropped = (guint16 *) gtk_selection_data_get_data (selection_data);
+
+    priv->color.red =   ((double) dropped[0]) / 65535.0;
+    priv->color.green = ((double) dropped[1]) / 65535.0;
+    priv->color.blue =  ((double) dropped[2]) / 65535.0;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+    g_object_freeze_notify (G_OBJECT (color_button));
+    g_object_notify (G_OBJECT (color_button), "color");
+    g_object_thaw_notify (G_OBJECT (color_button));
+}
+
+static void
+set_color_icon (GdkDragContext * context, GdkRGBA * color)
+{
+    GdkPixbuf *pixbuf;
+    guint32 pixel;
+
+    pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 48, 32);
+
+    pixel = ((guint32)(color->red * 0xff) << 24) |
+            ((guint32)(color->green * 0xff) << 16) |
+            ((guint32)(color->blue * 0xff) << 8);
+
+    gdk_pixbuf_fill (pixbuf, pixel);
+
+    gtk_drag_set_icon_pixbuf (context, pixbuf, -2, -2);
+    g_object_unref (pixbuf);
+}
+
+static void
+gsm_color_button_drag_begin (GtkWidget * widget,
+                             GdkDragContext * context, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = data;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    set_color_icon (context, &priv->color);
+}
+
+static void
+gsm_color_button_drag_data_get (GtkWidget * widget,
+                                GdkDragContext * context,
+                                GtkSelectionData * selection_data,
+                                guint info,
+                                guint time, GSMColorButton * color_button)
+{
+    guint16 dropped[4];
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    dropped[0] = (guint16) (65535.0 * priv->color.red);
+    dropped[1] = (guint16) (65535.0 * priv->color.green);
+    dropped[2] = (guint16) (65535.0 * priv->color.blue);
+    dropped[3] = 65535;        // This widget doesn't care about alpha
+
+    gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data),
+                            16, (guchar *) dropped, 8);
+}
+
+static void
+gsm_color_button_init (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = 0;
+    priv->color.green = 0;
+    priv->color.blue = 0;
+    priv->fraction = 0.5;
+    priv->type = GSMCP_TYPE_CPU;
+    priv->image_buffer = NULL;
+    priv->title = g_strdup (_("Pick a Color"));     /* default title */
+    priv->in_button = FALSE;
+    priv->button_down = FALSE;
+
+    gtk_drag_dest_set (GTK_WIDGET (color_button),
+                       GTK_DEST_DEFAULT_MOTION |
+                       GTK_DEST_DEFAULT_HIGHLIGHT |
+                       GTK_DEST_DEFAULT_DROP, drop_types, 1, GDK_ACTION_COPY);
+    gtk_drag_source_set (GTK_WIDGET (color_button),
+                         GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
+                         drop_types, 1, GDK_ACTION_COPY);
+    g_signal_connect (color_button, "drag_begin",
+                      G_CALLBACK (gsm_color_button_drag_begin), color_button);
+    g_signal_connect (color_button, "drag_data_received",
+                      G_CALLBACK (gsm_color_button_drag_data_received),
+                      color_button);
+    g_signal_connect (color_button, "drag_data_get",
+                      G_CALLBACK (gsm_color_button_drag_data_get),
+                      color_button);
+
+    gtk_widget_add_events (GTK_WIDGET(color_button), GDK_ENTER_NOTIFY_MASK
+                              | GDK_LEAVE_NOTIFY_MASK);
+
+    gtk_widget_set_tooltip_text (GTK_WIDGET(color_button), _("Click to set graph colors"));
+
+    g_signal_connect (color_button, "draw", G_CALLBACK (draw), color_button);
+}
+
+static void
+gsm_color_button_finalize (GObject * object)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    if (priv->cc_dialog != NULL)
+        gtk_widget_destroy (priv->cc_dialog);
+    priv->cc_dialog = NULL;
+
+    g_free (priv->title);
+    priv->title = NULL;
+
+    cairo_surface_destroy (priv->image_buffer);
+    priv->image_buffer = NULL;
+
+    G_OBJECT_CLASS (gsm_color_button_parent_class)->finalize (object);
+}
+
+GtkWidget *
+gsm_color_button_new (const GdkRGBA * color, guint type)
+{
+    return g_object_new (GSM_TYPE_COLOR_BUTTON, "color", color, "type", type,
+                         NULL);
+}
+
+static void
+dialog_response (GtkWidget * widget, GtkResponseType response, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GtkColorChooser *color_chooser;
+
+    if (response == GTK_RESPONSE_OK) {
+        color_chooser = GTK_COLOR_CHOOSER (priv->cc_dialog);
+
+        gtk_color_chooser_get_rgba (color_chooser, &priv->color);
+
+        gtk_widget_hide (priv->cc_dialog);
+
+        gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+        g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+        g_object_freeze_notify (G_OBJECT (color_button));
+        g_object_notify (G_OBJECT (color_button), "color");
+        g_object_thaw_notify (G_OBJECT (color_button));
+    }
+    else  /* (response == GTK_RESPONSE_CANCEL) */
+        gtk_widget_hide (priv->cc_dialog);
+}
+
+static gboolean
+dialog_destroy (GtkWidget * widget, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->cc_dialog = NULL;
+
+    return FALSE;
+}
+
+static gint
+gsm_color_button_clicked (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    /* if dialog already exists, make sure it's shown and raised */
+    if (!priv->cc_dialog)
+    {
+        /* Create the dialog and connects its buttons */
+        GtkWidget *cc_dialog;
+        GtkWidget *parent;
+
+        parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));
+        if (!gtk_widget_is_toplevel (parent))
+            parent = NULL;
+
+        cc_dialog = gtk_color_chooser_dialog_new (priv->title, GTK_WINDOW (parent));
+
+        gtk_window_set_modal (GTK_WINDOW (cc_dialog), TRUE);
+
+        g_signal_connect (cc_dialog, "response",
+                          G_CALLBACK (dialog_response), color_button);
+
+        g_signal_connect (cc_dialog, "destroy",
+                          G_CALLBACK (dialog_destroy), color_button);
+
+        priv->cc_dialog = cc_dialog;
+    }
+
+    gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (priv->cc_dialog),
+                                &priv->color);
+
+    gtk_window_present (GTK_WINDOW (priv->cc_dialog));
+
+    return 0;
+}
+
+static gint
+gsm_color_button_pressed (GtkWidget * widget, GdkEventButton * event)
+{
+    if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) )
+    {
+	GSMColorButtonPrivate *priv;
+        GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+	priv = gsm_color_button_get_instance_private (color_button);
+	priv->button_down = TRUE;
+    }
+  return 0;
+}
+
+static gint
+gsm_color_button_released (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    if (priv->button_down && priv->in_button)
+        gsm_color_button_clicked (widget, event);
+    priv->button_down = FALSE;
+    return 0;
+}
+
+static gboolean
+gsm_color_button_enter_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 1.0;
+    priv->in_button = TRUE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+static gboolean
+gsm_color_button_leave_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 0;
+    priv->in_button = FALSE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+guint
+gsm_color_button_get_cbtype (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->type;
+}
+
+void
+gsm_color_button_set_cbtype (GSMColorButton * color_button, guint type)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->type = type;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "type");
+}
+
+gdouble
+gsm_color_button_get_fraction (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->fraction;
+}
+
+void
+gsm_color_button_set_fraction (GSMColorButton * color_button,
+                               gdouble fraction)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->fraction = fraction;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "fraction");
+}
+
+void
+gsm_color_button_get_color (GSMColorButton * color_button, GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    color->red = priv->color.red;
+    color->green = priv->color.green;
+    color->blue = priv->color.blue;
+    color->alpha = priv->color.alpha;
+}
+
+void
+gsm_color_button_set_color (GSMColorButton * color_button,
+                            const GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    g_return_if_fail (color != NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = color->red;
+    priv->color.green = color->green;
+    priv->color.blue = color->blue;
+    priv->color.alpha = color->alpha;
+
+    gtk_widget_queue_draw (GTK_WIDGET (color_button));
+
+    g_object_notify (G_OBJECT (color_button), "color");
+}
+
+void
+gsm_color_button_set_title (GSMColorButton * color_button,
+                            const gchar * title)
+{
+    gchar *old_title;
+    GSMColorButtonPrivate *priv;
+
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    old_title = priv->title;
+    priv->title = g_strdup (title);
+    g_free (old_title);
+
+    if (priv->cc_dialog)
+        gtk_window_set_title (GTK_WINDOW (priv->cc_dialog),
+                              priv->title);
+
+    g_object_notify (G_OBJECT (color_button), "title");
+}
+
+const gchar* gsm_color_button_get_title(GSMColorButton* color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail(GSM_IS_COLOR_BUTTON(color_button), NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->title;
+}
+
+static void
+gsm_color_button_set_property (GObject * object,
+                               guint param_id,
+                               const GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            gsm_color_button_set_fraction (color_button,
+                                           g_value_get_double (value));
+            break;
+        case PROP_TITLE:
+            gsm_color_button_set_title (color_button, g_value_get_string (value));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_set_color (color_button, g_value_get_boxed (value));
+            break;
+        case PROP_TYPE:
+            gsm_color_button_set_cbtype (color_button, g_value_get_uint (value));
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+static void
+gsm_color_button_get_property (GObject * object,
+                               guint param_id,
+                               GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+    GdkRGBA color;
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            g_value_set_double (value,
+                                gsm_color_button_get_fraction (color_button));
+            break;
+        case PROP_TITLE:
+            g_value_set_string (value, gsm_color_button_get_title (color_button));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_get_color (color_button, &color);
+                                        g_value_set_boxed (value, &color);
+            break;
+        case PROP_TYPE:
+            g_value_set_uint (value, gsm_color_button_get_cbtype (color_button));
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/6.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/6.html new file mode 100644 index 00000000..f73c90ba --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/6.html @@ -0,0 +1,1599 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
/* Procman - main window
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <gdk/gdkkeysyms.h>
+#include <math.h>
+
+#include "procman.h"
+#include "callbacks.h"
+#include "interface.h"
+#include "proctable.h"
+#include "procactions.h"
+#include "load-graph.h"
+#include "util.h"
+#include "disks.h"
+#include "sysinfo.h"
+#include "gsm_color_button.h"
+
+static void    cb_toggle_tree (GtkAction *action, gpointer data);
+static void    cb_proc_goto_tab (gint tab);
+
+static const GtkActionEntry menu_entries[] =
+{
+    // xgettext: noun, top level menu.
+    // "File" did not make sense for system-monitor
+    { "Monitor", NULL, N_("_Monitor") },
+    { "Edit", NULL, N_("_Edit") },
+    { "View", NULL, N_("_View") },
+    { "Help", NULL, N_("_Help") },
+
+    { "Lsof", "edit-find", N_("Search for _Open Files"), "<control>O",
+      N_("Search for open files"), G_CALLBACK(cb_show_lsof) },
+    { "Quit", "application-exit", N_("_Quit"), "<control>Q",
+      N_("Quit the program"), G_CALLBACK (cb_app_exit) },
+
+
+    { "StopProcess", NULL, N_("_Stop Process"), "<control>S",
+      N_("Stop process"), G_CALLBACK(cb_kill_sigstop) },
+    { "ContProcess", NULL, N_("_Continue Process"), "<control>C",
+      N_("Continue process if stopped"), G_CALLBACK(cb_kill_sigcont) },
+
+    { "EndProcess", NULL, N_("_End Process"), "<control>E",
+      N_("Force process to finish normally"), G_CALLBACK (cb_end_process) },
+    { "KillProcess", NULL, N_("_Kill Process"), "<control>K",
+      N_("Force process to finish immediately"), G_CALLBACK (cb_kill_process) },
+    { "ChangePriority", NULL, N_("_Change Priority"), NULL,
+      N_("Change the order of priority of process"), NULL },
+    { "Preferences", "preferences-desktop", N_("_Preferences"), NULL,
+      N_("Configure the application"), G_CALLBACK (cb_edit_preferences) },
+
+    { "Refresh", "view-refresh", N_("_Refresh"), "<control>R",
+      N_("Refresh the process list"), G_CALLBACK(cb_user_refresh) },
+
+    { "MemoryMaps", NULL, N_("_Memory Maps"), "<control>M",
+      N_("Open the memory maps associated with a process"), G_CALLBACK (cb_show_memory_maps) },
+    // Translators: this means 'Files that are open' (open is no verb here
+    { "OpenFiles", NULL, N_("Open _Files"), "<control>F",
+      N_("View the files opened by a process"), G_CALLBACK (cb_show_open_files) },
+    { "ProcessProperties", NULL, N_("_Properties"), NULL,
+      N_("View additional information about a process"), G_CALLBACK (cb_show_process_properties) },
+
+
+    { "HelpContents", "help-browser", N_("_Contents"), "F1",
+      N_("Open the manual"), G_CALLBACK (cb_help_contents) },
+    { "About", "help-about", N_("_About"), NULL,
+      N_("About this application"), G_CALLBACK (cb_about) }
+};
+
+static const GtkToggleActionEntry toggle_menu_entries[] =
+{
+    { "ShowDependencies", NULL, N_("_Dependencies"), "<control>D",
+      N_("Show parent/child relationship between processes"),
+      G_CALLBACK (cb_toggle_tree), TRUE },
+};
+
+
+static const GtkRadioActionEntry radio_menu_entries[] =
+{
+  { "ShowActiveProcesses", NULL, N_("_Active Processes"), NULL,
+    N_("Show active processes"), ACTIVE_PROCESSES },
+  { "ShowAllProcesses", NULL, N_("A_ll Processes"), NULL,
+    N_("Show all processes"), ALL_PROCESSES },
+  { "ShowMyProcesses", NULL, N_("M_y Processes"), NULL,
+    N_("Show only user-owned processes"), MY_PROCESSES }
+};
+
+static const GtkRadioActionEntry priority_menu_entries[] =
+{
+    { "VeryHigh", NULL, N_("Very High"), NULL,
+      N_("Set process priority to very high"), VERY_HIGH_PRIORITY },
+    { "High", NULL, N_("High"), NULL,
+      N_("Set process priority to high"), HIGH_PRIORITY },
+    { "Normal", NULL, N_("Normal"), NULL,
+      N_("Set process priority to normal"), NORMAL_PRIORITY },
+    { "Low", NULL, N_("Low"), NULL,
+      N_("Set process priority to low"), LOW_PRIORITY },
+    { "VeryLow", NULL, N_("Very Low"), NULL,
+      N_("Set process priority to very low"), VERY_LOW_PRIORITY },
+    { "Custom", NULL, N_("Custom"), NULL,
+      N_("Set process priority manually"), CUSTOM_PRIORITY }
+};
+
+
+static const char ui_info[] =
+    "  <menubar name=\"MenuBar\">"
+    "    <menu name=\"MonitorMenu\" action=\"Monitor\">"
+    "      <menuitem name=\"MonitorLsofMenu\" action=\"Lsof\" />"
+    "      <menuitem name=\"MonitorQuitMenu\" action=\"Quit\" />"
+    "    </menu>"
+    "    <menu name=\"EditMenu\" action=\"Edit\">"
+    "      <menuitem name=\"EditStopProcessMenu\" action=\"StopProcess\" />"
+    "      <menuitem name=\"EditContProcessMenu\" action=\"ContProcess\" />"
+    "      <separator />"
+    "      <menuitem name=\"EditEndProcessMenu\" action=\"EndProcess\" />"
+    "      <menuitem name=\"EditKillProcessMenu\" action=\"KillProcess\" />"
+    "      <separator />"
+    "      <menu name=\"EditChangePriorityMenu\" action=\"ChangePriority\" >"
+    "        <menuitem action=\"VeryHigh\" />"
+    "        <menuitem action=\"High\" />"
+    "        <menuitem action=\"Normal\" />"
+    "        <menuitem action=\"Low\" />"
+    "        <menuitem action=\"VeryLow\" />"
+    "        <separator />"
+    "        <menuitem action=\"Custom\"/>"
+    "      </menu>"
+    "      <separator />"
+    "      <menuitem name=\"EditPreferencesMenu\" action=\"Preferences\" />"
+    "    </menu>"
+    "    <menu name=\"ViewMenu\" action=\"View\">"
+    "      <menuitem name=\"ViewActiveProcesses\" action=\"ShowActiveProcesses\" />"
+    "      <menuitem name=\"ViewAllProcesses\" action=\"ShowAllProcesses\" />"
+    "      <menuitem name=\"ViewMyProcesses\" action=\"ShowMyProcesses\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewDependenciesMenu\" action=\"ShowDependencies\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewMemoryMapsMenu\" action=\"MemoryMaps\" />"
+    "      <menuitem name=\"ViewOpenFilesMenu\" action=\"OpenFiles\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewProcessPropertiesMenu\" action=\"ProcessProperties\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewRefresh\" action=\"Refresh\" />"
+    "    </menu>"
+    "    <menu name=\"HelpMenu\" action=\"Help\">"
+    "      <menuitem name=\"HelpContentsMenu\" action=\"HelpContents\" />"
+    "      <menuitem name=\"HelpAboutMenu\" action=\"About\" />"
+    "    </menu>"
+    "  </menubar>"
+    "  <popup name=\"PopupMenu\" action=\"Popup\">"
+    "    <menuitem action=\"StopProcess\" />"
+    "    <menuitem action=\"ContProcess\" />"
+    "    <separator />"
+    "    <menuitem action=\"EndProcess\" />"
+    "    <menuitem action=\"KillProcess\" />"
+    "    <separator />"
+    "    <menu name=\"ChangePriorityMenu\" action=\"ChangePriority\" >"
+    "      <menuitem action=\"VeryHigh\" />"
+    "      <menuitem action=\"High\" />"
+    "      <menuitem action=\"Normal\" />"
+    "      <menuitem action=\"Low\" />"
+    "      <menuitem action=\"VeryLow\" />"
+    "      <separator />"
+    "      <menuitem action=\"Custom\"/>"
+    "    </menu>"
+    "    <separator />"
+    "    <menuitem action=\"MemoryMaps\" />"
+    "    <menuitem action=\"OpenFiles\" />"
+    "    <separator />"
+    "    <menuitem action=\"ProcessProperties\" />"
+
+    "  </popup>";
+
+
+static void
+create_proc_view(ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *proctree;
+    GtkWidget *scrolled;
+    char* string;
+
+    /* create the processes tab */
+    string = make_loadavg_string ();
+    procdata->loadavg = GTK_WIDGET (gtk_builder_get_object (builder, "load_avg_label"));
+    gtk_label_set_text (GTK_LABEL (procdata->loadavg), string);
+    g_free (string);
+
+    proctree = proctable_new (procdata);
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "processes_scrolled"));
+
+    gtk_container_add (GTK_CONTAINER (scrolled), proctree);
+
+    procdata->endprocessbutton = GTK_WIDGET (gtk_builder_get_object (builder, "endprocessbutton"));
+    g_signal_connect (G_OBJECT (procdata->endprocessbutton), "clicked",
+                      G_CALLBACK (cb_end_process_button_pressed), procdata);
+
+    /* create popup_menu for the processes tab */
+    procdata->popup_menu = gtk_ui_manager_get_widget (procdata->uimanager, "/PopupMenu");
+}
+
+
+GtkWidget *
+make_title_label (const char *text)
+{
+    GtkWidget *label;
+    char *full;
+
+    full = g_strdup_printf ("<span weight=\"bold\">%s</span>", text);
+    label = gtk_label_new (full);
+    g_free (full);
+
+    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+
+    return label;
+}
+
+
+static void
+create_sys_view (ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *cpu_graph_box, *mem_graph_box, *net_graph_box;
+    GtkWidget *label,*cpu_label;
+    GtkWidget *table;
+    GtkWidget *color_picker;
+    GtkWidget *picker_alignment;
+    LoadGraph *cpu_graph, *mem_graph, *net_graph;
+
+    gint i;
+    gchar *title_text;
+    gchar *label_text;
+    gchar *title_template;
+
+    // Translators: color picker title, %s is CPU, Memory, Swap, Receiving, Sending
+    title_template = g_strdup(_("Pick a Color for '%s'"));
+
+    /* The CPU BOX */
+
+    cpu_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_graph_box"));
+
+    cpu_graph = new LoadGraph(LOAD_GRAPH_CPU);
+    gtk_box_pack_start (GTK_BOX (cpu_graph_box),
+                        load_graph_get_widget(cpu_graph),
+                        TRUE,
+                        TRUE,
+                         0);
+
+    GtkWidget* flowbox = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_flow_box"));
+    gtk_box_reorder_child (GTK_BOX (cpu_graph_box), flowbox, 1);
+    for (i=0;i<procdata->config.num_cpus; i++) {
+        GtkWidget *temp_hbox;
+
+        temp_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
+        gtk_container_add (GTK_CONTAINER (flowbox), temp_hbox);
+
+        color_picker = gsm_color_button_new (&cpu_graph->colors.at(i), GSMCP_TYPE_CPU);
+        g_signal_connect (G_OBJECT (color_picker), "color_set",
+                          G_CALLBACK (cb_cpu_color_changed), GINT_TO_POINTER (i));
+        gtk_box_pack_start (GTK_BOX (temp_hbox), color_picker, FALSE, TRUE, 0);
+        gtk_widget_set_size_request(GTK_WIDGET(color_picker), 32, -1);
+        if(procdata->config.num_cpus == 1) {
+            label_text = g_strdup (_("CPU"));
+        } else {
+            label_text = g_strdup_printf (_("CPU%d"), i+1);
+        }
+        title_text = g_strdup_printf(title_template, label_text);
+        label = gtk_label_new (label_text);
+        gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+        g_free(title_text);
+        gtk_box_pack_start (GTK_BOX (temp_hbox), label, FALSE, FALSE, 6);
+        g_free (label_text);
+
+        cpu_label = gtk_label_new (NULL);
+        gtk_label_set_width_chars (GTK_LABEL (cpu_label), 7);
+        gtk_label_set_xalign (GTK_LABEL (cpu_label), 0.0);
+
+        gtk_box_pack_start (GTK_BOX (temp_hbox), cpu_label, TRUE, TRUE, 0);
+        load_graph_get_labels(cpu_graph)->cpu[i] = cpu_label;
+
+    }
+
+    procdata->cpu_graph = cpu_graph;
+
+    /** The memory box */
+    mem_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "mem_graph_box"));
+
+    mem_graph = new LoadGraph(LOAD_GRAPH_MEM);
+    gtk_box_pack_start (GTK_BOX (mem_graph_box),
+                        load_graph_get_widget(mem_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "mem_table"));
+
+    color_picker = load_graph_get_mem_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_mem_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Memory"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 0, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->memory;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 1, 1, 1, 1);
+
+    color_picker = load_graph_get_swap_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_swap_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Swap"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 2, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->swap;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 3, 1, 1, 1);
+
+    procdata->mem_graph = mem_graph;
+
+    /* The net box */
+    net_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "net_graph_box"));
+
+    net_graph = new LoadGraph(LOAD_GRAPH_NET);
+    gtk_box_pack_start (GTK_BOX (net_graph_box),
+                        load_graph_get_widget(net_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "net_table"));
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(0), GSMCP_TYPE_NETWORK_IN);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_in_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Receiving"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "receiving_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_in;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_in_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 1, 1, 1);
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(1), GSMCP_TYPE_NETWORK_OUT);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_out_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Sending"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "sending_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_out;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_out_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 1, 1, 1);
+
+    procdata->net_graph = net_graph;
+    g_free(title_template);
+}
+
+static void
+menu_item_select_cb (GtkMenuItem *proxy,
+                     ProcData *procdata)
+{
+    GtkAction *action;
+    char *message;
+
+    action = gtk_activatable_get_related_action (GTK_ACTIVATABLE(proxy));
+    g_assert(action);
+
+    g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
+    if (message)
+    {
+        gtk_statusbar_push (GTK_STATUSBAR (procdata->statusbar),
+                    procdata->tip_message_cid, message);
+        g_free (message);
+    }
+}
+
+static void
+menu_item_deselect_cb (GtkMenuItem *proxy,
+                       ProcData *procdata)
+{
+    gtk_statusbar_pop (GTK_STATUSBAR (procdata->statusbar),
+               procdata->tip_message_cid);
+}
+
+static void
+connect_proxy_cb (GtkUIManager *manager,
+                  GtkAction *action,
+                  GtkWidget *proxy,
+                  ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_connect (proxy, "select",
+                          G_CALLBACK (menu_item_select_cb), procdata);
+        g_signal_connect (proxy, "deselect",
+                          G_CALLBACK (menu_item_deselect_cb), procdata);
+    }
+}
+
+static void
+disconnect_proxy_cb (GtkUIManager *manager,
+                     GtkAction *action,
+                     GtkWidget *proxy,
+                     ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_select_cb)), procdata);
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_deselect_cb)), procdata);
+    }
+}
+
+void
+create_main_window (ProcData *procdata)
+{
+    gint i;
+    gint width, height, xpos, ypos;
+    GtkWidget *app;
+    GtkAction *action;
+    GtkWidget *menubar;
+    GtkWidget *main_box;
+    GtkWidget *notebook;
+    GtkBuilder *builder;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/interface.ui");
+
+    app = GTK_WIDGET (gtk_builder_get_object (builder, "main_window"));
+    main_box = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
+
+    GdkScreen* screen = gtk_widget_get_screen(app);
+    /* use visual, if available */
+    GdkVisual* visual = gdk_screen_get_rgba_visual(screen);
+    if (visual)
+        gtk_widget_set_visual(app, visual);
+
+    width = procdata->config.width;
+    height = procdata->config.height;
+    xpos = procdata->config.xpos;
+    ypos = procdata->config.ypos;
+    gtk_window_set_default_size (GTK_WINDOW (app), width, height);
+    gtk_window_move(GTK_WINDOW (app), xpos, ypos);
+
+    if (procdata->config.maximized) {
+        gtk_window_maximize(GTK_WINDOW(app));
+    }
+
+    /* create the menubar */
+    procdata->uimanager = gtk_ui_manager_new ();
+
+    /* show tooltips in the statusbar */
+    g_signal_connect (procdata->uimanager, "connect_proxy",
+                      G_CALLBACK (connect_proxy_cb), procdata);
+    g_signal_connect (procdata->uimanager, "disconnect_proxy",
+                      G_CALLBACK (disconnect_proxy_cb), procdata);
+
+    gtk_window_add_accel_group (GTK_WINDOW (app),
+                                gtk_ui_manager_get_accel_group (procdata->uimanager));
+
+    if (!gtk_ui_manager_add_ui_from_string (procdata->uimanager,
+                                            ui_info,
+                                            -1,
+                                            NULL)) {
+        g_error("building menus failed");
+    }
+
+    procdata->action_group = gtk_action_group_new ("ProcmanActions");
+    gtk_action_group_set_translation_domain (procdata->action_group, NULL);
+    gtk_action_group_add_actions (procdata->action_group,
+                                  menu_entries,
+                                  G_N_ELEMENTS (menu_entries),
+                                  procdata);
+    gtk_action_group_add_toggle_actions (procdata->action_group,
+                                         toggle_menu_entries,
+                                         G_N_ELEMENTS (toggle_menu_entries),
+                                         procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                        radio_menu_entries,
+                        G_N_ELEMENTS (radio_menu_entries),
+                        procdata->config.whose_process,
+                        G_CALLBACK(cb_radio_processes),
+                        procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                                        priority_menu_entries,
+                                        G_N_ELEMENTS (priority_menu_entries),
+                                        NORMAL_PRIORITY,
+                                        G_CALLBACK(cb_renice),
+                                        procdata);
+
+    gtk_ui_manager_insert_action_group (procdata->uimanager,
+                                        procdata->action_group,
+                                        0);
+
+    menubar = gtk_ui_manager_get_widget (procdata->uimanager, "/MenuBar");
+    gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0);
+    gtk_box_reorder_child (GTK_BOX (main_box), menubar, 0);
+
+    /* create the main notebook */
+    procdata->notebook = notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
+
+    create_proc_view(procdata, builder);
+    create_sys_view (procdata, builder);
+    create_disk_view (procdata, builder);
+
+    g_signal_connect (G_OBJECT (notebook), "switch-page",
+              G_CALLBACK (cb_switch_page), procdata);
+    g_signal_connect (G_OBJECT (notebook), "change-current-page",
+              G_CALLBACK (cb_change_current_page), procdata);
+
+    gtk_widget_show_all(notebook); // need to make page switch work
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab);
+    cb_change_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab, procdata);
+    g_signal_connect (G_OBJECT (app), "delete_event",
+                      G_CALLBACK (cb_app_delete),
+                      procdata);
+
+    GtkAccelGroup *accel_group;
+    GClosure *goto_tab_closure[4];
+    accel_group = gtk_accel_group_new ();
+    gtk_window_add_accel_group (GTK_WINDOW(app), accel_group);
+    for (i = 0; i < 4; ++i) {
+        goto_tab_closure[i] = g_cclosure_new_swap (G_CALLBACK (cb_proc_goto_tab),
+                                                   GINT_TO_POINTER (i), NULL);
+        gtk_accel_group_connect (accel_group, '0'+(i+1),
+                                 GDK_MOD1_MASK, GTK_ACCEL_VISIBLE,
+                                 goto_tab_closure[i]);
+    }
+
+    /* create the statusbar */
+    procdata->statusbar = GTK_WIDGET (gtk_builder_get_object (builder, "statusbar"));
+    procdata->tip_message_cid = gtk_statusbar_get_context_id
+        (GTK_STATUSBAR (procdata->statusbar), "tip_message");
+
+    action = gtk_action_group_get_action (procdata->action_group, "ShowDependencies");
+    gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+                      procdata->config.show_tree);
+
+    gtk_builder_connect_signals (builder, NULL);
+
+    gtk_widget_show_all(app);
+    procdata->app = app;
+
+    g_object_unref (G_OBJECT (builder));
+}
+
+void
+do_popup_menu (ProcData *procdata, GdkEventButton *event)
+{
+    gtk_menu_popup_at_pointer (GTK_MENU (procdata->popup_menu), NULL);
+}
+
+void
+update_sensitivity(ProcData *data)
+{
+    const char * const selected_actions[] = { "StopProcess",
+                                              "ContProcess",
+                                              "EndProcess",
+                                              "KillProcess",
+                                              "ChangePriority",
+                                              "MemoryMaps",
+                                              "OpenFiles",
+                                              "ProcessProperties" };
+
+    const char * const processes_actions[] = { "ShowActiveProcesses",
+                                               "ShowAllProcesses",
+                                               "ShowMyProcesses",
+                                               "ShowDependencies",
+                                               "Refresh"
+    };
+
+    size_t i;
+    gboolean processes_sensitivity, selected_sensitivity;
+    GtkAction *action;
+
+    processes_sensitivity = (data->config.current_tab == PROCMAN_TAB_PROCESSES);
+    selected_sensitivity = (processes_sensitivity && data->selection && gtk_tree_selection_count_selected_rows (data->selection) > 0);
+
+    if(data->endprocessbutton) {
+        /* avoid error on startup if endprocessbutton
+           has not been built yet */
+        gtk_widget_set_sensitive(data->endprocessbutton, selected_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(processes_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             processes_actions[i]);
+        gtk_action_set_sensitive(action, processes_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(selected_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             selected_actions[i]);
+        gtk_action_set_sensitive(action, selected_sensitivity);
+    }
+}
+
+void
+block_priority_changed_handlers(ProcData *data, bool block)
+{
+    gint i;
+    if (block) {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_block_by_func(action, (gpointer)cb_renice, data);
+        }
+    } else {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_unblock_by_func(action, (gpointer)cb_renice, data);
+        }
+    }
+}
+
+static void
+cb_toggle_tree (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GSettings *settings = procdata->settings;
+    gboolean show;
+
+    show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+    if (show == procdata->config.show_tree)
+        return;
+
+    g_settings_set_boolean (settings, "show-tree", show);
+}
+
+static void
+cb_proc_goto_tab (gint tab)
+{
+    ProcData *data = ProcData::get_instance ();
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (data->notebook), tab);
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/7.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/7.html new file mode 100644 index 00000000..8b385037 --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/7.html @@ -0,0 +1,1939 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
#include <config.h>
+
+#include <gdkmm/pixbuf.h>
+
+#include <stdio.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <signal.h>
+#include <dirent.h>
+#include <string.h>
+#include <time.h>
+
+#include <glib/gi18n.h>
+
+#include <glibtop.h>
+#include <glibtop/cpu.h>
+#include <glibtop/mem.h>
+#include <glibtop/swap.h>
+#include <glibtop/netload.h>
+#include <glibtop/netlist.h>
+#include <math.h>
+
+#include <algorithm>
+
+#include "procman.h"
+#include "load-graph.h"
+#include "util.h"
+#include "gsm_color_button.h"
+
+void LoadGraph::clear_background()
+{
+    if (background) {
+        cairo_pattern_destroy (background);
+        this->background = NULL;
+    }
+}
+
+
+unsigned LoadGraph::num_bars() const
+{
+    unsigned n;<--- Shadow variable
+
+    // keep 100 % num_bars == 0
+    switch (static_cast<int>(this->draw_height / (fontsize + 14)))
+    {
+    case 0:
+    case 1:
+        n = 1;
+        break;
+    case 2:
+    case 3:
+        n = 2;
+        break;
+    case 4:
+        n = 4;
+        break;
+    default:
+        n = 5;
+    }
+
+    return n;
+}
+
+
+
+#define FRAME_WIDTH 4
+static void draw_background(LoadGraph *graph) {
+    GtkAllocation allocation;
+    cairo_t *cr;
+    guint i;<--- Shadowed declaration
+    unsigned num_bars;
+    g_autofree gchar *caption;
+    PangoLayout* layout;
+    PangoFontDescription* font_desc;
+    PangoRectangle extents;
+    cairo_surface_t *surface;
+    GdkRGBA fg, bg;
+
+    num_bars = graph->num_bars();
+    graph->graph_dely = (graph->draw_height - 15) / num_bars; /* round to int to avoid AA blur */
+    graph->real_draw_height = graph->graph_dely * num_bars;
+    graph->graph_delx = (graph->draw_width - 2.0 - graph->rmargin - graph->indent) / (LoadGraph::NUM_POINTS - 3);
+    graph->graph_buffer_offset = (int) (1.5 * graph->graph_delx) + FRAME_WIDTH ;
+
+    gtk_widget_get_allocation (graph->disp, &allocation);
+    surface = gdk_window_create_similar_surface (gtk_widget_get_window (graph->disp), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height);
+    cr = cairo_create (surface);
+
+    GtkStyleContext *context = gtk_widget_get_style_context (ProcData::get_instance()->notebook);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get_background_color (context, gtk_style_context_get_state (context), &bg);
+    gtk_style_context_get_color (context, gtk_style_context_get_state (context), &fg);
+    gtk_style_context_restore (context);
+
+    // set the background color
+    gdk_cairo_set_source_rgba (cr, &bg);
+    cairo_paint (cr);
+
+    layout = pango_cairo_create_layout (cr);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get (context,
+                           gtk_style_context_get_state (context),
+                           GTK_STYLE_PROPERTY_FONT,
+                           &font_desc, NULL);
+    gtk_style_context_restore (context);
+    pango_font_description_set_size (font_desc, 0.8 * graph->fontsize * PANGO_SCALE);
+    pango_layout_set_font_description (layout, font_desc);
+    pango_font_description_free (font_desc);
+
+    /* draw frame */
+    cairo_translate (cr, FRAME_WIDTH, FRAME_WIDTH);
+
+    /* Draw background rectangle */
+    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+    cairo_rectangle (cr, graph->rmargin + graph->indent, 0,
+                     graph->draw_width - graph->rmargin - graph->indent, graph->real_draw_height);
+    cairo_fill(cr);
+
+    cairo_set_line_width (cr, 1.0);
+    cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    for (i = 0; i <= num_bars; ++i) {
+        double y;
+
+        if (i == 0)
+            y = 0.5 + graph->fontsize / 2.0;
+        else if (i == num_bars)
+            y = i * graph->graph_dely + 0.5;
+        else
+            y = i * graph->graph_dely + graph->fontsize / 2.0;
+
+        gdk_cairo_set_source_rgba (cr, &fg);
+        if (graph->type == LOAD_GRAPH_NET) {
+            // operation orders matters so it's 0 if i == num_bars
+            guint64 rate = graph->net.max - (i * graph->net.max / num_bars);
+            caption = g_format_size_full (network_in_bits ? rate*8 : rate, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        } else {
+            // operation orders matters so it's 0 if i == num_bars
+            caption = g_strdup_printf("%d%%", 100 - i * (100 / num_bars));
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        }
+
+        if (i==0 || i==num_bars)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, graph->rmargin + graph->indent - 3, i * graph->graph_dely + 0.5);
+        cairo_line_to (cr, graph->draw_width - 0.5, i * graph->graph_dely + 0.5);
+        cairo_stroke (cr);
+    }
+
+    const unsigned total_seconds = graph->speed * (LoadGraph::NUM_POINTS - 2) / 1000;
+
+    for (unsigned int i = 0; i < 7; i++) {<--- Shadow variable
+        double x = (i) * (graph->draw_width - graph->rmargin - graph->indent) / 6;
+        if (i==0 || i==6)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, 0.5);
+        cairo_line_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, graph->real_draw_height + 4.5);
+        cairo_stroke(cr);
+        unsigned seconds = total_seconds - i * total_seconds / 6;
+        const char* format;
+        if (i == 0)
+            format = dngettext(GETTEXT_PACKAGE, "%u second", "%u seconds", seconds);
+        else
+            format = "%u";
+        caption = g_strdup_printf(format, seconds);
+        pango_layout_set_text (layout, caption, -1);
+        pango_layout_get_extents (layout, NULL, &extents);
+        cairo_move_to (cr, ((ceil(x) + 0.5) + graph->rmargin + graph->indent) - (1.0 * extents.width / PANGO_SCALE/2), graph->draw_height - 1.0 * extents.height / PANGO_SCALE);
+        gdk_cairo_set_source_rgba (cr, &fg);
+        pango_cairo_show_layout (cr, layout);
+    }
+    g_object_unref(layout);
+    cairo_stroke (cr);
+    cairo_destroy (cr);
+    graph->background = cairo_pattern_create_for_surface (surface);
+    cairo_surface_destroy (surface);
+}
+
+/* Redraws the backing buffer for the load graph and updates the window */
+void
+load_graph_queue_draw (LoadGraph *graph)
+{
+    /* repaint */
+    gtk_widget_queue_draw (graph->disp);
+}
+
+static int load_graph_update (gpointer user_data); // predeclare load_graph_update so we can compile ;)
+
+static gboolean
+load_graph_configure (GtkWidget *widget,
+                      GdkEventConfigure *event,
+                      gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    gtk_widget_get_allocation (widget, &allocation);
+    graph->draw_width = allocation.width - 2 * FRAME_WIDTH;
+    graph->draw_height = allocation.height - 2 * FRAME_WIDTH;
+
+    graph->clear_background();
+
+    load_graph_queue_draw (graph);
+
+    return TRUE;
+}
+
+static gboolean load_graph_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+    GdkWindow *window;
+
+    guint i, j;
+    gdouble sample_width, x_offset;
+
+    window = gtk_widget_get_window (graph->disp);
+
+    /* Number of pixels wide for one graph point */
+    sample_width = (float)(graph->draw_width - graph->rmargin - graph->indent) / (float)LoadGraph::NUM_POINTS;
+    /* General offset */
+    x_offset = graph->draw_width - graph->rmargin + (sample_width*2);
+
+    /* Subframe offset */
+    x_offset += graph->rmargin - ((sample_width / graph->frames_per_unit) * graph->render_counter);
+
+    /* draw the graph */
+    cairo_t* cr;
+
+    cr = gdk_cairo_create (window);
+
+    if (graph->background == NULL) {
+        draw_background(graph);
+    }
+    cairo_set_source (cr, graph->background);
+    cairo_paint (cr);
+
+    cairo_set_line_width (cr, 1);
+    cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+    cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+    cairo_rectangle (cr, graph->rmargin + graph->indent + FRAME_WIDTH + 1, FRAME_WIDTH - 1,
+             graph->draw_width - graph->rmargin - graph->indent - 1, graph->real_draw_height + FRAME_WIDTH - 1);
+    cairo_clip(cr);
+
+    for (j = 0; j < graph->n; ++j) {
+        cairo_move_to (cr, x_offset, (1.0f - graph->data[0][j]) * graph->real_draw_height);
+        gdk_cairo_set_source_rgba (cr, &(graph->colors [j]));
+
+        for (i = 1; i < LoadGraph::NUM_POINTS; ++i) {
+            if (graph->data[i][j] == -1.0f)
+                continue;
+            cairo_curve_to (cr,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i-1][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - (i * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f);
+        }
+        cairo_stroke (cr);
+
+    }
+
+    cairo_destroy (cr);
+
+    return TRUE;
+}
+
+static void
+get_load (LoadGraph *graph)
+{
+    guint i;
+    glibtop_cpu cpu;
+
+    glibtop_get_cpu (&cpu);
+
+#undef NOW
+#undef LAST
+#define NOW  (graph->cpu.times[graph->cpu.now])
+#define LAST (graph->cpu.times[graph->cpu.now ^ 1])
+
+    if (graph->n == 1) {
+        NOW[0][CPU_TOTAL] = cpu.total;
+        NOW[0][CPU_USED] = cpu.user + cpu.nice + cpu.sys;
+    } else {
+        for (i = 0; i < graph->n; i++) {
+            NOW[i][CPU_TOTAL] = cpu.xcpu_total[i];
+            NOW[i][CPU_USED] = cpu.xcpu_user[i] + cpu.xcpu_nice[i]
+                + cpu.xcpu_sys[i];
+        }
+    }
+
+    // on the first call, LAST is 0
+    // which means data is set to the average load since boot
+    // that value has no meaning, we just want all the
+    // graphs to be aligned, so the CPU graph needs to start
+    // immediately
+
+    for (i = 0; i < graph->n; i++) {
+        float load;
+        float total, used;
+        gchar *text;
+
+        total = NOW[i][CPU_TOTAL] - LAST[i][CPU_TOTAL];
+        used  = NOW[i][CPU_USED]  - LAST[i][CPU_USED];
+
+        load = used / MAX(total, 1.0f);
+        graph->data[0][i] = load;
+
+        /* Update label */
+        text = g_strdup_printf("%.1f%%", load * 100.0f);
+        gtk_label_set_text(GTK_LABEL(graph->labels.cpu[i]), text);
+        g_free(text);
+    }
+
+    graph->cpu.now ^= 1;
+
+#undef NOW
+#undef LAST
+}
+
+
+namespace
+{
+
+    void set_memory_label_and_picker(GtkLabel* label, GSMColorButton* picker,
+                                   guint64 used, guint64 total, double percent)
+    {
+        char* used_text;
+        char* total_text;
+        char* text;
+
+        used_text = g_format_size_full(used, G_FORMAT_SIZE_IEC_UNITS);
+        total_text = g_format_size_full(total, G_FORMAT_SIZE_IEC_UNITS);
+        if (total == 0) {
+            text = g_strdup(_("not available"));
+        } else {
+            // xgettext: 540MiB (53 %) of 1.0 GiB
+            text = g_strdup_printf(_("%s (%.1f%%) of %s"), used_text, 100.0 * percent, total_text);
+        }
+        gtk_label_set_text(label, text);
+        g_free(used_text);
+        g_free(total_text);
+        g_free(text);
+
+        if (picker)
+            gsm_color_button_set_fraction(picker, percent);
+    }
+}
+
+static void
+get_memory (LoadGraph *graph)
+{
+    float mempercent, swappercent;
+
+    glibtop_mem mem;
+    glibtop_swap swap;
+
+    glibtop_get_mem (&mem);
+    glibtop_get_swap (&swap);
+
+    /* There's no swap on LiveCD : 0.0f is better than NaN :) */
+    swappercent = (swap.total ? (float)swap.used / (float)swap.total : 0.0f);
+    mempercent  = (float)mem.user  / (float)mem.total;
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.memory),
+                                GSM_COLOR_BUTTON(graph->mem_color_picker),
+                                mem.user, mem.total, mempercent);
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.swap),
+                                GSM_COLOR_BUTTON(graph->swap_color_picker),
+                                swap.used, swap.total, swappercent);
+
+    graph->data[0][0] = mempercent;
+    graph->data[0][1] = swappercent;
+}
+
+/* Nice Numbers for Graph Labels after Paul Heckbert
+   nicenum: find a "nice" number approximately equal to x.
+   Round the number if round=1, take ceiling if round=0    */
+
+static double
+nicenum (double x, int round)
+{
+    int expv;				/* exponent of x */
+    double f;				/* fractional part of x */
+    double nf;				/* nice, rounded fraction */
+
+    expv = floor( log10(x) );
+    f = x/pow( 10.0, expv );		/* between 1 and 10 */
+    if (round) {
+        if ( f < 1.5 ) nf = 1.0;
+        else if ( f < 3.0 ) nf = 2.0;
+        else if ( f < 7.0 ) nf = 5.0;
+        else nf = 10.0;
+    } else {
+        if ( f <= 1.0 ) nf = 1.0;
+        else if ( f <= 2.0 ) nf = 2.0;
+        else if ( f <= 5.0 ) nf = 5.0;
+        else nf = 10.0;
+    }
+    return nf * pow(10.0, expv);
+}
+
+static void
+net_scale (LoadGraph *graph, guint64 din, guint64 dout)
+{
+    graph->data[0][0] = 1.0f * din / graph->net.max;
+    graph->data[0][1] = 1.0f * dout / graph->net.max;
+
+    guint64 dmax = std::max(din, dout);
+    graph->net.values[graph->net.cur] = dmax;
+    graph->net.cur = (graph->net.cur + 1) % LoadGraph::NUM_POINTS;
+
+    guint64 new_max;
+    // both way, new_max is the greatest value
+    if (dmax >= graph->net.max)
+        new_max = dmax;
+    else
+        new_max = *std::max_element(&graph->net.values[0],
+                                    &graph->net.values[LoadGraph::NUM_POINTS]);
+
+    //
+    // Round network maximum
+    //
+
+    const guint64 bak_max(new_max);
+
+    if (ProcData::get_instance()->config.network_in_bits) {
+        // nice number is for the ticks
+        unsigned ticks = graph->num_bars();
+
+        // gets messy at low values due to division by 8
+        guint64 bit_max = std::max( new_max*8, G_GUINT64_CONSTANT(10000) );
+
+        // our tick size leads to max
+        double d = nicenum(bit_max/ticks, 0);
+        bit_max = ticks * d;
+        new_max = bit_max / 8;
+
+        procman_debug("bak*8 %" G_GUINT64_FORMAT ", ticks %d, d %f"
+                      ", bit_max %" G_GUINT64_FORMAT ", new_max %" G_GUINT64_FORMAT,
+                      bak_max*8, ticks, d, bit_max, new_max );
+    } else {
+        // round up to get some extra space
+        // yes, it can overflow
+        new_max = 1.1 * new_max;
+        // make sure max is not 0 to avoid / 0
+        // default to 1 KiB
+        new_max = std::max(new_max, G_GUINT64_CONSTANT(1024));
+
+        // decompose new_max = coef10 * 2**(base10 * 10)
+        // where coef10 and base10 are integers and coef10 < 2**10
+        //
+        // e.g: ceil(100.5 KiB) = 101 KiB = 101 * 2**(1 * 10)
+        //      where base10 = 1, coef10 = 101, pow2 = 16
+
+        guint64 pow2 = std::floor(log2(new_max));
+        guint64 base10 = pow2 / 10.0;
+        guint64 coef10 = std::ceil(new_max / double(G_GUINT64_CONSTANT(1) << (base10 * 10)));
+        g_assert(new_max <= (coef10 * (G_GUINT64_CONSTANT(1) << (base10 * 10))));
+
+        // then decompose coef10 = x * 10**factor10
+        // where factor10 is integer and x < 10
+        // so we new_max has only 1 significant digit
+
+        guint64 factor10 = std::pow(10.0, std::floor(std::log10(coef10)));
+        coef10 = std::ceil(coef10 / double(factor10)) * factor10;
+
+        // then make coef10 divisible by num_bars
+        if (coef10 % graph->num_bars() != 0)
+            coef10 = coef10 + (graph->num_bars() - coef10 % graph->num_bars());
+        g_assert(coef10 % graph->num_bars() == 0);
+        new_max = coef10 * (G_GUINT64_CONSTANT(1) << guint64(base10 * 10));
+        procman_debug("bak %" G_GUINT64_FORMAT " new_max %" G_GUINT64_FORMAT
+                      "pow2 %" G_GUINT64_FORMAT " coef10 %" G_GUINT64_FORMAT,
+                      bak_max, new_max, pow2, coef10);
+    }
+
+    if (bak_max > new_max) {
+        procman_debug("overflow detected: bak=%" G_GUINT64_FORMAT
+                      " new=%" G_GUINT64_FORMAT,
+                      bak_max, new_max);
+        new_max = bak_max;
+    }
+
+    // if max is the same or has decreased but not so much, don't
+    // do anything to avoid rescaling
+    if ((0.8 * graph->net.max) < new_max && new_max <= graph->net.max)
+        return;
+
+    const double scale = 1.0f * graph->net.max / new_max;
+
+    for (size_t i = 0; i < LoadGraph::NUM_POINTS; i++) {
+        if (graph->data[i][0] >= 0.0f) {
+            graph->data[i][0] *= scale;
+            graph->data[i][1] *= scale;
+        }
+    }
+
+    procman_debug("rescale dmax = %" G_GUINT64_FORMAT
+                  " max = %" G_GUINT64_FORMAT
+                  " new_max = %" G_GUINT64_FORMAT,
+                  dmax, graph->net.max, new_max);
+
+    graph->net.max = new_max;
+
+    // force the graph background to be redrawn now that scale has changed
+    graph->clear_background();
+}
+
+static void
+get_net (LoadGraph *graph)
+{
+    glibtop_netlist netlist;
+    char **ifnames;
+    guint32 i;
+    guint64 in = 0, out = 0;
+#if GLIB_CHECK_VERSION(2,61,2)
+    gint64 time;
+#else
+    GTimeVal time;
+#endif
+    guint64 din, dout;
+
+    ifnames = glibtop_get_netlist(&netlist);
+
+    for (i = 0; i < netlist.number; ++i)
+    {
+        glibtop_netload netload;
+        glibtop_get_netload (&netload, ifnames[i]);
+
+        if (netload.if_flags & (1 << GLIBTOP_IF_FLAGS_LOOPBACK))
+            continue;
+
+        /* Skip interfaces without any IPv4/IPv6 address (or
+         those with only a LINK ipv6 addr) However we need to
+         be able to exclude these while still keeping the
+         value so when they get online (with NetworkManager
+         for example) we don't get a suddent peak.  Once we're
+         able to get this, ignoring down interfaces will be
+         possible too.  */
+        if (not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS6)
+             and netload.scope6 != GLIBTOP_IF_IN6_SCOPE_LINK)
+            and not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS)))
+            continue;
+
+        /* Don't skip interfaces that are down (GLIBTOP_IF_FLAGS_UP)
+           to avoid spikes when they are brought up */
+
+        in  += netload.bytes_in;
+        out += netload.bytes_out;
+    }
+
+    g_strfreev(ifnames);
+
+#if GLIB_CHECK_VERSION(2,61,2)
+    time = g_get_real_time ();
+
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time != 0) {
+        float dtime = (double) (time - graph->net.time) / G_USEC_PER_SEC;
+#else
+    g_get_current_time (&time);
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time.tv_sec != 0) {
+        float dtime;
+        dtime = time.tv_sec - graph->net.time.tv_sec +
+            (double) (time.tv_usec - graph->net.time.tv_usec) / G_USEC_PER_SEC;
+#endif
+        din   = static_cast<guint64>((in  - graph->net.last_in)  / dtime);
+        dout  = static_cast<guint64>((out - graph->net.last_out) / dtime);
+    } else {
+        /* Don't calc anything if new data is less than old (interface
+           removed, counters reset, ...) or if it is the first time */
+        din  = 0;
+        dout = 0;
+    }
+
+    graph->net.last_in  = in;
+    graph->net.last_out = out;
+    graph->net.time     = time;
+
+    net_scale(graph, din, dout);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    g_autofree gchar *str=NULL, *formatted_str=NULL;
+
+    str = g_format_size_full (network_in_bits ? din*8 : din, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? in*8 : in, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in_total), str);
+
+    str = g_format_size_full (network_in_bits ? dout*8 : dout, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? out*8 : out, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out_total), str);
+}
+
+
+/* Updates the load graph when the timeout expires */
+static gboolean
+load_graph_update (gpointer user_data)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(user_data);
+
+    if (graph->render_counter == graph->frames_per_unit - 1) {
+        std::rotate(&graph->data[0], &graph->data[LoadGraph::NUM_POINTS - 1], &graph->data[LoadGraph::NUM_POINTS]);
+
+        switch (graph->type) {
+        case LOAD_GRAPH_CPU:
+            get_load(graph);
+            break;
+        case LOAD_GRAPH_MEM:
+            get_memory(graph);
+            break;
+        case LOAD_GRAPH_NET:
+            get_net(graph);
+            break;
+        default:
+            g_assert_not_reached();
+        }
+    }
+
+    if (graph->draw)
+        load_graph_queue_draw (graph);
+
+    graph->render_counter++;
+
+    if (graph->render_counter >= graph->frames_per_unit)
+        graph->render_counter = 0;
+
+    return TRUE;
+}
+
+
+
+LoadGraph::~LoadGraph()
+{
+  load_graph_stop(this);
+
+  if (timer_index)
+    g_source_remove(timer_index);
+
+  clear_background();
+}
+
+
+
+static gboolean
+load_graph_destroy (GtkWidget *widget, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    delete graph;
+
+    return FALSE;
+}
+
+
+LoadGraph::LoadGraph(guint type)
+  : fontsize(8.0),
+    rmargin(3.5 * fontsize),
+    indent(24.0),
+    n(0),
+    type(type),
+    speed(0),
+    draw_width(0),
+    draw_height(0),
+    render_counter(0),
+    frames_per_unit(10), // this will be changed but needs initialising
+    graph_dely(0),
+    real_draw_height(0),
+    graph_delx(0.0),
+    graph_buffer_offset(0),
+    main_widget(NULL),
+    disp(NULL),
+    background(NULL),
+    timer_index(0),
+    draw(FALSE),
+    mem_color_picker(NULL),
+    swap_color_picker(NULL)
+{
+    LoadGraph * const graph = this;
+
+    // FIXME:
+    // on configure, graph->frames_per_unit = graph->draw_width/(LoadGraph::NUM_POINTS);
+    // knock FRAMES down to 5 until cairo gets faster
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memset(&cpu, 0, sizeof cpu);
+        n = ProcData::get_instance()->config.num_cpus;
+
+        for(guint i = 0; i < G_N_ELEMENTS(labels.cpu); ++i)
+            labels.cpu[i] = gtk_label_new(NULL);
+
+        break;
+
+    case LOAD_GRAPH_MEM:
+        n = 2;
+        labels.memory = gtk_label_new(NULL);
+        labels.swap = gtk_label_new(NULL);
+        break;
+
+    case LOAD_GRAPH_NET:
+        memset(&net, 0, sizeof net);
+        n = 2;
+        net.max = 1;
+        labels.net_in = gtk_label_new(NULL);
+        labels.net_in_total = gtk_label_new(NULL);
+        labels.net_out = gtk_label_new(NULL);
+        labels.net_out_total = gtk_label_new(NULL);
+        break;
+    }
+
+    speed  = ProcData::get_instance()->config.graph_update_interval;
+
+    colors.resize(n);
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memcpy(&colors[0], ProcData::get_instance()->config.cpu_color,
+               n * sizeof colors[0]);
+        break;
+    case LOAD_GRAPH_MEM:
+        colors[0] = ProcData::get_instance()->config.mem_color;
+        colors[1] = ProcData::get_instance()->config.swap_color;
+        mem_color_picker = gsm_color_button_new (&colors[0],
+                                                 GSMCP_TYPE_PIE);
+        swap_color_picker = gsm_color_button_new (&colors[1],
+                                                  GSMCP_TYPE_PIE);
+        break;
+    case LOAD_GRAPH_NET:
+        colors[0] = ProcData::get_instance()->config.net_in_color;
+        colors[1] = ProcData::get_instance()->config.net_out_color;
+        break;
+    }
+
+    timer_index = 0;
+    render_counter = (frames_per_unit - 1);
+    draw = FALSE;
+
+    main_widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+    gtk_widget_set_size_request(main_widget, -1, LoadGraph::GRAPH_MIN_HEIGHT);
+    gtk_widget_show (main_widget);
+
+    disp = gtk_drawing_area_new ();
+    gtk_widget_show (disp);
+    g_signal_connect (G_OBJECT (disp), "draw", G_CALLBACK (load_graph_draw), graph);
+    g_signal_connect (G_OBJECT(disp), "configure_event",
+                      G_CALLBACK (load_graph_configure), graph);
+    g_signal_connect (G_OBJECT(disp), "destroy",
+                      G_CALLBACK (load_graph_destroy), graph);
+
+    gtk_widget_set_events (disp, GDK_EXPOSURE_MASK);
+
+    gtk_box_pack_start (GTK_BOX (main_widget), disp, TRUE, TRUE, 0);
+
+
+    /* Allocate data in a contiguous block */
+    data_block = std::vector<float>(n * LoadGraph::NUM_POINTS, -1.0f);
+
+    for (guint i = 0; i < LoadGraph::NUM_POINTS; ++i)
+        data[i] = &data_block[0] + i * n;
+
+    gtk_widget_show_all (main_widget);
+}
+
+void
+load_graph_start (LoadGraph *graph)
+{
+    if(!graph->timer_index) {
+
+        load_graph_update(graph);
+
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->draw = TRUE;
+}
+
+void
+load_graph_stop (LoadGraph *graph)
+{
+    /* don't draw anymore, but continue to poll */
+    graph->draw = FALSE;
+}
+
+void
+load_graph_change_speed (LoadGraph *graph,
+             guint new_speed)
+{
+    if (graph->speed == new_speed)
+        return;
+
+    graph->speed = new_speed;
+
+    if(graph->timer_index) {
+        g_source_remove (graph->timer_index);
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->clear_background();
+}
+
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *graph)
+{
+    return &graph->labels;
+}
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *graph)
+{
+    return graph->main_widget;
+}
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *graph)
+{
+    return graph->mem_color_picker;
+}
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *graph)
+{
+    return graph->swap_color_picker;
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/8.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/8.html new file mode 100644 index 00000000..6bd78123 --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/8.html @@ -0,0 +1,1075 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
#include <config.h>
+
+#include <gtkmm/messagedialog.h>
+#include <glibmm/regex.h>
+#include <glib/gi18n.h>
+#include <glibtop/procopenfiles.h>
+
+#include <sys/wait.h>
+
+#include <set>
+#include <string>
+#include <sstream>
+#include <iterator>
+
+#include <glibmm/regex.h>
+
+#include "procman.h"
+#include "lsof.h"
+#include "util.h"
+
+
+using std::string;
+
+
+namespace
+{
+
+    class Lsof
+    {
+        Glib::RefPtr<Glib::Regex> re;
+
+        bool matches(const string &filename) const
+        {
+            return this->re->match(filename);
+        }
+
+    public:
+
+        Lsof(const string &pattern, bool caseless)
+        {
+            Glib::RegexCompileFlags flags = static_cast<Glib::RegexCompileFlags>(0);
+
+            if (caseless)
+                flags |= Glib::REGEX_CASELESS;
+
+            this->re = Glib::Regex::create(pattern, flags);
+        }
+
+
+        template<typename OutputIterator>
+        void search(const ProcInfo &info, OutputIterator out) const
+        {
+            glibtop_open_files_entry *entries;
+            glibtop_proc_open_files buf;
+
+            entries = glibtop_get_proc_open_files(&buf, info.pid);
+
+            for (unsigned i = 0; i != buf.number; ++i) {
+                if (entries[i].type & GLIBTOP_FILE_TYPE_FILE) {
+                    const string filename(entries[i].info.file.name);
+                    if (this->matches(filename))
+                        *out++ = filename;
+                }
+            }
+
+            g_free(entries);
+        }
+    };
+
+
+
+    // GUI Stuff
+
+
+    enum ProcmanLsof {
+        PROCMAN_LSOF_COL_SURFACE,
+        PROCMAN_LSOF_COL_PROCESS,
+        PROCMAN_LSOF_COL_PID,
+        PROCMAN_LSOF_COL_FILENAME,
+        PROCMAN_LSOF_NCOLS
+    };
+
+
+    struct GUI {
+
+        GtkListStore *model;
+        GtkEntry *entry;
+        GtkWindow *window;
+        GtkLabel *count;<--- Shadowed declaration
+        ProcData *procdata;
+        bool case_insensitive;
+
+
+        GUI()
+        {
+            procman_debug("New Lsof GUI %p", this);
+        }
+
+
+        ~GUI()
+        {
+            procman_debug("Destroying Lsof GUI %p", this);
+        }
+
+
+        void clear_results()
+        {
+            gtk_list_store_clear(this->model);
+            gtk_label_set_text(this->count, "");
+        }
+
+
+        void clear()
+        {
+            this->clear_results();
+            gtk_entry_set_text(this->entry, "");
+        }
+
+
+        void display_regex_error(const Glib::RegexError& error)
+        {
+            char * msg = g_strdup_printf ("<b>%s</b>\n%s\n%s",
+                                          _("Error"),
+                                          _("'%s' is not a valid Perl regular expression."),
+                                          "%s");
+            std::string message = make_string(g_strdup_printf(msg, this->pattern().c_str(), error.what().c_str()));
+            g_free(msg);
+
+            Gtk::MessageDialog dialog(message,
+                                      true, // use markup
+                                      Gtk::MESSAGE_ERROR,
+                                      Gtk::BUTTONS_OK,
+                                      true); // modal
+            dialog.run();
+        }
+
+
+        void update_count(unsigned count)
+        {
+            std::ostringstream ss;
+            ss << count;
+            string s = ss.str();
+            gtk_label_set_text(this->count, s.c_str());
+        }
+
+
+        string pattern() const
+        {
+            return gtk_entry_get_text(this->entry);
+        }
+
+
+        void search()
+        {
+            typedef std::set<string> MatchSet;
+            typedef MatchSet::const_iterator iterator;
+
+            this->clear_results();
+
+
+            try {
+                Lsof lsof(this->pattern(), this->case_insensitive);
+
+                unsigned count = 0;<--- Shadow variable
+
+                for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it) {
+                    const ProcInfo &info(*it->second);
+
+                    MatchSet matches;
+                    lsof.search(info, std::inserter(matches, matches.begin()));
+                    count += matches.size();
+
+                    for (iterator it(matches.begin()), end(matches.end()); it != end; ++it) {
+                        GtkTreeIter file;
+                        gtk_list_store_append(this->model, &file);
+                        gtk_list_store_set(this->model, &file,
+                                           PROCMAN_LSOF_COL_SURFACE, info.surface,
+                                           PROCMAN_LSOF_COL_PROCESS, info.name,
+                                           PROCMAN_LSOF_COL_PID, info.pid,
+                                           PROCMAN_LSOF_COL_FILENAME, it->c_str(),
+                                           -1);
+                    }
+                }
+
+                this->update_count(count);
+            }
+            catch (Glib::RegexError& error) {
+                this->display_regex_error(error);
+            }
+        }
+
+
+        static void search_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void search_entry_activate(GtkEntry *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void clear_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->clear();
+        }
+
+
+        static void close_button_clicked(GtkButton *, gpointer data)
+        {
+            GUI *gui = static_cast<GUI*>(data);
+            gtk_widget_destroy(GTK_WIDGET(gui->window));
+            delete gui;
+        }
+
+
+        static void case_button_toggled(GtkToggleButton *button, gpointer data)
+        {
+            bool state = gtk_toggle_button_get_active(button);
+            static_cast<GUI*>(data)->case_insensitive = state;
+        }
+
+
+        static gboolean window_delete_event(GtkWidget *, GdkEvent *, gpointer data)
+        {
+            delete static_cast<GUI*>(data);
+            return FALSE;
+        }
+
+    };
+}
+
+
+
+
+void procman_lsof(ProcData *procdata)
+{
+    GtkListStore *model = \
+        gtk_list_store_new(PROCMAN_LSOF_NCOLS,
+                           CAIRO_GOBJECT_TYPE_SURFACE, // PROCMAN_LSOF_COL_SURFACE
+                           G_TYPE_STRING,              // PROCMAN_LSOF_COL_PROCESS
+                           G_TYPE_UINT,                // PROCMAN_LSOF_COL_PID
+                           G_TYPE_STRING               // PROCMAN_LSOF_COL_FILENAME
+        );
+
+    GtkWidget *tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_object_unref(model);
+
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *renderer;
+
+    // SURFACE / PROCESS
+
+    column = gtk_tree_view_column_new();
+
+    renderer = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "surface", PROCMAN_LSOF_COL_SURFACE,
+                                        NULL);
+
+    renderer = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "text", PROCMAN_LSOF_COL_PROCESS,
+                                        NULL);
+
+    gtk_tree_view_column_set_title(column, _("Process"));
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PROCESS);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_column_set_min_width(column, 10);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), PROCMAN_LSOF_COL_PROCESS,
+                                         GTK_SORT_ASCENDING);
+
+
+    // PID
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("PID"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_PID,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PID);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    // FILENAME
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("Filename"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_FILENAME,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_FILENAME);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    GtkWidget *dialog; /* = gtk_dialog_new_with_buttons(_("Search for Open Files"), NULL,
+                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+                                                        NULL); */
+    dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(procdata->app));
+    gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
+    // gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_title(GTK_WINDOW(dialog), _("Search for Open Files"));
+
+    // g_signal_connect(G_OBJECT(dialog), "response",
+    //                           G_CALLBACK(close_dialog), NULL);
+    gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(dialog), 575, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(dialog), 12);
+    GtkWidget *mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_add(GTK_CONTAINER(dialog), mainbox);
+    gtk_box_set_spacing(GTK_BOX(mainbox), 6);
+
+
+    // Label, entry and search button
+
+    GtkWidget *hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), hbox1, FALSE, FALSE, 0);
+
+    GtkWidget *image = gtk_image_new_from_icon_name("edit-find", GTK_ICON_SIZE_DIALOG);
+    gtk_box_pack_start(GTK_BOX(hbox1), image, FALSE, FALSE, 0);
+
+
+    GtkWidget *vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox1), vbox2, TRUE, TRUE, 0);
+
+
+    GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox, TRUE, TRUE, 0);
+    GtkWidget *label = gtk_label_new_with_mnemonic(_("_Name contains:"));
+    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+    GtkWidget *entry = gtk_entry_new();
+
+    gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
+
+    GtkWidget *search_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                         "label", "gtk-find",
+                                                         "use-stock", TRUE,
+                                                         "use-underline", TRUE,
+                                                         NULL));
+
+    gtk_box_pack_start(GTK_BOX(hbox), search_button, FALSE, FALSE, 0);
+
+    GtkWidget *clear_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-clear",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    /* The default accelerator collides with the default close accelerator. */
+    gtk_button_set_label(GTK_BUTTON(clear_button), _("C_lear"));
+    gtk_box_pack_start(GTK_BOX(hbox), clear_button, FALSE, FALSE, 0);
+
+
+    GtkWidget *case_button = gtk_check_button_new_with_mnemonic(_("Case insensitive matching"));
+    GtkWidget *hbox3 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox3), case_button, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox3, FALSE, FALSE, 0);
+
+
+    GtkWidget *results_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), results_box, FALSE, FALSE, 0);
+    GtkWidget *results_label = gtk_label_new_with_mnemonic(_("S_earch results:"));
+    gtk_box_pack_start(GTK_BOX(results_box), results_label, FALSE, FALSE, 0);
+    GtkWidget *count_label = gtk_label_new(NULL);
+    gtk_box_pack_end(GTK_BOX(results_box), count_label, FALSE, FALSE, 0);
+
+    // Scrolled TreeView
+    GtkWidget *scrolled = gtk_scrolled_window_new(NULL, NULL);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
+                                   GTK_POLICY_AUTOMATIC,
+                                   GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled),
+                                        GTK_SHADOW_IN);
+    gtk_container_add(GTK_CONTAINER(scrolled), tree);
+    gtk_box_pack_start(GTK_BOX(mainbox), scrolled, TRUE, TRUE, 0);
+
+    GtkWidget *bottom_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+
+    GtkWidget *close_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-close",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    gtk_box_pack_start(GTK_BOX(mainbox), bottom_box, FALSE, FALSE, 0);
+    gtk_box_pack_end(GTK_BOX(bottom_box), close_button, FALSE, FALSE, 0);
+
+
+    GUI *gui = new GUI; // wil be deleted by the close button or delete-event
+    gui->procdata = procdata;
+    gui->model = model;
+    gui->window = GTK_WINDOW(dialog);
+    gui->entry = GTK_ENTRY(entry);
+    gui->count = GTK_LABEL(count_label);
+
+    g_signal_connect(G_OBJECT(entry), "activate",
+                     G_CALLBACK(GUI::search_entry_activate), gui);
+    g_signal_connect(G_OBJECT(clear_button), "clicked",
+                     G_CALLBACK(GUI::clear_button_clicked), gui);
+    g_signal_connect(G_OBJECT(search_button), "clicked",
+                     G_CALLBACK(GUI::search_button_clicked), gui);
+    g_signal_connect(G_OBJECT(close_button), "clicked",
+                     G_CALLBACK(GUI::close_button_clicked), gui);
+    g_signal_connect(G_OBJECT(case_button), "toggled",
+                     G_CALLBACK(GUI::case_button_toggled), gui);
+    g_signal_connect(G_OBJECT(dialog), "delete-event",
+                     G_CALLBACK(GUI::window_delete_event), gui);
+
+
+    gtk_widget_show_all(dialog);
+}
+
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/9.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/9.html new file mode 100644 index 00000000..b1d95a0b --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/9.html @@ -0,0 +1,1197 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
#include <config.h>
+
+#include <glibtop/procmap.h>
+#include <glibtop/mountlist.h>
+#include <sys/stat.h>
+#include <glib/gi18n.h>
+
+#include <string>
+#include <map>
+#include <sstream>
+#include <iomanip>
+#include <stdexcept>
+
+using std::string;
+
+
+#include "procman.h"
+#include "memmaps.h"
+#include "proctable.h"
+#include "util.h"
+
+
+/* be careful with this enum, you could break the column names */
+enum
+{
+    MMAP_COL_FILENAME,
+    MMAP_COL_VMSTART,
+    MMAP_COL_VMEND,
+    MMAP_COL_VMSZ,
+    MMAP_COL_FLAGS,
+    MMAP_COL_VMOFFSET,
+    MMAP_COL_PRIVATE_CLEAN,
+    MMAP_COL_PRIVATE_DIRTY,
+    MMAP_COL_SHARED_CLEAN,
+    MMAP_COL_SHARED_DIRTY,
+    MMAP_COL_DEVICE,
+    MMAP_COL_INODE,
+    MMAP_COL_MAX
+};
+
+
+namespace
+{
+    class OffsetFormater
+    {
+        string format;
+
+    public:
+
+        void set(const glibtop_map_entry &last_map)
+        {
+            this->format = (last_map.end <= G_MAXUINT32) ? "%08" G_GINT64_MODIFIER "x" : "%016" G_GINT64_MODIFIER "x";
+        }
+
+        string operator()(guint64 v) const
+        {
+            char buffer[17];
+            g_snprintf(buffer, sizeof buffer, this->format.c_str(), v);
+            return buffer;
+        }
+    };
+
+
+    class InodeDevices
+    {
+        typedef std::map<guint16, string> Map;
+        Map devices;
+
+    public:
+
+        void update()
+        {
+            this->devices.clear();
+
+            glibtop_mountlist list;
+            glibtop_mountentry *entries = glibtop_get_mountlist(&list, 1);
+
+            for (unsigned i = 0; i != list.number; ++i) {
+                struct stat buf;
+
+                if (stat(entries[i].devname, &buf) != -1)
+                    this->devices[buf.st_rdev] = entries[i].devname;
+            }
+
+            g_free(entries);
+        }
+
+        string get(guint64 dev64)
+        {
+            if (dev64 == 0)
+                return "";
+
+            guint16 dev = dev64 & 0xffff;
+
+            if (dev != dev64)
+                g_warning("weird device %" G_GINT64_MODIFIER "x", dev64);
+
+            Map::iterator it(this->devices.find(dev));
+
+            if (it != this->devices.end())
+                return it->second;
+
+            guint8 major, minor;
+            major = dev >> 8;
+            minor = dev;
+
+            std::ostringstream out;
+            out << std::hex
+                << std::setfill('0')
+                << std::setw(2) << unsigned(major)
+                << ':'
+                << std::setw(2) << unsigned(minor);
+
+            this->devices[dev] = out.str();
+            return out.str();
+        }
+    };
+
+
+    class MemMapsData
+    {
+    public:
+        guint timer;
+        GtkWidget *tree;
+        GSettings *settings;
+        ProcInfo *info;
+        OffsetFormater format;
+        mutable InodeDevices devices;
+        const char * const schema;
+
+        MemMapsData(GtkWidget *a_tree, GSettings *a_settings)
+            : tree(a_tree),
+            settings(a_settings),
+            schema("memmapstree")
+        {
+            procman_get_tree_state(this->settings, this->tree, this->schema);
+        }
+
+        ~MemMapsData()
+        {
+            procman_save_tree_state(this->settings, this->tree, this->schema);
+        }
+    };
+}
+
+
+struct glibtop_map_entry_cmp
+{
+    bool operator()(const glibtop_map_entry &a, const guint64 start) const
+    {
+        return a.start < start;
+    }
+
+    bool operator()(const guint64 &start, const glibtop_map_entry &a) const
+    {
+        return start < a.start;
+    }
+
+};
+
+
+static void
+update_row(GtkTreeModel *model, GtkTreeIter &row, const MemMapsData &mm, const glibtop_map_entry *memmaps)
+{
+    guint64 size;
+    string filename, device;
+    string vmstart, vmend, vmoffset;
+    char flags[5] = "----";
+
+    size = memmaps->end - memmaps->start;
+
+    if(memmaps->perm & GLIBTOP_MAP_PERM_READ)    flags [0] = 'r';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_WRITE)   flags [1] = 'w';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_EXECUTE) flags [2] = 'x';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_SHARED)  flags [3] = 's';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_PRIVATE) flags [3] = 'p';
+
+    if (memmaps->flags & (1 << GLIBTOP_MAP_ENTRY_FILENAME))
+      filename = memmaps->filename;
+
+    vmstart  = mm.format(memmaps->start);
+    vmend    = mm.format(memmaps->end);
+    vmoffset = mm.format(memmaps->offset);
+    device   = mm.devices.get(memmaps->device);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        MMAP_COL_FILENAME, filename.c_str(),
+                        MMAP_COL_VMSTART, vmstart.c_str(),
+                        MMAP_COL_VMEND, vmend.c_str(),
+                        MMAP_COL_VMSZ, size,
+                        MMAP_COL_FLAGS, flags,
+                        MMAP_COL_VMOFFSET, vmoffset.c_str(),
+                        MMAP_COL_PRIVATE_CLEAN, memmaps->private_clean,
+                        MMAP_COL_PRIVATE_DIRTY, memmaps->private_dirty,
+                        MMAP_COL_SHARED_CLEAN, memmaps->shared_clean,
+                        MMAP_COL_SHARED_DIRTY, memmaps->shared_dirty,
+                        MMAP_COL_DEVICE, device.c_str(),
+                        MMAP_COL_INODE, memmaps->inode,
+                        -1);
+}
+
+
+
+
+static void
+update_memmaps_dialog (MemMapsData *mmdata)
+{
+    GtkTreeModel *model;
+    glibtop_map_entry *memmaps;
+    glibtop_proc_map procmap;
+
+    memmaps = glibtop_get_proc_map (&procmap, mmdata->info->pid);
+    /* process has disappeared */
+    if(!memmaps or procmap.number == 0) return;
+
+    mmdata->format.set(memmaps[procmap.number - 1]);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+
+    GtkTreeIter iter;<--- Shadowed declaration
+
+    typedef std::map<guint64, GtkTreeIter> IterCache;
+    IterCache iter_cache;
+
+    /*
+      removes the old maps and
+      also fills a cache of start -> iter in order to speed
+      up add
+    */
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        while (true) {
+            char *vmstart = 0;
+            guint64 start;
+            gtk_tree_model_get(model, &iter,
+                               MMAP_COL_VMSTART, &vmstart,
+                               -1);
+
+            try {
+                std::istringstream(vmstart) >> std::hex >> start;
+            } catch (std::logic_error &e) {
+                g_warning("Could not parse %s", vmstart);
+                start = 0;
+            }
+
+            g_free(vmstart);
+
+            bool found = std::binary_search(memmaps, memmaps + procmap.number,
+                                            start, glibtop_map_entry_cmp());
+
+            if (found) {
+                iter_cache[start] = iter;
+                if (!gtk_tree_model_iter_next(model, &iter))
+                    break;
+            } else {
+                if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                    break;
+            }
+        }
+    }
+
+    mmdata->devices.update();
+
+    /*
+      add the new maps
+    */
+
+    for (guint i = 0; i != procmap.number; i++) {
+        GtkTreeIter iter;<--- Shadow variable
+        IterCache::iterator it(iter_cache.find(memmaps[i].start));
+
+        if (it != iter_cache.end())
+            iter = it->second;
+        else
+            gtk_list_store_prepend(GTK_LIST_STORE(model), &iter);
+
+        update_row(model, iter, *mmdata, &memmaps[i]);
+    }
+
+    g_free (memmaps);
+}
+
+
+
+static void
+dialog_response (GtkDialog * dialog, gint response_id, gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+
+    g_source_remove (mmdata->timer);
+
+    delete mmdata;
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+
+static MemMapsData*
+create_memmapsdata (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Filename"),
+        // xgettext: virtual memory start
+        N_("VM Start"),
+        // xgettext: virtual memory end
+        N_("VM End"),
+        // xgettext: virtual memory syze
+        N_("VM Size"),
+        N_("Flags"),
+        // xgettext: virtual memory offset
+        N_("VM Offset"),
+        // xgettext: memory that has not been modified since
+        // it has been allocated
+        N_("Private clean"),
+        // xgettext: memory that has been modified since it
+        // has been allocated
+        N_("Private dirty"),
+        // xgettext: shared memory that has not been modified
+        // since it has been allocated
+        N_("Shared clean"),
+        // xgettext: shared memory that has been modified
+        // since it has been allocated
+        N_("Shared dirty"),
+        N_("Device"),
+        N_("Inode")
+    };
+
+    model = gtk_list_store_new (MMAP_COL_MAX,
+                                G_TYPE_STRING, /* MMAP_COL_FILENAME  */
+                                G_TYPE_STRING, /* MMAP_COL_VMSTART     */
+                                G_TYPE_STRING, /* MMAP_COL_VMEND     */
+                                G_TYPE_UINT64, /* MMAP_COL_VMSZ     */
+                                G_TYPE_STRING, /* MMAP_COL_FLAGS     */
+                                G_TYPE_STRING, /* MMAP_COL_VMOFFSET  */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_DIRTY */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_DIRTY */
+                                G_TYPE_STRING, /* MMAP_COL_DEVICE     */
+                                G_TYPE_UINT64 /* MMAP_COL_INODE     */
+                                );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < MMAP_COL_MAX; i++) {
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(tree), col);
+
+        switch (i) {
+            case MMAP_COL_PRIVATE_CLEAN:
+            case MMAP_COL_PRIVATE_DIRTY:
+            case MMAP_COL_SHARED_CLEAN:
+            case MMAP_COL_SHARED_DIRTY:
+            case MMAP_COL_VMSZ:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                         &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+                break;
+        }
+
+
+        switch (i) {
+            case MMAP_COL_VMSTART:
+            case MMAP_COL_VMEND:
+            case MMAP_COL_FLAGS:
+            case MMAP_COL_VMOFFSET:
+            case MMAP_COL_DEVICE:
+                g_object_set(cell, "family", "monospace", NULL);
+                break;
+        }
+    }
+
+    return new MemMapsData(tree, procdata->settings);
+}
+
+
+static gboolean
+memmaps_timer (gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+    g_assert(model);
+
+    update_memmaps_dialog (mmdata);
+
+    return TRUE;
+}
+
+
+static void
+create_single_memmaps_dialog (GtkTreeModel *model, GtkTreePath *path,
+                              GtkTreeIter *iter, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    MemMapsData *mmdata;
+    GtkWidget *memmapsdialog;
+    GtkWidget *dialog_vbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    ProcInfo *info;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    mmdata = create_memmapsdata (procdata);
+    mmdata->info = info;
+
+    memmapsdialog = gtk_dialog_new_with_buttons (_("Memory Maps"), GTK_WINDOW (procdata->app),
+                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                 "gtk-close", GTK_RESPONSE_CLOSE,
+                                                 NULL);
+    gtk_window_set_resizable(GTK_WINDOW(memmapsdialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(memmapsdialog), 620, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(memmapsdialog), 5);
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG(memmapsdialog));
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Memory maps for process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), label, FALSE, TRUE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    gtk_container_add (GTK_CONTAINER (scrolled), mmdata->tree);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), mmdata->tree);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+
+    g_signal_connect(G_OBJECT(memmapsdialog), "response",
+                              G_CALLBACK(dialog_response), mmdata);
+
+    gtk_widget_show_all (memmapsdialog);
+
+    mmdata->timer = g_timeout_add_seconds (5, memmaps_timer, mmdata);
+
+    update_memmaps_dialog (mmdata);
+}
+
+
+void
+create_memmaps_dialog (ProcData *procdata)
+{
+    /* TODO: do we really want to open multiple dialogs ? */
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_memmaps_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/index.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/index.html new file mode 100644 index 00000000..02bb6ffc --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/index.html @@ -0,0 +1,323 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/cgroups.cpp
27variableScope398styleThe scope of the variable 'paren_offset' can be reduced.
27variableScope398styleThe scope of the variable 'off' can be reduced.
27variableScope398styleThe scope of the variable 'tmp_size' can be reduced.
55cstyleCast398styleC-style pointer casting
src/disks.cpp
202redundantAssignment563styleVariable 'res' is reassigned a value before the old one has been used.
src/gsm_color_button.c
648variableScope398styleThe scope of the variable 'color_chooser' can be reduced.
src/interface.cpp
452cstyleCast398styleC-style pointer casting
454cstyleCast398styleC-style pointer casting
src/load-graph.cpp
41shadowVariable398styleLocal variable 'n' shadows outer variable
164shadowVariable398styleLocal variable 'i' shadows outer variable
src/load-graph.h
36noExplicitConstructor398styleStruct 'LoadGraph' has a constructor with 1 argument that is not explicit.
src/lsof.cpp
164shadowVariable398styleLocal variable 'count' shadows outer variable
src/memmaps.cpp
269shadowVariable398styleLocal variable 'iter' shadows outer variable
src/msm-resources.c
9unusedStructMember563styleunion member 'Anonymous0::alignment' is never used.
9unusedStructMember563styleunion member 'Anonymous0::ptr' is never used.
src/openfiles.cpp
73nullPointerRedundantCheck476warningEither the condition 'res' is redundant or there is possible null pointer dereference: res.
205shadowVariable398styleLocal variable 'openfiles' shadows outer variable
247variableScope398styleThe scope of the variable 'column' can be reduced.
248variableScope398styleThe scope of the variable 'cell' can be reduced.
src/prettytable.h
39unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_opened'
40unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_closed'
src/procdialogs.cpp
294noExplicitConstructor398styleClass 'SpinButtonUpdater' has a constructor with 1 argument that is not explicit.
415shadowVariable398styleLocal variable 'column' shadows outer variable
475cstyleCast398styleC-style pointer casting
498cstyleCast398styleC-style pointer casting
513cstyleCast398styleC-style pointer casting
src/procman-app.cpp
348uninitMemberVar398warningMember variable 'ProcmanApp::procdata' is not initialized in the constructor.
src/procman.cpp
34uninitMemberVarPrivate398warningMember variable 'ProcData::uimanager' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::action_group' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::statusbar' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::loadavg' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::endprocessbutton' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::popup_menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::disk_list' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::notebook' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::config' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::selection' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::settings' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::app' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::frequency' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::smooth_refresh' is not initialized in the constructor.
112shadowVariable398styleLocal variable 'order' shadows outer variable
162shadowVariable398styleLocal variable 'order' shadows outer variable
src/procman.h
103uninitMemberVar398warningMember variable 'MutableProcInfo::cgroup_name' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::unit' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::session' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::seat' is not initialized in the constructor.
173noExplicitConstructor398styleClass 'ProcInfo' has a constructor with 1 argument that is not explicit.
src/procproperties.cpp
208variableScope398styleThe scope of the variable 'column' can be reduced.
209variableScope398styleThe scope of the variable 'cell' can be reduced.
src/proctable.cpp
920shadowVariable398styleLocal variable 'arguments' shadows outer variable
929shadowVariable398styleLocal variable 'tooltip' shadows outer variable
1016shadowVariable398styleLocal variable 'it' shadows outer variable
1022shadowVariable398styleLocal variable 'it' shadows outer variable
1068shadowVariable398styleLocal variable 'it' shadows outer variable
1073shadowVariable398styleLocal variable 'it' shadows outer variable
src/selinux.cpp
21varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
src/smooth_refresh.h
22noExplicitConstructor398styleClass 'SmoothRefresh' has a constructor with 1 argument that is not explicit.
src/sysinfo.cpp
126unusedPrivateFunction398styleUnused private function: 'SysInfo::get_os_type'
233cstyleCast398styleC-style pointer casting
343cstyleCast398styleC-style pointer casting
509uninitMemberVar398warningMember variable 'LSBSysInfo::lsb_fd' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::name' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::release' is not initialized in the constructor.
515missingOverridestyleThe function 'set_distro_labels' overrides a function in a base class but is not marked with a 'override' specifier.
570shadowVariable398styleLocal variable 'release' shadows outer variable
615unusedPrivateFunction398styleUnused private function: 'LSBSysInfo::sync_lsb_release'
626variableScope398styleThe scope of the variable 'codename' can be reduced.
626shadowVariable398styleLocal variable 'release' shadows outer variable
690stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
697stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
701stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
736variableScope398styleThe scope of the variable 'len' can be reduced.
738stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
1001unreadVariable563styleVariable 'table_count' is assigned a value that is never used.
+
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/stats.html b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/stats.html new file mode 100644 index 00000000..aa8922ed --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/stats.html @@ -0,0 +1,189 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+

Top 10 files for warning severity, total findings: 24
+   15  src/procman.cpp
+   4   src/procman.h
+   3   src/sysinfo.cpp
+   1   src/procman-app.cpp
+   1   src/openfiles.cpp
+

+

Top 10 files for portability severity, total findings: 1
+   1  src/selinux.cpp
+

+

Top 10 files for performance severity, total findings: 4
+   4  src/sysinfo.cpp
+

+

Top 10 files for style severity, total findings: 47
+   10  src/sysinfo.cpp
+   6   src/proctable.cpp
+   5   src/procdialogs.cpp
+   4   src/cgroups.cpp
+   3   src/openfiles.cpp
+   2   src/procproperties.cpp
+   2   src/procman.cpp
+   2   src/prettytable.h
+   2   src/msm-resources.c
+   2   src/load-graph.cpp
+

+ +
+ +
+ + diff --git a/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/style.css b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/style.css new file mode 100644 index 00000000..3897bfaf --- /dev/null +++ b/2023-05-15-174607-3004-cppcheck@e1533eb204f2_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-09-04-185402-6123-1@d0fc4b9c7899_master/index.html b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/index.html new file mode 100644 index 00000000..f2cc0450 --- /dev/null +++ b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/index.html @@ -0,0 +1,136 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@d91e964d4731
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 16.0.6 (Fedora 16.0.6-2.fc38) +
Date:Mon Sep 4 18:54:02 2023
+

Bug Summary

+ + + + + + + +
Bug TypeQuantityDisplay?
All Bugs14
Logic error
Use of identical expressions1
Unused code
Dead assignment1
Unreachable code12
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
Unused codeDead assignmentrootdir/src/disks.cppget_mount_opt2011View Report
Unused codeUnreachable coderootdir/src/procman-app.cppon_command_line3811View Report
Unused codeUnreachable coderootdir/src/util.cppio_rate_cell_data_func4941View Report
Unused codeUnreachable coderootdir/src/util.cppstatus_cell_data_func5911View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_gicon421View Report
Unused codeUnreachable coderootdir/src/util.cppduration_cell_data_func5351View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_na_cell_data_func3841View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_na_cell_data_func4561View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_cell_data_func4221View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_icon131View Report
Unused codeUnreachable coderootdir/src/util.cpptime_cell_data_func5641View Report
Unused codeUnreachable coderootdir/src/procman-app.cpptimeouts_changed_cb1511View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_cell_data_func3501View Report
Logic errorUse of identical expressionsusr/include/sigc++-2.0/sigc++/visit_each.hoperator()981View Report
+ + diff --git a/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-22e004.html b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-22e004.html new file mode 100644 index 00000000..37c844ca --- /dev/null +++ b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-22e004.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 381, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-04-185402-6123-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
This statement is never executed
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-491eb3.html b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-491eb3.html new file mode 100644 index 00000000..da806e02 --- /dev/null +++ b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-491eb3.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 494, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-04-185402-6123-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-4d889d.html b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-4d889d.html new file mode 100644 index 00000000..5b3c4bec --- /dev/null +++ b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-4d889d.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 591, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-04-185402-6123-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-633ebf.html b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-633ebf.html new file mode 100644 index 00000000..4d2d67a8 --- /dev/null +++ b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-633ebf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 42, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-04-185402-6123-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
This statement is never executed
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-6c54e6.html b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-6c54e6.html new file mode 100644 index 00000000..08679af4 --- /dev/null +++ b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-6c54e6.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 535, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-04-185402-6123-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-6c8186.html b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-6c8186.html new file mode 100644 index 00000000..f31491d7 --- /dev/null +++ b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-6c8186.html @@ -0,0 +1,886 @@ + + + +/usr/include/sigc++-2.0/sigc++/visit_each.h + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:usr/include/sigc++-2.0/sigc++/visit_each.h
Warning:line 98, column 64
identical expressions on both sides of logical operator
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-04-185402-6123-1 -x c++ procman.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright 2002, The libsigc++ Development Team
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18#ifndef _SIGC_VISIT_EACH_HPP_
19#define _SIGC_VISIT_EACH_HPP_
20
21#include <sigc++/type_traits.h>
22#include <type_traits>
23
24namespace sigc {
25
26#ifndef DOXYGEN_SHOULD_SKIP_THIS
27namespace internal {
28
29//This should really be an inner class of limit_derived_target, without the T_limit template type,
30//But the SUN CC 5.7 (not earlier versions) compiler finds it ambiguous when we specify a particular specialization of it.
31//and does not seem to allow us to tell it explicitly that it's an inner class.
32template <bool I_derived, class T_type, class T_limit>
33struct with_type;
34
35//Specialization for I_derived = false
36template <class T_type, class T_limit> struct
37with_type<false, T_type, T_limit>
38{
39 static void execute_(const T_type&, const T_limit&) {}
40};
41
42//Specialization for I_derived = true
43template <class T_type, class T_limit>
44struct with_type<true, T_type, T_limit>
45{
46 static void execute_(const T_type& _A_type, const T_limit& _A_action)
47 { _A_action.action_(_A_type); }
48};
49
50
51/// Helper struct for visit_each_type().
52template <class T_target, class T_action>
53struct limit_derived_target
54{
55 typedef limit_derived_target<T_target, T_action> T_self;
56
57 template <class T_type>
58 void operator()(const T_type& _A_type) const
59 {
60 with_type<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
61 }
62
63 limit_derived_target(const T_action& _A_action)
64 : action_(_A_action)
65 {}
66
67 T_action action_;
68};
69
70// Specialization for T_target pointer types, to provide a slightly different execute_() implementation.
71
72template <bool I_derived, class T_type, class T_limit>
73struct with_type_pointer;
74
75//Specialization for I_derived = false
76template <class T_type, class T_limit>
77struct with_type_pointer<false, T_type, T_limit>
78{
79 static void execute_(const T_type&, const T_limit&) {}
80};
81
82//Specialization for I_derived = true
83template <class T_type, class T_limit>
84struct with_type_pointer<true, T_type, T_limit>
85{
86 static void execute_(const T_type& _A_type, const T_limit& _A_action)
87 { _A_action.action_(&_A_type); }
88};
89
90template <class T_target, class T_action>
91struct limit_derived_target<T_target*, T_action>
92{
93 typedef limit_derived_target<T_target*, T_action> T_self;
94
95 template <class T_type>
96 void operator()(const T_type& _A_type) const
97 {
98 with_type_pointer<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
identical expressions on both sides of logical operator
99 }
100
101 limit_derived_target(const T_action& _A_action)
102 : action_(_A_action)
103 {}
104
105 T_action action_;
106};
107
108} /* namespace internal */
109#endif // DOXYGEN_SHOULD_SKIP_THIS
110
111// struct visitor was introduced as a result of https://bugzilla.gnome.org/show_bug.cgi?id=724496
112// The advantage of using specializations of a template struct instead of overloads of
113// a template function is described by Herb Sutter in http://www.gotw.ca/publications/mill17.htm
114// In libsigc++ the main reason for using this technique is that we can avoid using ADL
115// (argument-dependent lookup), and therefore there is no risk that a visit_each() overload
116// in e.g. Boost is selected by mistake.
117
118/** sigc::visitor<T_functor>::do_visit_each() performs a functor on each of the targets of a functor.
119 * All unknown types just call @a _A_action on them.
120 * Add specializations that specialize the @a T_functor argument for your own
121 * functor types, so that subobjects get visited. This is needed to enable
122 * auto-disconnection support for your functor types.
123 *
124 * @par Example:
125 * @code
126 * namespace some_ns
127 * {
128 * struct some_functor
129 * {
130 * void operator()() {}
131 * some_possibly_sigc_trackable_derived_type some_data_member;
132 * some_other_functor_type some_other_functor;
133 * };
134 * }
135 *
136 * namespace sigc
137 * {
138 * template <>
139 * struct visitor<some_ns::some_functor>
140 * {
141 * template <class T_action>
142 * static void do_visit_each(const T_action& _A_action,
143 * const some_ns::some_functor& _A_target)
144 * {
145 * sigc::visit_each(_A_action, _A_target.some_data_member);
146 * sigc::visit_each(_A_action, _A_target.some_other_functor);
147 * }
148 * };
149 * }
150 * @endcode
151 *
152 * @ingroup sigcfunctors
153 */
154template <class T_functor>
155struct visitor
156{
157 template <class T_action>
158 static void do_visit_each(const T_action& _A_action, const T_functor& _A_functor)
159 {
160 _A_action(_A_functor);
161 }
162};
163
164/** This function performs a functor on each of the targets of a functor.
165 *
166 * @ingroup sigcfunctors
167 */
168template <class T_action, class T_functor>
169void visit_each(const T_action& _A_action, const T_functor& _A_functor)
170{ sigc::visitor<T_functor>::do_visit_each(_A_action, _A_functor); }
171
172/** This function performs a functor on each of the targets
173 * of a functor limited to a restricted type.
174 *
175 * @ingroup sigcfunctors
176 */
177template <class T_type, class T_action, class T_functor>
178void visit_each_type(const T_action& _A_action, const T_functor& _A_functor)
179{
180 typedef internal::limit_derived_target<T_type, T_action> type_limited_action;
181
182 type_limited_action limited_action(_A_action);
183
184 //specifying the types of the template specialization prevents disconnection of bound trackable references (such as with std::ref()),
185 //probably because the visit_each<> specializations take various different template types,
186 //in various sequences, and we are probably specifying only a subset of them with this.
187 //
188 //But this is required by the AIX (and maybe IRIX MipsPro and Tru64) compilers.
189 //I guess that std::ref() therefore does not work on those platforms. murrayc
190 // sigc::visit_each<type_limited_action, T_functor>(limited_action, _A_functor);
191
192 //g++ (even slightly old ones) is our primary platform, so we could use the non-crashing version.
193 //However, the explicit version also fixes a crash in a slightly more common case: http://bugzilla.gnome.org/show_bug.cgi?id=169225
194 //Users (and distributors) of libsigc++ on AIX (and maybe IRIX MipsPro and Tru64) do
195 //need to use the version above instead, to allow compilation.
196
197 //Added 2014-03-20: The preceding comment probably does not apply any more,
198 //now when the visit_each<>() overloads have been replaced by visitor<> specializations.
199 //It's probably safe to add explicit template parameters on calls to visit_each(),
200 //visit_each_type() and visitor::do_visit_each(), if necessary.
201
202 sigc::visit_each(limited_action, _A_functor);
203}
204
205} /* namespace sigc */
206#endif
diff --git a/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-77634b.html b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-77634b.html new file mode 100644 index 00000000..42979244 --- /dev/null +++ b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-77634b.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 384, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-04-185402-6123-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-7bbc8c.html b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-7bbc8c.html new file mode 100644 index 00000000..24e0366a --- /dev/null +++ b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-7bbc8c.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 456, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-04-185402-6123-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-7ce786.html b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-7ce786.html new file mode 100644 index 00000000..710e574d --- /dev/null +++ b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-7ce786.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 422, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-04-185402-6123-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-802eaf.html b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-802eaf.html new file mode 100644 index 00000000..c5af799d --- /dev/null +++ b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-802eaf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 13, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-04-185402-6123-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
This statement is never executed
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-8e6c9c.html b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-8e6c9c.html new file mode 100644 index 00000000..6b82683e --- /dev/null +++ b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-8e6c9c.html @@ -0,0 +1,1200 @@ + + + +disks.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/disks.cpp
Warning:line 201, column 13
Value stored to 'res' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name disks.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-04-185402-6123-1 -x c++ disks.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#ifdef __linux__1
4#include <mntent.h>
5#endif // __linux__
6
7#include <giomm.h>
8#include <giomm/themedicon.h>
9#include <gtk/gtk.h>
10#include <glibtop/mountlist.h>
11#include <glibtop/fsusage.h>
12#include <glib/gi18n.h>
13
14#include "procman.h"
15#include "disks.h"
16#include "util.h"
17#include "interface.h"
18#include "iconthemewrapper.h"
19
20namespace
21{
22 const unsigned DISK_ICON_SIZE = 24;
23}
24
25enum DiskColumns
26{
27 /* string columns* */
28 DISK_DEVICE,
29 DISK_DIR,
30 DISK_TYPE,
31 DISK_SUBVOLUME,
32 DISK_TOTAL,
33 DISK_FREE,
34 DISK_AVAIL,
35 /* USED has to be the last column */
36 DISK_USED,
37 // then unvisible columns
38 /* Surface column */
39 DISK_ICON,
40 /* numeric columns */
41 DISK_USED_PERCENTAGE,
42 DISK_N_COLUMNS
43};
44
45
46
47static void
48fsusage_stats(const glibtop_fsusage *buf,
49 guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
50 gint *percentage)
51{
52 guint64 total = buf->blocks * buf->block_size;
53
54 if (!total) {
55 /* not a real device */
56 *btotal = *bfree = *bavail = *bused = 0ULL;
57 *percentage = 0;
58 } else {
59 int percent;
60 *btotal = total;
61 *bfree = buf->bfree * buf->block_size;
62 *bavail = buf->bavail * buf->block_size;
63 *bused = *btotal - *bfree;
64 /* percent = 100.0f * *bused / *btotal; */
65 percent = 100 * *bused / (*bused + *bavail);
66 *percentage = CLAMP(percent, 0, 100)(((percent) > (100)) ? (100) : (((percent) < (0)) ? (0)
: (percent)))
;
67 }
68}
69
70
71namespace
72{
73 string get_icon_for_path(const std::string& path)
74 {
75 using namespace Glib;
76 using namespace Gio;
77
78 // FIXME: I don't know whether i should use Volume or Mount or UnixMount
79 // all i need an icon name.
80 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
81
82 std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
83
84 for (size_t i = 0; i != mounts.size(); ++i) {
85 if (mounts[i]->get_name() != path)
86 continue;
87
88 RefPtr<Icon> icon = mounts[i]->get_icon();
89 RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
90
91 if (themed_icon) {
92 char* name = 0;
93 // FIXME: not wrapped yet
94 g_object_get(G_OBJECT(themed_icon->gobj())((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((themed_icon->gobj())), (((GType) ((20) << (2)))
)))))
, "name", &name, NULL__null);
95 return make_string(name);
96 }
97 }
98
99 return "";
100 }
101}
102
103
104static Glib::RefPtr<Gdk::Pixbuf>
105get_icon_for_device(const char *mountpoint)
106{
107 procman::IconThemeWrapper icon_theme;
108 string icon_name = get_icon_for_path(mountpoint);
109 if (icon_name == "")
110 // FIXME: defaults to a safe value
111 icon_name = "drive-harddisk"; // get_icon_for_path("/");
112 return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
113}
114
115
116static gboolean
117find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
118 GtkTreeIter *result)
119{
120 GtkTreeIter iter;
121 gboolean found = FALSE(0);
122
123 if (gtk_tree_model_get_iter_first(model, &iter)) {
124 do {
125 char *dir;
126
127 gtk_tree_model_get(model, &iter,
128 DISK_DIR, &dir,
129 -1);
130
131 if (dir && !strcmp(dir, mountpoint)) {
132 *result = iter;
133 found = TRUE(!(0));
134 }
135
136 g_free(dir);
137
138 } while (!found && gtk_tree_model_iter_next(model, &iter));
139 }
140
141 return found;
142}
143
144
145
146static void
147remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
148{
149 GtkTreeIter iter;
150
151 if (!gtk_tree_model_get_iter_first(model, &iter))
152 return;
153
154 while (true) {
155 char *dir;
156 guint i;
157 gboolean found = FALSE(0);
158
159 gtk_tree_model_get(model, &iter,
160 DISK_DIR, &dir,
161 -1);
162
163 for (i = 0; i != n; ++i) {
164 if (!strcmp(dir, entries[i].mountdir)) {
165 found = TRUE(!(0));
166 break;
167 }
168 }
169
170 g_free(dir);
171
172 if (!found) {
173 if (!gtk_list_store_remove(GTK_LIST_STORE(model)((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_list_store_get_type ()))))))
, &iter))
174 break;
175 else
176 continue;
177 }
178
179 if (!gtk_tree_model_iter_next(model, &iter))
180 break;
181 }
182}
183
184#ifdef __linux__1
185static char *
186get_mount_opt(const glibtop_mountentry *entry, const char* opt)
187{
188 char *opt_value = NULL__null;
189 const struct mntent *mnt;
190 FILE *fp;
191
192 if (!(fp = setmntent(MOUNTED"/etc/mtab", "r"))) {
193 goto out;
194 }
195
196 while ((mnt = getmntent(fp))) {
197 if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
198 (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
199 char *res;
200
201 res = hasmntopt(mnt, "subvol");
Value stored to 'res' is never read
202 if ((res = hasmntopt(mnt, "subvol")) != NULL__null) {
203 char **strs = g_strsplit_set(res, "=", 2);
204
205 if (g_strv_length(strs) == 2) {
206 char *value = strs[1];
207 if (g_strcmp0 (value,"/root") == 0)
208 opt_value = g_strdup("/")g_strdup_inline ("/");
209 else
210 opt_value = g_strdup(strs[1])g_strdup_inline (strs[1]);
211 g_strfreev(strs);
212 }
213 }
214 break;
215 }
216 }
217
218 endmntent(fp);
219
220 out:
221 return opt_value;
222}
223#endif // __linux__
224
225
226static void
227add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
228{
229 Glib::RefPtr<Gdk::Pixbuf> pixbuf;
230 cairo_surface_t *surface;
231 GtkTreeIter iter;
232 glibtop_fsusage usage;
233 guint64 bused, bfree, bavail, btotal;
234 gint percentage;
235#ifdef __linux__1
236 char *subvol = NULL__null;
237#endif // __linux__
238
239 glibtop_get_fsusage(&usage, entry->mountdir);
240
241 if (not show_all_fs and usage.blocks == 0) {
242 if (find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
243 gtk_list_store_remove(list, &iter);
244 return;
245 }
246
247 fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
248#ifdef __linux__1
249 subvol = get_mount_opt(entry, "subvol");
250#endif // __linux__
251 pixbuf = get_icon_for_device(entry->mountdir);
252 surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL__null);
253
254 /* if we can find a row with the same mountpoint, we get it but we
255 still need to update all the fields.
256 This makes selection persistent.
257 */
258 if (!find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
259 gtk_list_store_append(list, &iter);
260
261 gtk_list_store_set(list, &iter,
262 DISK_ICON, surface,
263 DISK_DEVICE, entry->devname,
264 DISK_DIR, entry->mountdir,
265 DISK_TYPE, entry->type,
266#ifdef __linux__1
267
268 DISK_SUBVOLUME, subvol != NULL__null ? subvol : "",
269#else
270 DISK_SUBVOLUME, "",
271#endif // __linux__
272 DISK_USED_PERCENTAGE, percentage,
273 DISK_TOTAL, btotal,
274 DISK_FREE, bfree,
275 DISK_AVAIL, bavail,
276 DISK_USED, bused,
277 -1);
278#ifdef __linux__1
279 g_free (subvol);
280#endif // __linux__
281}
282
283
284
285int
286cb_update_disks(gpointer data)
287{
288 ProcData *const procdata = static_cast<ProcData*>(data);
289
290 GtkListStore *list;
291 glibtop_mountentry * entries;
292 glibtop_mountlist mountlist;
293 guint i;
294
295 list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)))((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_tree_view_get_model(((((GtkTreeView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((procdata->disk_list)), ((gtk_tree_view_get_type
()))))))))), ((gtk_list_store_get_type ()))))))
;
296
297 entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
298
299 remove_old_disks(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entries, mountlist.number);
300
301 for (i = 0; i < mountlist.number; i++)
302 add_disk(list, &entries[i], procdata->config.show_all_fs);
303
304 g_free(entries);
305
306 return TRUE(!(0));
307}
308
309
310static void
311cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
312{
313 ProcData * const procdata = static_cast<ProcData*>(user_data);
314
315 procman_save_tree_state(procdata->settings,
316 GTK_WIDGET(treeview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_widget_get_type ()))))))
,
317 "disktreenew");
318}
319
320
321static void
322open_dir(GtkTreeView *tree_view,
323 GtkTreePath *path,
324 GtkTreeViewColumn *column,
325 gpointer user_data)
326{
327 GtkTreeIter iter;
328 GtkTreeModel *model;
329 char *dir, *url;
330
331 model = gtk_tree_view_get_model(tree_view);
332
333 if (!gtk_tree_model_get_iter(model, &iter, path)) {
334 char *p;
335 p = gtk_tree_path_to_string(path);
336 g_warning("Cannot get iter for path '%s'\n", p);
337 g_free(p);
338 return;
339 }
340
341 gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
342
343 url = g_strdup_printf("file://%s", dir);
344
345 GError* error = 0;
346 if (!g_app_info_launch_default_for_uri(url, NULL__null, &error)) {
347 g_warning("Cannot open '%s' : %s\n", url, error->message);
348 g_error_free(error);
349 }
350
351 g_free(url);
352 g_free(dir);
353}
354
355static guint timeout_id = 0;
356static GtkTreeViewColumn *current_column;
357
358static gboolean
359save_column_width (gpointer data)
360{
361 gint width;
362 gchar *key;
363 int id;
364 GSettings *settings;
365
366 settings = g_settings_get_child (G_SETTINGS (data)((((GSettings*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((g_settings_get_type ()))))))
, "disktreenew");
367 id = gtk_tree_view_column_get_sort_column_id (current_column);
368 width = gtk_tree_view_column_get_width (current_column);
369
370 key = g_strdup_printf ("col-%d-width", id);
371 g_settings_set_int(settings, key, width);
372 g_free (key);
373
374 if (timeout_id) {
375 g_source_remove (timeout_id);
376 timeout_id = 0;
377 }
378
379 return FALSE(0);
380}
381
382static void
383cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
384{
385 current_column = GTK_TREE_VIEW_COLUMN(widget)((((GtkTreeViewColumn*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((widget)), ((gtk_tree_view_column_get_type (
)))))))
;
386
387 if (timeout_id)
388 g_source_remove (timeout_id);
389
390 timeout_id = g_timeout_add (250, save_column_width, data);
391}
392
393void
394create_disk_view(ProcData *procdata, GtkBuilder *builder)
395{
396 GtkWidget *scrolled;
397 GtkWidget *disk_tree;
398 GtkListStore *model;
399 GtkTreeViewColumn *col;
400 GtkCellRenderer *cell;
401 guint i;
402
403 const gchar * const titles[] = {
404 N_("Device")("Device"),
405 N_("Directory")("Directory"),
406 N_("Type")("Type"),
407 N_("SubVolume")("SubVolume"),
408 N_("Total")("Total"),
409 N_("Free")("Free"),
410 N_("Available")("Available"),
411 N_("Used")("Used")
412 };
413
414 scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "disks_scrolled"))), ((
gtk_widget_get_type ()))))))
;
415
416 model = gtk_list_store_new(DISK_N_COLUMNS, /* n columns */
417 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DEVICE */
418 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DIR */
419 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_TYPE */
420 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_SUBVOLUME */
421 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_TOTAL */
422 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_FREE */
423 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_AVAIL */
424 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_USED */
425 CAIRO_GOBJECT_TYPE_SURFACEcairo_gobject_surface_get_type (), /* DISK_ICON */
426 G_TYPE_INT((GType) ((6) << (2)))); /* DISK_USED_PERCENTAGE */
427
428 disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_model_get_type ()))))))
);
429 g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("row-activated"), (((GCallback) (open_dir))), (__null
), __null, (GConnectFlags) 0)
;
430 procdata->disk_list = disk_tree;
431 gtk_container_add(GTK_CONTAINER(scrolled)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((scrolled)), ((gtk_container_get_type ()))))))
, disk_tree);
432 g_object_unref(G_OBJECT(model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
);
433
434 /* icon + device */
435
436 col = gtk_tree_view_column_new();
437 cell = gtk_cell_renderer_pixbuf_new();
438 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
439 gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
440 NULL__null);
441
442 cell = gtk_cell_renderer_text_new();
443 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
444 gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
445 NULL__null);
446 gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE])gettext (titles[DISK_DEVICE]));
447 gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
448 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
449 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
450 gtk_tree_view_column_set_min_width (col, 30);
451 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
452 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
453 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
454
455 /* sizes - used */
456
457 for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
458 cell = gtk_cell_renderer_text_new();
459 col = gtk_tree_view_column_new();
460 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
461 gtk_tree_view_column_set_title(col, _(titles[i])gettext (titles[i]));
462 gtk_tree_view_column_set_sort_column_id(col, i);
463 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
464 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
465 gtk_tree_view_column_set_min_width (col, 30);
466 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
467 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
468 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
469
470 switch (i) {
471 case DISK_TOTAL:
472 case DISK_FREE:
473 case DISK_AVAIL:
474 g_object_set(cell, "xalign", 1.0f, NULL__null);
475 gtk_tree_view_column_set_cell_data_func(col, cell,
476 &procman::storage_size_cell_data_func,
477 GUINT_TO_POINTER(i)((gpointer) (gulong) (i)),
478 NULL__null);
479 break;
480
481 default:
482 gtk_tree_view_column_set_attributes(col, cell,
483 "text", i,
484 NULL__null);
485 break;
486 }
487 }
488
489 /* used + percentage */
490
491 col = gtk_tree_view_column_new();
492 cell = gtk_cell_renderer_text_new();
493 g_object_set(cell, "xalign", 1.0f, NULL__null);
494 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
495 gtk_tree_view_column_set_cell_data_func(col, cell,
496 &procman::storage_size_cell_data_func,
497 GUINT_TO_POINTER(DISK_USED)((gpointer) (gulong) (DISK_USED)),
498 NULL__null);
499
500 cell = gtk_cell_renderer_progress_new();
501 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
502 gtk_tree_view_column_set_attributes(col, cell, "value",
503 DISK_USED_PERCENTAGE, NULL__null);
504 gtk_tree_view_column_set_title(col, _(titles[DISK_USED])gettext (titles[DISK_USED]));
505 gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
506 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
507 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
508 gtk_tree_view_column_set_min_width (col, 150);
509 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
510 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
511 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
512
513 /* numeric sort */
514
515 procman_get_tree_state(procdata->settings, disk_tree,
516 "disktreenew");
517
518 g_signal_connect (G_OBJECT(disk_tree), "columns-changed",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
519 G_CALLBACK(cb_disk_columns_changed), procdata)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
;
520}
diff --git a/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-c673b5.html b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-c673b5.html new file mode 100644 index 00000000..4505fcb5 --- /dev/null +++ b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-c673b5.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 564, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-04-185402-6123-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-d507c5.html b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-d507c5.html new file mode 100644 index 00000000..a68a82ab --- /dev/null +++ b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-d507c5.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 151, column 9
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-04-185402-6123-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
This statement is never executed
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-e8ff80.html b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-e8ff80.html new file mode 100644 index 00000000..ad580a3f --- /dev/null +++ b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/report-e8ff80.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 350, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-04-185402-6123-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-04-185402-6123-1@d0fc4b9c7899_master/scanview.css b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/scanview.css new file mode 100644 index 00000000..cf8a5a6a --- /dev/null +++ b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/2023-09-04-185402-6123-1@d0fc4b9c7899_master/sorttable.js b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/sorttable.js new file mode 100644 index 00000000..32faa078 --- /dev/null +++ b/2023-09-04-185402-6123-1@d0fc4b9c7899_master/sorttable.js @@ -0,0 +1,492 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse',''); + cell.className = cell.className.replace('sorttable_sorted',''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j=0; j 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } + else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } + else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i=0; i=0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a,b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); + if (isNaN(bb)) bb = 0; + return aa-bb; + }, + sort_alpha: function(a,b) { + if (a[0]==b[0]) return 0; + if (a[0] 0 ) { + var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for(var i = t; i > b; --i) { + if ( comp_func(list[i], list[i-1]) < 0 ) { + var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write(" + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef _PROCMAN_PROCMAN_H_
+#define _PROCMAN_PROCMAN_H_
+
+#include <glibmm/refptr.h>
+#include <cairo-gobject.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+#include <glibtop/cpu.h>
+
+#include <time.h>
+#include <sys/types.h>
+
+#include <map>
+#include <string>
+
+struct ProcInfo;
+struct ProcData;
+struct LoadGraph;
+
+#include "smooth_refresh.h"
+#include "prettytable.h"
+
+#define GSM_GSETTINGS_SCHEMA "org.mate.system-monitor"
+
+enum
+{
+    ALL_PROCESSES,
+    MY_PROCESSES,
+    ACTIVE_PROCESSES
+};
+
+enum
+{
+    VERY_HIGH_PRIORITY,
+    HIGH_PRIORITY,
+    NORMAL_PRIORITY,
+    LOW_PRIORITY,
+    VERY_LOW_PRIORITY,
+    CUSTOM_PRIORITY
+};
+
+static const unsigned MIN_UPDATE_INTERVAL =   1 * 1000;
+static const unsigned MAX_UPDATE_INTERVAL = 100 * 1000;
+
+enum ProcmanTab
+{
+    PROCMAN_TAB_SYSINFO,
+    PROCMAN_TAB_PROCESSES,
+    PROCMAN_TAB_RESOURCES,
+    PROCMAN_TAB_DISKS
+};
+
+struct ProcConfig
+{
+    gint        width;
+    gint        height;
+    gint        xpos;
+    gint        ypos;
+    gboolean    maximized;
+    gboolean    show_kill_warning;
+    gboolean    show_tree;
+    gboolean    show_all_fs;
+    int         update_interval;
+    int         graph_update_interval;
+    int         disks_update_interval;
+    gint        whose_process;
+    gint        current_tab;
+    GdkRGBA     cpu_color[GLIBTOP_NCPU];
+    GdkRGBA     mem_color;
+    GdkRGBA     swap_color;
+    GdkRGBA     net_in_color;
+    GdkRGBA     net_out_color;
+    GdkRGBA     bg_color;
+    GdkRGBA     frame_color;
+    gint        num_cpus;
+    bool solaris_mode;
+    bool network_in_bits;
+};
+
+struct MutableProcInfo
+{
+MutableProcInfo()<--- Member variable 'MutableProcInfo::cgroup_name' is not initialized in the constructor.<--- Member variable 'MutableProcInfo::unit' is not initialized in the constructor.<--- Member variable 'MutableProcInfo::session' is not initialized in the constructor.<--- Member variable 'MutableProcInfo::seat' is not initialized in the constructor.
+  : disk_write_bytes_current(0ULL),
+    disk_read_bytes_current(0ULL),
+    disk_write_bytes_total(0ULL),
+    disk_read_bytes_total(0ULL),
+    status(0U)
+    { }
+
+    std::string user;
+
+    gchar wchan[40];
+
+    // all these members are filled with libgtop which uses
+    // guint64 (to have fixed size data) but we don't need more
+    // than an unsigned long (even for 32bit apps on a 64bit
+    // kernel) as these data are amounts, not offsets.
+    gulong vmsize;
+    gulong memres;
+    gulong memshared;
+    gulong memwritable;
+    gulong mem;
+
+#ifdef HAVE_WNCK
+    // wnck gives an unsigned long
+    gulong memxserver;
+#endif
+
+    gulong start_time;
+    guint64 cpu_time;
+    guint64 disk_write_bytes_current;
+    guint64 disk_read_bytes_current;
+    guint64 disk_write_bytes_total;
+    guint64 disk_read_bytes_total;
+    guint status;
+    guint pcpu;
+    gint nice;
+    gchar *cgroup_name;
+
+    gchar *unit;
+    gchar *session;
+    gchar *seat;
+
+    std::string owner;
+};
+
+class ProcInfo
+: public MutableProcInfo
+{
+    /* undefined */ ProcInfo& operator=(const ProcInfo&);
+    /* undefined */ ProcInfo(const ProcInfo&);
+
+    typedef std::map<guint, std::string> UserMap;
+    /* cached username */
+    static UserMap users;
+
+  public:
+
+    // TODO: use a set instead
+    // sorted by pid. The map has a nice property : it is sorted
+    // by pid so this helps a lot when looking for the parent node
+    // as ppid is nearly always < pid.
+    typedef std::map<pid_t, ProcInfo*> List;
+    typedef List::iterator Iterator;
+
+    static List all;
+
+    static ProcInfo* find(pid_t pid);
+    static Iterator begin() { return ProcInfo::all.begin(); }
+    static Iterator end() { return ProcInfo::all.end(); }
+
+    ProcInfo(pid_t pid);
+    ~ProcInfo();
+    // adds one more ref to icon
+    void set_icon(Glib::RefPtr<Gdk::Pixbuf> icon);
+    void set_user(guint uid);
+    std::string lookup_user(guint uid);
+
+    GtkTreeIter      node;
+    cairo_surface_t *surface;
+    gchar           *tooltip;
+    gchar           *name;
+    gchar           *arguments;
+    gchar           *security_context;
+
+    const pid_t      pid;
+    pid_t            ppid;
+    guint            uid;
+
+// private:
+    // tracks cpu time per process keeps growing because if a
+    // ProcInfo is deleted this does not mean that the process is
+    // not going to be recreated on the next update.  For example,
+    // if dependencies + (My or Active), the proclist is cleared
+    // on each update.  This is a workaround
+    static std::map<pid_t, guint64> cpu_times;
+};
+
+struct ProcData
+{
+    // lazy initialization
+    static ProcData* get_instance();
+
+    GtkUIManager    *uimanager;
+    GtkActionGroup    *action_group;
+    GtkWidget    *statusbar;
+    gint        tip_message_cid;
+    GtkWidget    *tree;
+    GtkWidget    *loadavg;
+    GtkWidget    *endprocessbutton;
+    GtkWidget    *popup_menu;
+    GtkWidget    *disk_list;
+    GtkWidget    *notebook;
+    ProcConfig    config;
+    LoadGraph    *cpu_graph;
+    LoadGraph    *mem_graph;
+    LoadGraph    *net_graph;
+    gint        cpu_label_fixed_width;
+    gint        net_label_fixed_width;
+    ProcInfo    *selected_process;
+    GtkTreeSelection *selection;
+    guint        timeout;
+    guint        disk_timeout;
+
+    PrettyTable    pretty_table;
+
+    GSettings       *settings;
+    GtkWidget        *app;
+    GtkUIManager    *menu;
+
+    unsigned    frequency;
+
+    SmoothRefresh  *smooth_refresh;
+
+    guint64 cpu_total_time;
+    guint64 cpu_total_time_last;
+
+    gboolean terminating;
+
+private:
+    ProcData();
+    /* undefined */ ProcData(const ProcData &);
+    /* undefined */ ProcData& operator=(const ProcData &);
+};
+
+void        procman_save_config (ProcData *data);
+void        procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+gboolean    procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+
+struct ReniceArgs
+{
+    ProcData *procdata;
+    int nice_value;
+};
+
+struct KillArgs
+{
+    ProcData *procdata;
+    int signal;
+};
+
+#endif /* _PROCMAN_PROCMAN_H_ */
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/1.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/1.html new file mode 100644 index 00000000..b83a4070 --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/1.html @@ -0,0 +1,435 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
#ifndef _PROCMAN_SMOOTH_REFRESH
+#define _PROCMAN_SMOOTH_REFRESH
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <string>
+
+using std::string;
+
+class SmoothRefresh
+{
+  public:
+
+    /*
+      smooth_refresh_new
+
+      @config_interval : pointer to config_interval so we can observe
+      config_interval changes.
+
+      @return : initialized SmoothRefresh
+    */
+    SmoothRefresh(GSettings *a_settings);
+
+    ~SmoothRefresh();
+
+    /*
+      smooth_refresh_reset
+
+      Resets state and re-read config_interval
+    */
+    void reset();
+
+    /*
+      smooth_refresh_get
+
+      Computes the new refresh_interval so that CPU usage is lower than
+      SMOOTH_REFRESH_PCPU.
+
+      @new_interval : where the new refresh_interval is stored.
+
+      @return : TRUE is refresh_interval has changed. The new refresh_interval
+      is stored in @new_interval. Else FALSE;
+    */
+    bool get(guint &new_interval);
+
+    static const string KEY;
+    static const bool KEY_DEFAULT_VALUE;
+
+  private:
+
+    unsigned get_own_cpu_usage();
+
+    static void status_changed(GSettings *settings,
+                               const gchar *key,
+                               gpointer user_data);
+
+    void load_settings_value(const gchar *key);
+
+    /*
+      fuzzy logic:
+      - decrease refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_LO
+      - increase refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_HI
+
+    */
+
+    enum
+    {
+        PCPU_HI = 22,
+        PCPU_LO = 18
+    };
+
+    /*
+      -self : procman's PID (so we call getpid() only once)
+
+      -interval : current refresh interval
+
+      -config_interval : pointer to the configuration refresh interval.
+      Used to watch configuration changes
+
+      -interval >= -config_interval
+
+      -last_pcpu : to avoid spikes, the last CPU%. See PCPU_{LO,HI}
+
+      -last_total_time:
+      -last_cpu_time: Save last cpu and process times to compute CPU%
+    */
+
+    GSettings *settings;
+    bool active;
+    guint connection;
+    guint interval;
+    unsigned  last_pcpu;
+    guint64 last_total_time;
+    guint64 last_cpu_time;
+};
+
+#endif /* _PROCMAN_SMOOTH_REFRESH */
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/10.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/10.html new file mode 100644 index 00000000..cb5e0f54 --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/10.html @@ -0,0 +1,1067 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
#include <gio/gio.h>
+
+#if defined (__ELF__) && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
+# define SECTION __attribute__ ((section (".gresource.msm"), aligned (8)))
+#else
+# define SECTION
+#endif
+
+static const SECTION union { const guint8 data[3353]; const double alignment; void * const ptr;}  msm_resource_data = { {<--- union member 'Anonymous0::alignment' is never used.<--- union member 'Anonymous0::ptr' is never used.
+  0107, 0126, 0141, 0162, 0151, 0141, 0156, 0164, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0030, 0000, 0000, 0000, 0310, 0000, 0000, 0000, 0000, 0000, 0000, 0050, 0006, 0000, 0000, 0000, 
+  0000, 0000, 0000, 0000, 0001, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0005, 0000, 0000, 0000, 0376, 0236, 0033, 0101, 0005, 0000, 0000, 0000, 
+  0310, 0000, 0000, 0000, 0024, 0000, 0114, 0000, 0334, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 
+  0113, 0120, 0220, 0013, 0002, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 0004, 0000, 0114, 0000, 
+  0350, 0000, 0000, 0000, 0354, 0000, 0000, 0000, 0324, 0265, 0002, 0000, 0377, 0377, 0377, 0377, 
+  0354, 0000, 0000, 0000, 0001, 0000, 0114, 0000, 0360, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 
+  0173, 0250, 0316, 0037, 0000, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 0014, 0000, 0166, 0000, 
+  0000, 0001, 0000, 0000, 0034, 0006, 0000, 0000, 0234, 0164, 0275, 0021, 0000, 0000, 0000, 0000, 
+  0034, 0006, 0000, 0000, 0016, 0000, 0166, 0000, 0060, 0006, 0000, 0000, 0017, 0015, 0000, 0000, 
+  0201, 0321, 0040, 0031, 0001, 0000, 0000, 0000, 0017, 0015, 0000, 0000, 0005, 0000, 0114, 0000, 
+  0024, 0015, 0000, 0000, 0030, 0015, 0000, 0000, 0155, 0141, 0164, 0145, 0055, 0163, 0171, 0163, 
+  0164, 0145, 0155, 0055, 0155, 0157, 0156, 0151, 0164, 0157, 0162, 0057, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0157, 0162, 0147, 0057, 0005, 0000, 0000, 0000, 0057, 0000, 0000, 0000, 
+  0001, 0000, 0000, 0000, 0151, 0156, 0164, 0145, 0162, 0146, 0141, 0143, 0145, 0056, 0165, 0151, 
+  0242, 0073, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0133, 0133, 0163, 0352, 0066, 
+  0020, 0176, 0317, 0257, 0160, 0375, 0332, 0161, 0010, 0227, 0320, 0164, 0006, 0070, 0323, 0166, 
+  0232, 0364, 0241, 0347, 0114, 0046, 0344, 0114, 0037, 0031, 0331, 0136, 0260, 0212, 0054, 0271, 
+  0222, 0314, 0345, 0337, 0237, 0065, 0066, 0004, 0002, 0370, 0102, 0210, 0061, 0224, 0067, 0154, 
+  0257, 0054, 0355, 0267, 0253, 0335, 0317, 0253, 0245, 0363, 0145, 0346, 0063, 0143, 0002, 0122, 
+  0121, 0301, 0273, 0146, 0375, 0366, 0316, 0064, 0200, 0073, 0302, 0245, 0174, 0324, 0065, 0277, 
+  0277, 0076, 0132, 0017, 0346, 0227, 0336, 0115, 0347, 0047, 0313, 0062, 0236, 0200, 0203, 0044, 
+  0032, 0134, 0143, 0112, 0265, 0147, 0214, 0030, 0161, 0301, 0150, 0336, 0066, 0037, 0156, 0033, 
+  0206, 0145, 0241, 0020, 0345, 0032, 0344, 0220, 0070, 0320, 0353, 0110, 0370, 0057, 0244, 0022, 
+  0224, 0301, 0250, 0335, 0065, 0107, 0172, 0374, 0263, 0371, 0066, 0113, 0363, 0266, 0321, 0062, 
+  0153, 0275, 0216, 0260, 0377, 0005, 0107, 0033, 0016, 0043, 0112, 0165, 0315, 0047, 0075, 0376, 
+  0207, 0162, 0127, 0114, 0115, 0203, 0272, 0135, 0323, 0047, 0224, 0017, 0246, 0361, 0215, 0136, 
+  0047, 0220, 0042, 0000, 0251, 0347, 0006, 0047, 0076, 0164, 0115, 0207, 0160, 0153, 0050, 0234, 
+  0120, 0231, 0275, 0107, 0302, 0024, 0164, 0152, 0113, 0201, 0055, 0121, 0115, 0065, 0003, 0323, 
+  0320, 0222, 0160, 0305, 0210, 0046, 0066, 0303, 0233, 0163, 0300, 0221, 0375, 0271, 0322, 0340, 
+  0033, 0137, 0005, 0247, 0132, 0310, 0224, 0127, 0270, 0060, 0044, 0041, 0323, 0326, 0224, 0272, 
+  0332, 0063, 0173, 0255, 0326, 0135, 0016, 0141, 0017, 0350, 0310, 0323, 0050, 0375, 0353, 0375, 
+  0272, 0264, 0343, 0121, 0346, 0356, 0120, 0375, 0167, 0061, 0133, 0323, 0333, 0306, 0253, 0255, 
+  0067, 0117, 0250, 0242, 0270, 0172, 0263, 0367, 0052, 0303, 0064, 0215, 0013, 0200, 0043, 0044, 
+  0005, 0256, 0211, 0106, 0263, 0230, 0075, 0264, 0217, 0246, 0016, 0141, 0073, 0226, 0033, 0060, 
+  0264, 0252, 0047, 0230, 0013, 0022, 0355, 0126, 0113, 0356, 0356, 0323, 0345, 0233, 0320, 0140, 
+  0013, 0061, 0216, 0025, 0342, 0313, 0253, 0143, 0050, 0224, 0041, 0351, 0023, 0071, 0242, 0334, 
+  0122, 0232, 0110, 0204, 0276, 0336, 0310, 0026, 0005, 0356, 0346, 0023, 0324, 0042, 0170, 0057, 
+  0230, 0151, 0113, 0065, 0127, 0224, 0017, 0105, 0151, 0346, 0364, 0140, 0026, 0220, 0110, 0241, 
+  0214, 0127, 0116, 0162, 0312, 0331, 0102, 0242, 0305, 0227, 0176, 0237, 0212, 0222, 0012, 0210, 
+  0203, 0061, 0143, 0017, 0104, 0251, 0376, 0263, 0373, 0141, 0055, 0206, 0365, 0235, 0264, 0241, 
+  0347, 0101, 0264, 0251, 0211, 0155, 0356, 0000, 0376, 0157, 0142, 0003, 0333, 0204, 0236, 0055, 
+  0156, 0225, 0001, 0176, 0074, 0323, 0376, 0100, 0263, 0076, 0164, 0245, 0034, 0242, 0066, 0106, 
+  0330, 0266, 0243, 0026, 0261, 0255, 0041, 0145, 0154, 0307, 0264, 0265, 0325, 0230, 0254, 0175, 
+  0270, 0362, 0103, 0034, 0354, 0374, 0037, 0234, 0060, 0063, 0234, 0355, 0165, 0332, 0207, 0074, 
+  0373, 0172, 0315, 0275, 0230, 0040, 0356, 0200, 0114, 0106, 0045, 0372, 0227, 0107, 0030, 0035, 
+  0241, 0136, 0213, 0340, 0126, 0310, 0231, 0226, 0100, 0147, 0315, 0020, 0073, 0134, 0306, 0212, 
+  0003, 0241, 0150, 0014, 0360, 0335, 0141, 0136, 0331, 0167, 0244, 0140, 0014, 0334, 0365, 0144, 
+  0037, 0071, 0050, 0050, 0005, 0152, 0240, 0222, 0247, 0145, 0144, 0213, 0143, 0173, 0252, 0362, 
+  0010, 0152, 0144, 0105, 0041, 0312, 0354, 0121, 0236, 0073, 0016, 0236, 0312, 0200, 0365, 0003, 
+  0303, 0112, 0250, 0065, 0016, 0137, 0030, 0016, 0323, 0147, 0142, 0073, 0073, 0276, 0133, 0040, 
+  0054, 0376, 0311, 0135, 0143, 0360, 0034, 0217, 0116, 0131, 0157, 0250, 0300, 0042, 0116, 0264, 
+  0142, 0213, 0004, 0001, 0020, 0174, 0221, 0003, 0331, 0130, 0034, 0337, 0135, 0044, 0070, 0100, 
+  0047, 0240, 0254, 0204, 0342, 0145, 0373, 0127, 0262, 0143, 0021, 0244, 0014, 0375, 0102, 0216, 
+  0036, 0301, 0050, 0337, 0261, 0334, 0123, 0071, 0107, 0043, 0335, 0071, 0062, 0227, 0125, 0314, 
+  0315, 0162, 0347, 0365, 0105, 0052, 0253, 0102, 0122, 0177, 0136, 0206, 0254, 0102, 0306, 0332, 
+  0203, 0312, 0247, 0146, 0177, 0374, 0014, 0273, 0046, 0377, 0242, 0214, 0165, 0077, 0234, 0116, 
+  0020, 0126, 0347, 0373, 0154, 0257, 0116, 0167, 0005, 0011, 0115, 0244, 0125, 0025, 0266, 0325, 
+  0037, 0317, 0337, 0215, 0277, 0250, 0302, 0017, 0362, 0171, 0312, 0370, 0131, 0022, 0131, 0067, 
+  0264, 0044, 0132, 0113, 0212, 0151, 0010, 0324, 0332, 0357, 0144, 0300, 0064, 0376, 0032, 0067, 
+  0046, 0204, 0205, 0013, 0267, 0142, 0156, 0124, 0201, 0250, 0255, 0217, 0071, 0063, 0036, 0265, 
+  0341, 0220, 0043, 0111, 0002, 0357, 0154, 0167, 0371, 0301, 0156, 0336, 0376, 0160, 0255, 0342, 
+  0221, 0211, 0351, 0006, 0222, 0103, 0274, 0121, 0032, 0220, 0223, 0175, 0234, 0076, 0265, 0256, 
+  0161, 0377, 0113, 0332, 0354, 0202, 0205, 0076, 0212, 0056, 0041, 0112, 0013, 0231, 0022, 0331, 
+  0152, 0056, 0101, 0037, 0047, 0137, 0040, 0050, 0201, 0133, 0370, 0300, 0212, 0271, 0112, 0063, 
+  0165, 0311, 0263, 0135, 0103, 0322, 0213, 0010, 0300, 0040, 0146, 0172, 0276, 0160, 0121, 0230, 
+  0013, 0176, 0112, 0056, 0204, 0223, 0044, 0144, 0076, 0235, 0301, 0345, 0246, 0072, 0025, 0045, 
+  0372, 0347, 0032, 0370, 0174, 0360, 0057, 0060, 0023, 0107, 0132, 0125, 0041, 0023, 0177, 0005, 
+  0037, 0223, 0260, 0201, 0206, 0067, 0372, 0123, 0022, 0134, 0263, 0162, 0161, 0347, 0274, 0146, 
+  0345, 0174, 0131, 0071, 0072, 0135, 0302, 0004, 0263, 0310, 0134, 0252, 0333, 0302, 0337, 0230, 
+  0231, 0124, 0167, 0161, 0254, 0264, 0015, 0361, 0223, 0244, 0356, 0033, 0306, 0013, 0227, 0055, 
+  0005, 0337, 0002, 0111, 0070, 0257, 0051, 0066, 0022, 0160, 0273, 0100, 0126, 0157, 0147, 0274, 
+  0324, 0023, 0276, 0030, 0001, 0007, 0261, 0253, 0256, 0221, 0043, 0010, 0051, 0334, 0361, 0145, 
+  0326, 0066, 0163, 0342, 0225, 0122, 0143, 0307, 0005, 0027, 0015, 0115, 0231, 0241, 0205, 0301, 
+  0120, 0133, 0030, 0214, 0210, 0343, 0245, 0223, 0035, 0055, 0202, 0225, 0334, 0201, 0201, 0143, 
+  0063, 0003, 0140, 0240, 0075, 0053, 0370, 0343, 0144, 0361, 0271, 0006, 0250, 0037, 0325, 0000, 
+  0007, 0034, 0111, 0235, 0342, 0341, 0225, 0362, 0136, 0024, 0345, 0255, 0177, 0220, 0125, 0160, 
+  0320, 0027, 0110, 0171, 0043, 0255, 0252, 0100, 0171, 0277, 0201, 0236, 0012, 0071, 0276, 0122, 
+  0335, 0342, 0116, 0171, 0245, 0272, 0173, 0330, 0154, 0073, 0067, 0233, 0215, 0140, 0074, 0031, 
+  0233, 0155, 0345, 0154, 0225, 0151, 0076, 0134, 0062, 0355, 0215, 0217, 0370, 0160, 0252, 0263, 
+  0042, 0137, 0057, 0313, 0125, 0237, 0023, 0377, 0112, 0063, 0203, 0026, 0232, 0260, 0101, 0162, 
+  0336, 0352, 0236, 0225, 0055, 0136, 0243, 0245, 0033, 0057, 0311, 0322, 0253, 0141, 0220, 0372, 
+  0207, 0015, 0242, 0160, 0357, 0237, 0333, 0256, 0350, 0143, 0104, 0377, 0134, 0374, 0357, 0113, 
+  0336, 0020, 0150, 0005, 0175, 0206, 0233, 0241, 0072, 0206, 0070, 0302, 0106, 0300, 0101, 0040, 
+  0267, 0341, 0137, 0034, 0120, 0133, 0121, 0327, 0063, 0050, 0235, 0221, 0045, 0077, 0215, 0322, 
+  0366, 0156, 0112, 0256, 0156, 0154, 0071, 0114, 0334, 0362, 0334, 0070, 0014, 0346, 0337, 0042, 
+  0077, 0360, 0321, 0131, 0336, 0347, 0342, 0200, 0072, 0143, 0220, 0003, 0262, 0172, 0136, 0006, 
+  0244, 0233, 0235, 0007, 0355, 0343, 0065, 0163, 0155, 0300, 0176, 0127, 0071, 0330, 0227, 0241, 
+  0376, 0202, 0101, 0157, 0225, 0016, 0372, 0045, 0026, 0176, 0076, 0122, 0146, 0313, 0255, 0134, 
+  0306, 0262, 0057, 0243, 0050, 0164, 0274, 0126, 0273, 0306, 0061, 0133, 0355, 0242, 0276, 0261, 
+  0052, 0124, 0145, 0136, 0100, 0211, 0120, 0072, 0007, 0167, 0332, 0065, 0112, 0353, 0264, 0033, 
+  0226, 0327, 0150, 0127, 0106, 0143, 0134, 0073, 0317, 0327, 0363, 0256, 0166, 0156, 0227, 0252, 
+  0361, 0265, 0225, 0273, 0102, 0045, 0274, 0002, 0273, 0245, 0171, 0314, 0020, 0062, 0254, 0106, 
+  0004, 0171, 0244, 0014, 0214, 0370, 0137, 0070, 0207, 0006, 0221, 0346, 0261, 0202, 0310, 0231, 
+  0235, 0074, 0364, 0061, 0160, 0204, 0312, 0046, 0062, 0141, 0207, 0253, 0313, 0112, 0237, 0100, 
+  0064, 0076, 0261, 0153, 0054, 0113, 0252, 0170, 0136, 0337, 0276, 0361, 0366, 0117, 0332, 0233, 
+  0037, 0325, 0360, 0311, 0023, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0160, 0162, 0145, 0146, 
+  0145, 0162, 0145, 0156, 0143, 0145, 0163, 0056, 0165, 0151, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0065, 0123, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0134, 0335, 0162, 0342, 0066, 
+  0024, 0276, 0357, 0123, 0250, 0276, 0355, 0050, 0004, 0262, 0155, 0167, 0072, 0301, 0073, 0335, 
+  0335, 0046, 0335, 0231, 0266, 0263, 0323, 0354, 0266, 0227, 0036, 0331, 0076, 0140, 0155, 0204, 
+  0344, 0112, 0002, 0102, 0257, 0372, 0054, 0175, 0264, 0076, 0111, 0217, 0177, 0010, 0140, 0300, 
+  0066, 0004, 0210, 0041, 0334, 0331, 0346, 0110, 0072, 0072, 0377, 0237, 0216, 0206, 0353, 0067, 
+  0017, 0003, 0101, 0106, 0240, 0015, 0127, 0262, 0353, 0264, 0057, 0056, 0035, 0002, 0062, 0120, 
+  0041, 0227, 0375, 0256, 0363, 0371, 0323, 0015, 0175, 0355, 0274, 0161, 0277, 0272, 0376, 0232, 
+  0122, 0162, 0013, 0022, 0064, 0263, 0020, 0222, 0061, 0267, 0021, 0351, 0013, 0026, 0002, 0271, 
+  0272, 0270, 0172, 0175, 0321, 0041, 0224, 0042, 0021, 0227, 0026, 0164, 0217, 0005, 0340, 0136, 
+  0153, 0370, 0153, 0310, 0065, 0030, 0042, 0270, 0337, 0165, 0372, 0366, 0376, 0033, 0147, 0266, 
+  0312, 0325, 0105, 0347, 0225, 0323, 0162, 0257, 0225, 0377, 0005, 0002, 0113, 0002, 0301, 0214, 
+  0351, 0072, 0267, 0366, 0376, 0303, 0200, 0365, 0301, 0041, 0074, 0354, 0072, 0074, 0171, 0154, 
+  0073, 0356, 0165, 0254, 0125, 0014, 0332, 0116, 0210, 0144, 0003, 0350, 0072, 0043, 0156, 0270, 
+  0057, 0300, 0161, 0077, 0351, 0041, 0134, 0267, 0246, 0277, 0056, 0321, 0005, 0114, 0322, 0236, 
+  0012, 0206, 0306, 0161, 0157, 0230, 0060, 0145, 0244, 0074, 0120, 0222, 0046, 0217, 0216, 0073, 
+  0346, 0062, 0124, 0143, 0032, 0010, 0265, 0070, 0242, 0225, 0261, 0132, 0203, 0345, 0316, 0241, 
+  0131, 0216, 0100, 0304, 0324, 0327, 0152, 0154, 0100, 0327, 0143, 0371, 0075, 0147, 0102, 0365, 
+  0063, 0236, 0143, 0015, 0075, 0320, 0250, 0161, 0060, 0136, 0230, 0175, 0177, 0012, 0137, 0276, 
+  0322, 0041, 0150, 0072, 0346, 0241, 0215, 0034, 0367, 0333, 0022, 0112, 0313, 0055, 0212, 0204, 
+  0130, 0315, 0244, 0021, 0314, 0062, 0024, 0120, 0327, 0231, 0000, 0256, 0161, 0067, 0061, 0026, 
+  0006, 0344, 0127, 0045, 0271, 0125, 0232, 0174, 0234, 0161, 0130, 0062, 0135, 0010, 0075, 0066, 
+  0024, 0166, 0272, 0362, 0253, 0313, 0313, 0032, 0304, 0021, 0360, 0176, 0144, 0221, 0272, 0123, 
+  0116, 0155, 0254, 0126, 0023, 0232, 0030, 0075, 0215, 0031, 0262, 0142, 0053, 0125, 0151, 0047, 
+  0061, 0320, 0210, 0047, 0224, 0231, 0124, 0347, 0151, 0203, 0210, 0213, 0220, 0244, 0316, 0042, 
+  0231, 0240, 0351, 0053, 0132, 0211, 0257, 0036, 0234, 0025, 0332, 0172, 0213, 0237, 0123, 0125, 
+  0145, 0023, 0171, 0202, 0115, 0324, 0320, 0076, 0111, 0113, 0003, 0246, 0373, 0134, 0122, 0253, 
+  0342, 0162, 0035, 0345, 0164, 0276, 0262, 0126, 0015, 0312, 0111, 0225, 0346, 0050, 0027, 0146, 
+  0321, 0277, 0035, 0027, 0035, 0335, 0362, 0200, 0211, 0022, 0172, 0023, 0263, 0000, 0103, 0214, 
+  0343, 0166, 0252, 0045, 0303, 0202, 0144, 0132, 0017, 0045, 0317, 0126, 0012, 0150, 0210, 0354, 
+  0311, 0242, 0230, 0026, 0007, 0155, 0040, 0253, 0164, 0321, 0265, 0313, 0144, 0153, 0044, 0076, 
+  0347, 0371, 0331, 0207, 0245, 0311, 0005, 0363, 0101, 0070, 0356, 0317, 0110, 0123, 0042, 0200, 
+  0241, 0001, 0232, 0361, 0110, 0131, 0034, 0003, 0103, 0077, 0010, 0240, 0132, 0165, 0133, 0304, 
+  0222, 0012, 0112, 0015, 0001, 0360, 0021, 0030, 0232, 0173, 0105, 0345, 0200, 0064, 0314, 0071, 
+  0156, 0026, 0355, 0126, 0106, 0034, 0324, 0355, 0075, 0052, 0167, 0151, 0044, 0074, 0304, 0114, 
+  0206, 0325, 0233, 0354, 0161, 0041, 0052, 0331, 0210, 0225, 0341, 0231, 0271, 0055, 0070, 0157, 
+  0353, 0161, 0361, 0126, 0256, 0311, 0072, 0012, 0115, 0003, 0176, 0225, 0106, 0337, 0025, 0263, 
+  0302, 0111, 0252, 0264, 0335, 0004, 0225, 0266, 0313, 0125, 0172, 0140, 0266, 0160, 0021, 0232, 
+  0104, 0164, 0307, 0005, 0031, 0356, 0320, 0044, 0223, 0242, 0112, 0322, 0100, 0211, 0341, 0100, 
+  0232, 0156, 0033, 0237, 0223, 0064, 0216, 0017, 0130, 0115, 0055, 0333, 0353, 0255, 0346, 0141, 
+  0156, 0255, 0012, 0043, 0244, 0264, 0136, 0077, 0371, 0162, 0210, 0162, 0143, 0323, 0350, 0236, 
+  0155, 0211, 0226, 0004, 0371, 0025, 0373, 0373, 0115, 0131, 0360, 0225, 0272, 0317, 0366, 0050, 
+  0247, 0157, 0007, 0360, 0227, 0150, 0152, 0056, 0025, 0164, 0243, 0232, 0164, 0045, 0125, 0120, 
+  0271, 0346, 0073, 0125, 0232, 0307, 0211, 0260, 0016, 0062, 0130, 0254, 0141, 0305, 0344, 0345, 
+  0166, 0160, 0020, 0023, 0330, 0257, 0214, 0332, 0235, 0035, 0132, 0037, 0212, 0162, 0146, 0172, 
+  0355, 0327, 0173, 0021, 0277, 0017, 0021, 0033, 0161, 0245, 0017, 0042, 0373, 0205, 0015, 0175, 
+  0127, 0307, 0227, 0176, 0111, 0063, 0326, 0032, 0236, 0275, 0074, 0237, 0035, 0302, 0152, 0230, 
+  0340, 0175, 0324, 0232, 0261, 0114, 0333, 0022, 0272, 0214, 0243, 0125, 0150, 0340, 0155, 0316, 
+  0164, 0131, 0055, 0211, 0162, 0021, 0100, 0005, 0227, 0100, 0007, 0052, 0134, 0261, 0001, 0146, 
+  0255, 0346, 0230, 0335, 0301, 0314, 0075, 0347, 0243, 0307, 0031, 0010, 0040, 0043, 0046, 0206, 
+  0251, 0135, 0212, 0060, 0301, 0246, 0255, 0371, 0061, 0225, 0371, 0106, 0100, 0317, 0122, 0034, 
+  0301, 0202, 0250, 0020, 0374, 0213, 0300, 0100, 0305, 0253, 0351, 0066, 0115, 0022, 0257, 0066, 
+  0267, 0125, 0317, 0100, 0220, 0071, 0321, 0001, 0064, 0237, 0143, 0207, 0124, 0361, 0025, 0376, 
+  0135, 0151, 0336, 0213, 0042, 0350, 0324, 0316, 0223, 0303, 0070, 0144, 0026, 0274, 0024, 0117, 
+  0240, 0172, 0017, 0227, 0057, 0353, 0006, 0313, 0142, 0236, 0154, 0167, 0266, 0166, 0356, 0307, 
+  0115, 0036, 0316, 0271, 0327, 0073, 0255, 0367, 0071, 0225, 0074, 0231, 0062, 0205, 0017, 0004, 
+  0215, 0117, 0311, 0320, 0374, 0120, 0121, 0100, 0017, 0045, 0246, 0205, 0304, 0225, 0053, 0071, 
+  0035, 0110, 0030, 0050, 0311, 0203, 0044, 0207, 0364, 0001, 0215, 0154, 0205, 0060, 0114, 0314, 
+  0245, 0134, 0163, 0056, 0362, 0014, 0276, 0274, 0244, 0312, 0073, 0344, 0157, 0036, 0207, 0254, 
+  0337, 0302, 0041, 0352, 0040, 0056, 0363, 0071, 0021, 0171, 0063, 0134, 0361, 0277, 0177, 0376, 
+  0055, 0233, 0127, 0360, 0201, 0117, 0223, 0003, 0301, 0102, 0275, 0136, 0074, 0077, 0341, 0175, 
+  0156, 0115, 0241, 0010, 0334, 0114, 0013, 0355, 0335, 0150, 0241, 0121, 0252, 0177, 0027, 0101, 
+  0260, 0200, 0101, 0315, 0100, 0051, 0033, 0125, 0200, 0320, 0125, 0336, 0366, 0223, 0114, 0136, 
+  0210, 0227, 0115, 0100, 0064, 0364, 0064, 0230, 0350, 0070, 0201, 0152, 0025, 0017, 0233, 0205, 
+  0210, 0120, 0263, 0061, 0345, 0062, 0304, 0202, 0321, 0046, 0265, 0132, 0221, 0174, 0077, 0006, 
+  0321, 0336, 0221, 0101, 0004, 0311, 0207, 0055, 0354, 0341, 0107, 0201, 0144, 0304, 0207, 0236, 
+  0322, 0100, 0020, 0261, 0342, 0352, 0104, 0151, 0342, 0335, 0043, 0330, 0115, 0236, 0037, 0203, 
+  0314, 0331, 0104, 0236, 0313, 0104, 0072, 0273, 0212, 0031, 0112, 0060, 0315, 0315, 0026, 0106, 
+  0342, 0275, 0347, 0043, 0036, 0002, 0171, 0367, 0361, 0063, 0031, 0032, 0326, 0007, 0342, 0117, 
+  0322, 0227, 0100, 0015, 0245, 0075, 0133, 0306, 0163, 0131, 0306, 0325, 0163, 0244, 0260, 0166, 
+  0163, 0363, 0346, 0323, 0241, 0172, 0217, 0203, 0010, 0315, 0121, 0036, 0222, 0354, 0010, 0370, 
+  0147, 0022, 0150, 0004, 0062, 0370, 0040, 0061, 0053, 0015, 0322, 0263, 0034, 0162, 0223, 0262, 
+  0125, 0062, 0315, 0227, 0241, 0261, 0274, 0067, 0161, 0334, 0344, 0230, 0266, 0204, 0016, 0060, 
+  0257, 0305, 0206, 0377, 0135, 0171, 0100, 0133, 0175, 0122, 0120, 0030, 0360, 0220, 0237, 0137, 
+  0134, 0236, 0370, 0151, 0302, 0306, 0356, 0324, 0074, 0054, 0135, 0327, 0247, 0052, 0117, 0023, 
+  0267, 0161, 0255, 0324, 0304, 0033, 0341, 0140, 0037, 0063, 0326, 0010, 0367, 0346, 0074, 0315, 
+  0104, 0152, 0054, 0023, 0020, 0056, 0270, 0261, 0173, 0106, 0340, 0126, 0003, 0170, 0271, 0201, 
+  0155, 0352, 0131, 0315, 0302, 0346, 0201, 0126, 0102, 0100, 0370, 0147, 0172, 0047, 0244, 0250, 
+  0170, 0223, 0377, 0172, 0214, 0375, 0011, 0023, 0261, 0344, 0226, 0113, 0326, 0322, 0342, 0262, 
+  0216, 0361, 0177, 0102, 0255, 0376, 0301, 0141, 0116, 0014, 0363, 0172, 0076, 0214, 0020, 0030, 
+  0332, 0245, 0241, 0217, 0063, 0127, 0371, 0010, 0244, 0260, 0230, 0032, 0054, 0121, 0023, 0053, 
+  0130, 0335, 0350, 0137, 0272, 0154, 0140, 0100, 0074, 0236, 0222, 0256, 0224, 0302, 0335, 0043, 
+  0301, 0242, 0105, 0114, 0203, 0052, 0235, 0315, 0320, 0132, 0121, 0102, 0235, 0140, 0041, 0327, 
+  0350, 0105, 0027, 0274, 0234, 0044, 0046, 0217, 0363, 0060, 0337, 0251, 0033, 0340, 0223, 0076, 
+  0133, 0203, 0342, 0372, 0042, 0150, 0257, 0024, 0055, 0316, 0100, 0263, 0036, 0367, 0322, 0312, 
+  0073, 0357, 0112, 0153, 0060, 0152, 0250, 0203, 0163, 0157, 0362, 0171, 0172, 0223, 0063, 0361, 
+  0367, 0065, 0213, 0243, 0146, 0001, 0236, 0047, 0001, 0231, 0342, 0316, 0016, 0331, 0277, 0254, 
+  0271, 0277, 0365, 0176, 0173, 0233, 0262, 0174, 0006, 0071, 0307, 0000, 0162, 0226, 0014, 0255, 
+  0241, 0015, 0323, 0203, 0037, 0063, 0154, 0333, 0200, 0235, 0011, 0264, 0320, 0212, 0075, 0255, 
+  0056, 0354, 0154, 0233, 0347, 0056, 0254, 0273, 0102, 0030, 0307, 0326, 0205, 0135, 0277, 0205, 
+  0163, 0027, 0366, 0324, 0273, 0260, 0076, 0112, 0151, 0233, 0166, 0312, 0135, 0244, 0306, 0104, 
+  0202, 0035, 0053, 0175, 0117, 0114, 0014, 0220, 0100, 0113, 0222, 0314, 0166, 0232, 0275, 0224, 
+  0272, 0301, 0365, 0004, 0032, 0266, 0057, 0247, 0347, 0122, 0271, 0150, 0355, 0033, 0332, 0233, 
+  0301, 0355, 0105, 0350, 0330, 0204, 0334, 0371, 0373, 0224, 0243, 0215, 0254, 0157, 0215, 0170, 
+  0366, 0007, 0312, 0053, 0113, 0332, 0020, 0106, 0374, 0014, 0311, 0237, 0011, 0222, 0117, 0205, 
+  0177, 0074, 0227, 0205, 0213, 0034, 0037, 0025, 0324, 0256, 0161, 0125, 0370, 0014, 0266, 0033, 
+  0003, 0266, 0227, 0114, 0355, 0310, 0301, 0366, 0336, 0100, 0364, 0124, 0120, 0047, 0174, 0215, 
+  0171, 0151, 0213, 0057, 0027, 0076, 0057, 0211, 0342, 0330, 0300, 0363, 0272, 0015, 0234, 0241, 
+  0363, 0251, 0103, 0147, 0046, 0204, 0067, 0325, 0176, 0172, 0167, 0165, 0023, 0000, 0235, 0342, 
+  0147, 0017, 0247, 0040, 0230, 0232, 0201, 0230, 0364, 0117, 0000, 0316, 0330, 0371, 0214, 0235, 
+  0137, 0310, 0175, 0305, 0251, 0343, 0274, 0324, 0333, 0212, 0213, 0373, 0077, 0052, 0334, 0161, 
+  0276, 0323, 0170, 0012, 0056, 0167, 0302, 0067, 0032, 0367, 0350, 0247, 0315, 0271, 0370, 0170, 
+  0063, 0053, 0033, 0236, 0347, 0362, 0143, 0310, 0315, 0175, 0162, 0051, 0116, 0302, 0370, 0144, 
+  0357, 0077, 0116, 0265, 0377, 0242, 0157, 0077, 0256, 0120, 0364, 0013, 0276, 0000, 0231, 0233, 
+  0004, 0115, 0044, 0062, 0102, 0031, 0235, 0357, 0077, 0036, 0305, 0242, 0263, 0126, 0105, 0147, 
+  0227, 0235, 0234, 0004, 0274, 0171, 0071, 0170, 0153, 0114, 0063, 0047, 0115, 0015, 0167, 0313, 
+  0210, 0162, 0133, 0041, 0075, 0245, 0237, 0323, 0314, 0276, 0136, 0315, 0320, 0271, 0247, 0177, 
+  0161, 0232, 0176, 0310, 0341, 0174, 0226, 0120, 0115, 0341, 0235, 0150, 0060, 0261, 0222, 0006, 
+  0127, 0240, 0355, 0166, 0366, 0277, 0207, 0171, 0243, 0036, 0113, 0321, 0171, 0312, 0222, 0201, 
+  0337, 0073, 0356, 0374, 0137, 0175, 0055, 0015, 0154, 0025, 0131, 0230, 0361, 0070, 0373, 0163, 
+  0313, 0257, 0376, 0007, 0112, 0344, 0157, 0105, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0155, 
+  0141, 0164, 0145, 0057, 0000, 0000, 0000, 0000
+} };
+
+static GStaticResource static_resource = { msm_resource_data.data, sizeof (msm_resource_data.data) - 1 /* nul terminator */, NULL, NULL, NULL };
+
+G_MODULE_EXPORT
+GResource *msm_get_resource (void);
+GResource *msm_get_resource (void)
+{
+  return g_static_resource_get_resource (&static_resource);
+}
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GLib Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __G_CONSTRUCTOR_H__
+#define __G_CONSTRUCTOR_H__
+
+/*
+  If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and
+  destructors, in a usable way, including e.g. on library unload. If not you're on
+  your own.
+
+  Some compilers need #pragma to handle this, which does not work with macros,
+  so the way you need to use this is (for constructors):
+
+  #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+  #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(my_constructor)
+  #endif
+  G_DEFINE_CONSTRUCTOR(my_constructor)
+  static void my_constructor(void) {
+   ...
+  }
+
+*/
+
+#ifndef __GTK_DOC_IGNORE__
+
+#if  __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func (void);
+#define G_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func (void);
+
+#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
+/* Visual studio 2008 and later has _Pragma */
+
+/*
+ * Only try to include gslist.h if not already included via glib.h,
+ * so that items using gconstructor.h outside of GLib (such as
+ * GResources) continue to build properly.
+ */
+#ifndef __G_LIB_H__
+#include "gslist.h"
+#endif
+
+#include <stdlib.h>
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* We do some weird things to avoid the constructors being optimized
+ * away on VS2015 if WholeProgramOptimization is enabled. First we
+ * make a reference to the array from the wrapper to make sure its
+ * references. Then we use a pragma to make sure the wrapper function
+ * symbol is always included at the link stage. Also, the symbols
+ * need to be extern (but not dllexport), even though they are not
+ * really used from another object file.
+ */
+
+/* We need to account for differences between the mangling of symbols
+ * for x86 and x64/ARM/ARM64 programs, as symbols on x86 are prefixed
+ * with an underscore but symbols on x64/ARM/ARM64 are not.
+ */
+#ifdef _M_IX86
+#define G_MSVC_SYMBOL_PREFIX "_"
+#else
+#define G_MSVC_SYMBOL_PREFIX ""
+#endif
+
+#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
+#define G_DEFINE_DESTRUCTOR(_func) G_MSVC_DTOR (_func, G_MSVC_SYMBOL_PREFIX)
+
+#define G_MSVC_CTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _wrapper(void) { _func(); g_slist_find (NULL,  _array ## _func); return 0; } \
+  __pragma(comment(linker,"/include:" _sym_prefix # _func "_wrapper")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _wrapper;
+
+#define G_MSVC_DTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _constructor(void) { atexit (_func); g_slist_find (NULL,  _array ## _func); return 0; } \
+   __pragma(comment(linker,"/include:" _sym_prefix # _func "_constructor")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined (_MSC_VER)
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* Pre Visual studio 2008 must use #pragma section */
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _wrapper(void) { _func(); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func ## _wrapper;
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _constructor(void) { atexit (_func); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined(__SUNPRO_C)
+
+/* This is not tested, but i believe it should work, based on:
+ * http://opensource.apple.com/source/OpenSSL098/OpenSSL098-35/src/fips/fips_premain.c
+ */
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  init(_func)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void);
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  fini(_func)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void);
+
+#else
+
+/* constructors not supported for this compiler */
+
+#endif
+
+#endif /* __GTK_DOC_IGNORE__ */
+#endif /* __G_CONSTRUCTOR_H__ */
+
+#ifdef G_HAS_CONSTRUCTORS
+
+#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(msmresource_constructor)
+#endif
+G_DEFINE_CONSTRUCTOR(msmresource_constructor)
+#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(msmresource_destructor)
+#endif
+G_DEFINE_DESTRUCTOR(msmresource_destructor)
+
+#else
+#warning "Constructor not supported on this compiler, linking in resources will not work"
+#endif
+
+static void msmresource_constructor (void)
+{
+  g_static_resource_init (&static_resource);
+}
+
+static void msmresource_destructor (void)
+{
+  g_static_resource_fini (&static_resource);
+}
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/11.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/11.html new file mode 100644 index 00000000..174d418f --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/11.html @@ -0,0 +1,1039 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
#include <config.h>
+
+#include <glib/gi18n.h>
+#include <glibtop/procopenfiles.h>
+#include <sys/stat.h>
+#include <netdb.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include "procman.h"
+#include "openfiles.h"
+#include "proctable.h"
+#include "util.h"
+#include "settings-keys.h"
+
+#ifndef NI_IDN
+#define NI_IDN 0
+#endif
+
+enum
+{
+    COL_FD,
+    COL_TYPE,
+    COL_OBJECT,
+    COL_OPENFILE_STRUCT,
+    NUM_OPENFILES_COL
+};
+
+
+static const char*
+get_type_name(enum glibtop_file_type t)
+{
+    switch(t)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        return _("file");
+    case GLIBTOP_FILE_TYPE_PIPE:
+        return _("pipe");
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+        return _("IPv6 network connection");
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        return _("IPv4 network connection");
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        return _("local socket");
+    default:
+        return _("unknown type");
+    }
+}
+
+
+
+static char *
+friendlier_hostname(const char *addr_str, int port)
+{
+    struct addrinfo hints = { };
+    struct addrinfo *res = NULL;
+    char hostname[NI_MAXHOST];
+    char service[NI_MAXSERV];
+    char port_str[6];
+
+    if (!addr_str[0]) return g_strdup("");
+
+    snprintf(port_str, sizeof port_str, "%d", port);
+
+    hints.ai_family = AF_UNSPEC;
+    hints.ai_socktype = SOCK_STREAM;
+
+    if (getaddrinfo(addr_str, port_str, &hints, &res))
+        goto failsafe;
+
+    if (getnameinfo(res->ai_addr, res->ai_addrlen, hostname,<--- Null pointer dereference
+            sizeof hostname, service, sizeof service, NI_IDN))
+        goto failsafe;
+
+    if (res) freeaddrinfo(res);<--- Assuming that condition 'res' is not redundant
+        return g_strdup_printf("%s, TCP port %d (%s)", hostname, port, service);
+
+  failsafe:
+    if (res) freeaddrinfo(res);
+    return g_strdup_printf("%s, TCP port %d", addr_str, port);
+}
+
+
+
+static void
+add_new_files (gpointer key, gpointer value, gpointer data)
+{
+    glibtop_open_files_entry *openfiles = static_cast<glibtop_open_files_entry*>(value);
+
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreeIter row;
+
+    char *object;
+
+    switch(openfiles->type)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        object = g_strdup(openfiles->info.file.name);
+        break;
+
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        object = friendlier_hostname(openfiles->info.sock.dest_host,
+                         openfiles->info.sock.dest_port);
+        break;
+
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        object = g_strdup(openfiles->info.localsock.name);
+        break;
+
+    default:
+        object = g_strdup("");
+    }
+
+    gtk_list_store_insert (GTK_LIST_STORE (model), &row, 0);
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        COL_FD, openfiles->fd,
+                        COL_TYPE, get_type_name(static_cast<glibtop_file_type>(openfiles->type)),
+                        COL_OBJECT, object,
+#if GLIB_CHECK_VERSION (2, 68, 0)
+                        COL_OPENFILE_STRUCT, g_memdup2(openfiles, sizeof(*openfiles)),
+#else
+                        COL_OPENFILE_STRUCT, g_memdup(openfiles, sizeof(*openfiles)),
+#endif
+                        -1);
+
+    g_free(object);
+}
+
+static GList *old_maps = NULL;
+
+static gboolean
+classify_openfiles (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+    GHashTable *new_maps = static_cast<GHashTable*>(data);
+    GtkTreeIter *old_iter;
+    glibtop_open_files_entry *openfiles;
+    gchar *old_name;
+
+    gtk_tree_model_get (model, iter, 1, &old_name, -1);
+
+    openfiles = static_cast<glibtop_open_files_entry*>(g_hash_table_lookup (new_maps, old_name));
+    if (openfiles) {
+        g_hash_table_remove (new_maps, old_name);
+        g_free (old_name);
+        return FALSE;
+
+    }
+
+    old_iter = gtk_tree_iter_copy (iter);
+    old_maps = g_list_append (old_maps, old_iter);
+    g_free (old_name);
+    return FALSE;
+
+}
+
+
+static gboolean
+compare_open_files(gconstpointer a, gconstpointer b)
+{
+    const glibtop_open_files_entry *o1 = static_cast<const glibtop_open_files_entry *>(a);
+    const glibtop_open_files_entry *o2 = static_cast<const glibtop_open_files_entry *>(b);
+
+    /* Falta manejar los diferentes tipos! */
+    return (o1->fd == o2->fd) && (o1->type == o2->type); /* XXX! */
+}
+
+
+static void
+update_openfiles_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+    GtkTreeModel *model;
+    glibtop_open_files_entry *openfiles;<--- Shadowed declaration
+    glibtop_proc_open_files procmap;
+    GHashTable *new_maps;
+    guint i;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    if (!info)
+        return;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    openfiles = glibtop_get_proc_open_files (&procmap, info->pid);
+
+    if (!openfiles)
+        return;
+
+    new_maps = static_cast<GHashTable *>(g_hash_table_new_full (g_str_hash, compare_open_files,
+                                                                NULL, NULL));
+    for (i=0; i < procmap.number; i++)
+        g_hash_table_insert (new_maps, openfiles + i, openfiles + i);
+
+    gtk_tree_model_foreach (model, classify_openfiles, new_maps);
+
+    g_hash_table_foreach (new_maps, add_new_files, model);
+
+    while (old_maps) {
+        GtkTreeIter *iter = static_cast<GtkTreeIter*>(old_maps->data);
+        glibtop_open_files_entry *openfiles = NULL;<--- Shadow variable
+
+        gtk_tree_model_get (model, iter,
+                            COL_OPENFILE_STRUCT, &openfiles,
+                            -1);
+
+        gtk_list_store_remove (GTK_LIST_STORE (model), iter);
+        gtk_tree_iter_free (iter);
+        g_free (openfiles);
+
+        old_maps = g_list_next (old_maps);
+
+    }
+
+    g_hash_table_destroy (new_maps);
+    g_free (openfiles);
+}
+
+static void
+close_openfiles_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GSettings *settings;
+    guint timer;
+
+    settings = static_cast<GSettings*>(g_object_get_data (G_OBJECT (tree), "settings"));
+    procman_save_tree_state (settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    return ;
+}
+
+
+static GtkWidget *
+create_openfiles_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    const gchar * const titles[] = {
+        /* Translators: "FD" here means "File Descriptor". Please use
+           a very short translation if possible, and at most
+           2-3 characters for it to be able to fit in the UI. */
+        N_("FD"),
+        N_("Type"),
+        N_("Object")
+    };
+
+    model = gtk_list_store_new (NUM_OPENFILES_COL,
+                                G_TYPE_INT,        /* FD */
+                                G_TYPE_STRING,    /* Type */
+                                G_TYPE_STRING,    /* Object */
+                                G_TYPE_POINTER    /* open_files_entry */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_OPENFILES_COL-1; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        switch (i) {
+        case COL_FD:
+            g_object_set(cell, "xalign", 1.0f, NULL);
+            break;
+        }
+
+        column = gtk_tree_view_column_new_with_attributes (_(titles[i]),
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_sort_column_id (column, i);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    procman_get_tree_state (procdata->settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    return tree;
+}
+
+
+static gboolean
+openfiles_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_openfiles_dialog (tree);
+
+    return TRUE;
+}
+
+
+static void
+create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *openfilesdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    openfilesdialog = gtk_dialog_new_with_buttons (_("Open Files"), NULL,
+                                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                   "gtk-close", GTK_RESPONSE_CLOSE,
+                                                   NULL);
+    gtk_window_set_resizable (GTK_WINDOW (openfilesdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (openfilesdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (openfilesdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (openfilesdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Files opened by process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                    GTK_POLICY_AUTOMATIC,
+                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_openfiles_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+    g_object_set_data (G_OBJECT (tree), "settings", procdata->settings);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (openfilesdialog), "response",
+                      G_CALLBACK (close_openfiles_dialog), tree);
+
+    gtk_widget_show_all (openfilesdialog);
+
+    timer = g_timeout_add_seconds (5, openfiles_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_openfiles_dialog (tree);
+
+}
+
+
+void
+create_openfiles_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_openfiles_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/12.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/12.html new file mode 100644 index 00000000..c1c9bcc6 --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/12.html @@ -0,0 +1,385 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
// -*- c++ -*-
+
+#ifndef _PROCMAN_PRETTYTABLE_H_
+#define _PROCMAN_PRETTYTABLE_H_
+
+#include <glib.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <glibmm/refptr.h>
+#include <gdkmm/pixbuf.h>
+#include <giomm/filemonitor.h>
+
+#include <map>
+#include <string>
+
+#ifdef HAVE_WNCK
+extern "C" {
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h>
+}
+#endif
+
+#include "iconthemewrapper.h"
+
+class ProcInfo;
+
+using std::string;
+
+class PrettyTable
+{
+ public:
+    PrettyTable();
+    ~PrettyTable();
+
+    void set_icon(ProcInfo &);
+
+private:
+
+#ifdef HAVE_WNCK
+    static void on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_opened'
+    static void on_application_closed(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_closed'
+
+    void register_application(pid_t pid, Glib::RefPtr<Gdk::Pixbuf> icon);
+    void unregister_application(pid_t pid);
+#endif
+
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_theme(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_default(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_gio(const ProcInfo &);
+#ifdef HAVE_WNCK
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_wnck(const ProcInfo &);
+#endif
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_name(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_for_kernel(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_dummy(const ProcInfo &);
+
+    bool get_default_icon_name(const string &cmd, string &name);
+    void file_monitor_event (Glib::RefPtr<Gio::File>,
+                             Glib::RefPtr<Gio::File>,
+                             Gio::FileMonitorEvent);
+    void init_gio_app_cache ();
+
+    typedef std::map<string, Glib::RefPtr<Gdk::Pixbuf> > IconCache;
+    typedef std::map<pid_t, Glib::RefPtr<Gdk::Pixbuf> > IconsForPID;
+    typedef std::map<string, Glib::RefPtr<Gio::AppInfo> > AppCache;
+    typedef std::map<string, Glib::RefPtr<Gio::FileMonitor> > DesktopDirMonitors;
+
+    IconsForPID apps;
+    IconCache defaults;
+    DesktopDirMonitors monitors;
+    AppCache gio_apps;
+    procman::IconThemeWrapper theme;
+};
+
+#endif /* _PROCMAN_PRETTYTABLE_H_ */
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/13.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/13.html new file mode 100644 index 00000000..b7c3450b --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/13.html @@ -0,0 +1,1417 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
/* Procman - dialogs
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+
+#include <signal.h>
+#include <string.h>
+
+#include "procdialogs.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "procactions.h"
+#include "util.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "procman_gksu.h"
+#include "procman_pkexec.h"
+#include "cgroups.h"
+
+#define GET_WIDGET(x) GTK_WIDGET(gtk_builder_get_object(builder, x))
+
+static GtkWidget *renice_dialog = NULL;
+static GtkWidget *prefs_dialog = NULL;
+static gint new_nice_value = 0;
+
+
+static void
+kill_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    struct KillArgs *kargs = static_cast<KillArgs*>(data);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    if (id == GTK_RESPONSE_OK)
+        kill_process (kargs->procdata, kargs->signal);
+
+    g_free (kargs);
+}
+
+void
+procdialog_create_kill_dialog (ProcData *procdata, int signal)
+{
+    GtkWidget *kill_alert_dialog;
+    gchar *primary, *secondary, *button_text;
+    struct KillArgs *kargs;
+
+    kargs = g_new(KillArgs, 1);
+    kargs->procdata = procdata;
+    kargs->signal = signal;
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if ( selected_count == 1 ) {
+        ProcInfo *selected_process = NULL;
+        // get the last selected row
+        gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &selected_process);
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing single process*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        } else {
+            /*xgettext: primary alert message for ending single process*/
+            primary = g_strdup_printf (_("Are you sure you want to end the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        }
+    } else {
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the %d selected processes?"),
+                                       selected_count);
+        } else {
+            /*xgettext: primary alert message for ending multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to end the %d selected processes?"),
+                                       selected_count);
+
+        }
+    }
+
+    if ( signal == SIGKILL ) {
+        /*xgettext: secondary alert message*/
+        secondary = _("Killing a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be killed.");
+        button_text = ngettext("_Kill Process", "_Kill Processes", selected_count);
+    } else {
+        /*xgettext: secondary alert message*/
+        secondary = _("Ending a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be ended.");
+        button_text = ngettext("_End Process", "_End Processes", selected_count);
+    }
+
+    kill_alert_dialog = gtk_message_dialog_new (GTK_WINDOW (procdata->app),
+                                                static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
+                                                GTK_MESSAGE_WARNING,
+                                                GTK_BUTTONS_NONE,
+                                                "%s",
+                                                primary);
+    g_free (primary);
+
+    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (kill_alert_dialog),
+                                              "%s",
+                                              secondary);
+
+    gtk_dialog_add_buttons (GTK_DIALOG (kill_alert_dialog),
+                            "gtk-cancel", GTK_RESPONSE_CANCEL,
+                            button_text, GTK_RESPONSE_OK,
+                            NULL);
+
+    gtk_dialog_set_default_response (GTK_DIALOG (kill_alert_dialog),
+                                     GTK_RESPONSE_CANCEL);
+
+    g_signal_connect (G_OBJECT (kill_alert_dialog), "response",
+                      G_CALLBACK (kill_dialog_button_pressed), kargs);
+
+    gtk_widget_show_all (kill_alert_dialog);
+}
+
+static void
+renice_scale_changed (GtkAdjustment *adj, gpointer data)
+{
+    GtkWidget *label = GTK_WIDGET (data);
+
+    new_nice_value = int(gtk_adjustment_get_value (adj));
+    gchar* text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (new_nice_value));
+    gtk_label_set_text (GTK_LABEL (label), text);
+    g_free(text);
+
+}
+
+static void
+renice_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (id == 100) {
+        if (new_nice_value == -100)
+            return;
+        renice(procdata, new_nice_value);
+    }
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+    renice_dialog = NULL;
+}
+
+void
+procdialog_create_renice_dialog (ProcData *procdata)
+{
+    ProcInfo  *info;
+    GtkWidget *dialog = NULL;
+    GtkWidget *dialog_vbox;
+    GtkWidget *vbox;
+    GtkWidget *label;
+    GtkWidget *priority_label;
+    GtkWidget *grid;
+    GtkAdjustment *renice_adj;
+    GtkWidget *hscale;
+    GtkWidget *button;
+    GtkWidget *icon;
+    gchar     *text;
+    gchar     *dialog_title;
+
+    if (renice_dialog)
+        return;
+
+    gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &info);
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if (!info)
+        return;
+
+    if ( selected_count == 1 ) {
+        dialog_title = g_strdup_printf (_("Change Priority of Process “%s†(PID: %u)"),
+                                        info->name, info->pid);
+    } else {
+        dialog_title = g_strdup_printf (_("Change Priority of %d Selected Processes"),
+                                        selected_count);
+    }
+
+    dialog = gtk_dialog_new_with_buttons (dialog_title, NULL,
+                                          GTK_DIALOG_DESTROY_WITH_PARENT,
+                                          "gtk-cancel", GTK_RESPONSE_CANCEL,
+                                          NULL);
+    g_free (dialog_title);
+
+    renice_dialog = dialog;
+    gtk_window_set_resizable (GTK_WINDOW (renice_dialog), FALSE);
+    gtk_container_set_border_width (GTK_CONTAINER (renice_dialog), 5);
+
+    button = gtk_button_new_with_mnemonic (_("Change _Priority"));
+    gtk_widget_set_can_default (button, TRUE);
+
+    icon = gtk_image_new_from_icon_name ("gtk-apply", GTK_ICON_SIZE_BUTTON);
+    gtk_button_set_image (GTK_BUTTON (button), icon);
+
+    gtk_dialog_add_action_widget (GTK_DIALOG (renice_dialog), button, 100);
+    gtk_dialog_set_default_response (GTK_DIALOG (renice_dialog), 100);
+    new_nice_value = -100;
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+    gtk_box_set_spacing (GTK_BOX (dialog_vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), vbox, TRUE, TRUE, 0);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+
+    grid = gtk_grid_new ();
+    gtk_grid_set_column_spacing (GTK_GRID(grid), 12);
+    gtk_grid_set_row_spacing (GTK_GRID(grid), 6);
+    gtk_box_pack_start (GTK_BOX (vbox), grid, TRUE, TRUE, 0);
+
+    label = gtk_label_new_with_mnemonic (_("_Nice value:"));
+    gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 2);
+
+    renice_adj = gtk_adjustment_new (info->nice, RENICE_VAL_MIN, RENICE_VAL_MAX, 1, 1, 0);
+    new_nice_value = 0;
+    hscale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, renice_adj);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), hscale);
+    gtk_scale_set_digits (GTK_SCALE (hscale), 0);
+    gtk_widget_set_hexpand (hscale, TRUE);
+    gtk_grid_attach (GTK_GRID (grid), hscale, 1, 0, 1, 1);
+    text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (info->nice));
+    priority_label = gtk_label_new (text);
+    gtk_grid_attach (GTK_GRID (grid), priority_label, 1, 1, 1, 1);
+    g_free(text);
+
+    text = g_strconcat("<small><i><b>", _("Note:"), "</b> ",
+        _("The priority of a process is given by its nice value. A lower nice value corresponds to a higher priority."),
+        "</i></small>", NULL);
+    label = gtk_label_new (_(text));
+    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+    g_free (text);
+
+    g_signal_connect (G_OBJECT (dialog), "response",
+                      G_CALLBACK (renice_dialog_button_pressed), procdata);
+    g_signal_connect (G_OBJECT (renice_adj), "value_changed",
+                      G_CALLBACK (renice_scale_changed), priority_label);
+
+    gtk_widget_show_all (dialog);
+
+
+}
+
+static void
+prefs_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    if (id == GTK_RESPONSE_HELP)
+    {
+        GError* error = 0;
+        if (!g_app_info_launch_default_for_uri("help:mate-system-monitor/mate-system-monitor-prefs", NULL, &error))
+        {
+            g_warning("Could not display preferences help : %s", error->message);
+            g_error_free(error);
+        }
+    }
+    else
+    {
+        gtk_widget_destroy (GTK_WIDGET (dialog));
+        prefs_dialog = NULL;
+    }
+}
+
+
+class SpinButtonUpdater
+{
+public:
+    SpinButtonUpdater(const string& key)
+        : key(key)
+    { }
+
+    static gboolean callback(GtkWidget *widget, GdkEventFocus *event, gpointer data)
+    {
+        SpinButtonUpdater* updater = static_cast<SpinButtonUpdater*>(data);
+        gtk_spin_button_update(GTK_SPIN_BUTTON(widget));
+        updater->update(GTK_SPIN_BUTTON(widget));
+        return FALSE;
+    }
+
+private:
+
+    void update(GtkSpinButton* spin)
+    {
+        int new_value = int(1000 * gtk_spin_button_get_value(spin));
+        g_settings_set_int(ProcData::get_instance()->settings,
+                           this->key.c_str(), new_value);
+
+        procman_debug("set %s to %d", this->key.c_str(), new_value);
+    }
+
+    const string key;
+};
+
+
+static void
+field_toggled (const gchar *child_schema, GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+    GtkTreeIter iter;
+    GtkTreeViewColumn *column;
+    gboolean toggled;
+    GSettings *settings = g_settings_get_child (ProcData::get_instance()->settings, child_schema);
+    gchar *key;
+    int id;
+
+    if (!path)
+        return;
+
+    gtk_tree_model_get_iter (model, &iter, path);
+
+    gtk_tree_model_get (model, &iter, 2, &column, -1);
+    toggled = gtk_cell_renderer_toggle_get_active (cell);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, !toggled, -1);
+    gtk_tree_view_column_set_visible (column, !toggled);
+
+    id = gtk_tree_view_column_get_sort_column_id (column);
+
+    key = g_strdup_printf ("col-%d-visible", id);
+    g_settings_set_boolean (settings, key, !toggled);
+    g_free (key);
+
+    gtk_tree_path_free (path);
+}
+
+static void
+proc_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("proctree", cell, path_str, data);
+}
+
+static void
+disk_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("disktreenew", cell, path_str, data);
+}
+
+static void
+create_field_page(GtkBuilder* builder, GtkWidget *tree, const gchar *widgetname)
+{
+    GtkTreeView *treeview;
+    GList *it, *columns;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;<--- Shadowed declaration
+    GtkCellRenderer *cell;
+    gchar *full_widgetname;
+
+    full_widgetname = g_strdup_printf ("%s_columns", widgetname);
+    treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, full_widgetname));
+    g_free (full_widgetname);
+
+    model = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER);
+
+    gtk_tree_view_set_model (GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(model));
+    g_object_unref (G_OBJECT (model));
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_toggle_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "active", 0,
+                                         NULL);
+
+    if (g_strcmp0 (widgetname, "proctree") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (proc_field_toggled), model);
+    else if (g_strcmp0 (widgetname, "disktreenew") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (disk_field_toggled), model);
+
+    gtk_tree_view_column_set_clickable (column, TRUE);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "text", 1,
+                                         NULL);
+
+    gtk_tree_view_column_set_title (column, "Not Shown");
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    for(it = columns; it; it = it->next)
+    {
+        GtkTreeViewColumn *column = static_cast<GtkTreeViewColumn*>(it->data);<--- Shadow variable
+        GtkTreeIter iter;
+        const gchar *title;
+        gboolean visible;
+        gint column_id;
+
+        title = gtk_tree_view_column_get_title (column);
+        if (!title)
+            title = _("Icon");
+
+        column_id = gtk_tree_view_column_get_sort_column_id(column);
+        if ((column_id == COL_CGROUP) && (!cgroups_enabled()))
+            continue;
+
+        if ((column_id == COL_UNIT ||
+             column_id == COL_SESSION ||
+             column_id == COL_SEAT ||
+             column_id == COL_OWNER)
+#ifdef HAVE_SYSTEMD
+            && !LOGIND_RUNNING()
+#endif
+                )
+            continue;
+
+        visible = gtk_tree_view_column_get_visible (column);
+
+        gtk_list_store_append (model, &iter);
+        gtk_list_store_set (model, &iter, 0, visible, 1, title, 2, column,-1);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procdialog_create_preferences_dialog (ProcData *procdata)
+{
+    typedef SpinButtonUpdater SBU;
+
+    static SBU interval_updater("update-interval");
+    static SBU graph_interval_updater("graph-update-interval");
+    static SBU disks_interval_updater("disks-interval");
+
+    GtkWidget *notebook;
+    GtkAdjustment *adjustment;
+    GtkWidget *spin_button;
+    GtkWidget *check_button;
+    GtkWidget *smooth_button;
+    GtkBuilder *builder;
+    gfloat update;
+
+    if (prefs_dialog)
+        return;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/preferences.ui");
+
+    prefs_dialog = GET_WIDGET("preferences_dialog");
+    notebook = GET_WIDGET("notebook");
+    spin_button = GET_WIDGET("processes_interval_spinner");
+
+    update = (gfloat) procdata->config.update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0,
+                                   MIN_UPDATE_INTERVAL / 1000,
+                                   MAX_UPDATE_INTERVAL / 1000,
+                                   0.25,
+                                   1.0,
+                                   0);
+
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK (SBU::callback), &interval_updater);
+
+    smooth_button = GET_WIDGET("smooth_button");
+    g_settings_bind(procdata->settings, SmoothRefresh::KEY.c_str(), smooth_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    check_button = GET_WIDGET("check_button");
+    g_settings_bind(procdata->settings, "kill-dialog", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    GtkWidget *solaris_button = GET_WIDGET("solaris_button");
+    g_settings_bind(procdata->settings, procman::settings::solaris_mode.c_str(), solaris_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->tree, "proctree");
+
+    update = (gfloat) procdata->config.graph_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0, 0.25,
+                                                      100.0, 0.25, 1.0, 0);
+
+    spin_button = GET_WIDGET("resources_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &graph_interval_updater);
+
+    GtkWidget *bits_button = GET_WIDGET("bits_button");
+    g_settings_bind(procdata->settings, procman::settings::network_in_bits.c_str(), bits_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+
+    update = (gfloat) procdata->config.disks_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new (update / 1000.0, 1.0,
+                                                       100.0, 1.0, 1.0, 0);
+
+    spin_button = GET_WIDGET("devices_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &disks_interval_updater);
+
+    check_button = GET_WIDGET("all_devices_check");
+    g_settings_bind(procdata->settings, "show-all-fs", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->disk_list, "disktreenew");
+
+    gtk_widget_show_all (prefs_dialog);
+    g_signal_connect (G_OBJECT (prefs_dialog), "response",
+                       G_CALLBACK (prefs_dialog_button_pressed), procdata);
+
+    switch (procdata->config.current_tab) {
+    case PROCMAN_TAB_SYSINFO:
+    case PROCMAN_TAB_PROCESSES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
+        break;
+    case PROCMAN_TAB_RESOURCES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 1);
+        break;
+    case PROCMAN_TAB_DISKS:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 2);
+        break;
+    }
+
+    gtk_builder_connect_signals (builder, NULL);
+    g_object_unref (G_OBJECT (builder));
+}
+
+
+static char *
+procman_action_to_command(ProcmanActionType type,
+                          gint pid,
+                          gint extra_value)
+{
+    switch (type) {
+    case PROCMAN_ACTION_KILL:
+           return g_strdup_printf("kill -s %d %d", extra_value, pid);
+    case PROCMAN_ACTION_RENICE:
+        return g_strdup_printf("renice %d %d", extra_value, pid);
+    default:
+        g_assert_not_reached();
+    }
+}
+
+
+/*
+ * type determines whether if dialog is for killing process or renice.
+ * type == PROCMAN_ACTION_KILL,   extra_value -> signal to send
+ * type == PROCMAN_ACTION_RENICE, extra_value -> new priority.
+ */
+gboolean
+procdialog_create_root_password_dialog(ProcmanActionType type,
+                                       ProcData *procdata,
+                                       gint pid,
+                                       gint extra_value)
+{
+    char * command;
+    gboolean ret = FALSE;
+
+    command = procman_action_to_command(type, pid, extra_value);
+
+    procman_debug("Trying to run '%s' as root", command);
+
+    if (procman_has_pkexec())
+        ret = procman_pkexec_create_root_password_dialog(command);
+    else if (procman_has_gksu())
+        ret = procman_gksu_create_root_password_dialog(command);
+
+    g_free(command);
+    return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/14.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/14.html new file mode 100644 index 00000000..3c8a776c --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/14.html @@ -0,0 +1,1109 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
#include <glib/gi18n.h>
+#include <glibtop.h>
+#include <glibtop/close.h>
+#include <glibtop/cpu.h>
+#include <glibtop/sysinfo.h>
+
+#include "procman-app.h"
+#include "procman.h"
+#include "interface.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "argv.h"
+#include "util.h"
+
+static void
+mount_changed(const Glib::RefPtr<Gio::Mount>&)
+{
+    cb_update_disks(ProcData::get_instance());
+}
+
+
+static void
+init_volume_monitor(ProcData *procdata)
+{
+    using namespace Gio;
+    using namespace Glib;
+
+    RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+    monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
+}
+
+static gboolean
+has_key (gchar **keys, const gchar *key)
+{
+    gchar **loop = keys;
+
+    while (*loop) {
+        if (!strcmp (*loop++, key))
+            return TRUE;
+    }
+
+    return FALSE;
+}
+
+static void
+tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_tree = g_settings_get_boolean(settings, key);
+
+    g_object_set(G_OBJECT(procdata->tree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
+    proctable_update (procdata);
+}
+
+
+static void
+network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
+    // force scale to be redrawn
+    procdata->net_graph->clear_background();
+}
+
+static void
+view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.whose_process = g_settings_get_int (settings, key);
+    procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2);
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "kill-dialog")) {
+        procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
+    }
+}
+
+static void
+timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "update-interval")) {
+        procdata->config.update_interval = g_settings_get_int (settings, key);
+        procdata->config.update_interval =
+            MAX (procdata->config.update_interval, 1000);
+
+        procdata->smooth_refresh->reset();
+
+        if(procdata->timeout) {
+            g_source_remove (procdata->timeout);
+            procdata->timeout = g_timeout_add (procdata->config.update_interval,
+                                               cb_timeout,
+                                               procdata);
+        }
+    }
+    else if (g_str_equal (key, "graph-update-interval")){
+        procdata->config.graph_update_interval = g_settings_get_int (settings, key);
+        procdata->config.graph_update_interval =
+            MAX (procdata->config.graph_update_interval,
+                 250);
+        load_graph_change_speed(procdata->cpu_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->mem_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->net_graph,
+                                procdata->config.graph_update_interval);
+    }
+    else if (g_str_equal(key, "disks-interval")) {
+        procdata->config.disks_update_interval = g_settings_get_int (settings, key);
+        procdata->config.disks_update_interval =
+            MAX (procdata->config.disks_update_interval, 1000);
+
+        if(procdata->disk_timeout) {
+            g_source_remove (procdata->disk_timeout);
+            procdata->disk_timeout = \
+                g_timeout_add (procdata->config.disks_update_interval,
+                               cb_update_disks,
+                               procdata);
+        }
+    }
+    else {
+        g_assert_not_reached();
+    }
+}
+
+static void
+color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    gchar *color = g_settings_get_string (settings, key);
+
+    if (g_str_has_prefix (key, "cpu-color")) {
+        for (int i = 0; i < procdata->config.num_cpus; i++) {
+            string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
+            if (cpu_key == key) {
+                gdk_rgba_parse (&procdata->config.cpu_color[i], color);
+                procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
+                break;
+            }
+        }
+    }
+    else if (g_str_equal (key, "mem-color")) {
+        gdk_rgba_parse (&procdata->config.mem_color, color);
+        procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
+    }
+    else if (g_str_equal (key, "swap-color")) {
+        gdk_rgba_parse (&procdata->config.swap_color, color);
+        procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
+    }
+    else if (g_str_equal (key, "net-in-color")) {
+        gdk_rgba_parse (&procdata->config.net_in_color, color);
+        procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
+    }
+    else if (g_str_equal (key, "net-out-color")) {
+        gdk_rgba_parse (&procdata->config.net_out_color, color);
+        procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
+    }
+    else {
+        g_assert_not_reached();
+    }
+    g_free(color);
+}
+
+static void
+show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
+
+    cb_update_disks (data);
+}
+
+static ProcData *
+procman_data_new (GSettings *settings)
+{
+    GSettingsSchema *schema;
+    ProcData *pd;
+    gchar *color;
+    gchar **keys;
+    glibtop_cpu cpu;
+
+    pd = ProcData::get_instance();
+
+    g_settings_get (settings, "window-state", "(iiii)",
+                    &pd->config.width, &pd->config.height,
+                    &pd->config.xpos, &pd->config.ypos);
+
+    pd->config.maximized = g_settings_get_boolean(settings, "maximized");
+
+    pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
+    g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd);
+
+    pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
+    std::string detail_string("changed::" + procman::settings::solaris_mode);
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd);
+
+    pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
+    detail_string = "changed::" + procman::settings::network_in_bits;
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd);
+
+    pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
+    g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd);
+    pd->config.update_interval = g_settings_get_int (settings, "update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.graph_update_interval = g_settings_get_int (settings,
+                                                           "graph-update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",
+                      G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd);
+
+
+    /* show_all_fs */
+    pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
+    g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd);
+
+
+    pd->config.whose_process = g_settings_get_int (settings, "view-as");
+    g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd);
+    pd->config.current_tab = g_settings_get_int (settings, "current-tab");
+
+    glibtop_get_cpu (&cpu);
+    pd->frequency = cpu.frequency;
+    pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
+
+    g_object_get (settings, "settings-schema", &schema, NULL);
+    keys = g_settings_schema_list_keys (schema);
+    g_settings_schema_unref (schema);
+
+    for (int i = 0; i < pd->config.num_cpus; i++) {
+        gchar *key;
+        key = g_strdup_printf ("cpu-color%d", i);
+
+        if (has_key (keys, key))
+            color = g_settings_get_string (settings, key);
+        else
+            color = g_strdup ("#f25915e815e8");
+        detail_string = std::string("changed::") + std::string(key);
+        g_signal_connect (G_OBJECT(settings), detail_string.c_str(),
+                          G_CALLBACK(color_changed_cb), pd);
+        gdk_rgba_parse (&pd->config.cpu_color[i], color);
+        g_free (color);
+        g_free (key);
+    }
+    g_strfreev (keys);
+
+    color = g_settings_get_string (settings, "mem-color");
+    if (!color)
+        color = g_strdup ("#000000ff0082");
+    g_signal_connect (G_OBJECT(settings), "changed::mem-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.mem_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "swap-color");
+    if (!color)
+        color = g_strdup ("#00b6000000ff");
+    g_signal_connect (G_OBJECT(settings), "changed::swap-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.swap_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-in-color");
+    if (!color)
+        color = g_strdup ("#000000f200f2");
+    g_signal_connect (G_OBJECT(settings), "changed::net-in-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_in_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-out-color");
+    if (!color)
+        color = g_strdup ("#00f2000000c1");
+    g_signal_connect (G_OBJECT(settings), "changed::net-out-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_out_color, color);
+    g_free (color);
+
+    /* Sanity checks */
+    GdkDisplay *display;
+    GdkMonitor *monitor;
+    GdkRectangle monitor_geometry;
+
+    display = gdk_display_get_default ();
+    monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
+    if (monitor == NULL) {
+        monitor = gdk_display_get_monitor (display, 0);
+    }
+    gdk_monitor_get_geometry (monitor, &monitor_geometry);
+
+    pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width);
+    pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height);
+    pd->config.update_interval = MAX (pd->config.update_interval, 1000);
+    pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250);
+    pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000);
+    pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2);
+    pd->config.current_tab = CLAMP(pd->config.current_tab,
+                                   PROCMAN_TAB_SYSINFO,
+                                   PROCMAN_TAB_DISKS);
+
+    // delayed initialization as SmoothRefresh() needs ProcData
+    // i.e. we can't call ProcData::get_instance
+    pd->smooth_refresh = new SmoothRefresh(settings);
+
+    pd->terminating = FALSE;
+
+    return pd;
+}
+
+static void
+procman_free_data (ProcData *procdata)
+{
+
+    proctable_free_table (procdata);
+    delete procdata->smooth_refresh;
+}
+
+ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)<--- Member variable 'ProcmanApp::procdata' is not initialized in the constructor.
+{
+    Glib::set_application_name(_("System Monitor"));
+}
+
+Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
+{
+    return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
+}
+
+void ProcmanApp::on_activate()
+{
+    gtk_window_present (GTK_WINDOW (procdata->app));
+}
+
+static void
+set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
+{
+    gtk_notebook_set_current_page(notebook, tab);
+    cb_change_current_page(notebook, tab, procdata);
+}
+
+int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
+{
+    int argc = 0;
+    char** argv = command_line->get_arguments(argc);
+
+    Glib::OptionContext context;
+    context.set_summary(_("A simple process and system monitor."));
+    context.set_ignore_unknown_options(true);
+    procman::OptionGroup option_group;
+    context.set_main_group(option_group);
+
+    try {
+        context.parse(argc, argv);
+    } catch (const Glib::Error& ex) {
+        g_error("Arguments parse error : %s", ex.what().c_str());
+    }
+
+    if (option_group.show_system_tab) {
+        procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_SYSINFO, procdata);
+    } else if (option_group.show_processes_tab) {
+        procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_PROCESSES, procdata);
+    } else if (option_group.show_resources_tab) {
+        procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_RESOURCES, procdata);
+    } else if (option_group.show_file_systems_tab) {
+        procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_DISKS, procdata);
+    }
+
+    on_activate ();
+
+    return 0;
+}
+
+void ProcmanApp::on_startup()
+{
+    Gtk::Application::on_startup();
+
+    GSettings *settings;
+
+    Gtk::Window::set_default_icon_name ("utilities-system-monitor");
+
+    settings = g_settings_new (GSM_GSETTINGS_SCHEMA);
+
+    glibtop_init ();
+
+    procdata = procman_data_new (settings);
+    procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA);
+
+    create_main_window (procdata);
+    init_volume_monitor (procdata);
+
+    Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app));
+    window->show();
+    window->set_name ("mate-system-monitor");
+
+    add_window (*window);
+}
+
+void ProcmanApp::on_shutdown()
+{
+    procman_free_data(procdata);
+    glibtop_close();
+}
+
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/15.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/15.html new file mode 100644 index 00000000..caf6d784 --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/15.html @@ -0,0 +1,671 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+
+#include <locale.h>
+
+#include <gtkmm.h>
+#include <glib/gi18n.h>
+
+#include "procman-app.h"
+#include "procman.h"
+#include "proctable.h"
+
+ProcData::ProcData()<--- Member variable 'ProcData::uimanager' is not initialized in the constructor.<--- Member variable 'ProcData::action_group' is not initialized in the constructor.<--- Member variable 'ProcData::statusbar' is not initialized in the constructor.<--- Member variable 'ProcData::loadavg' is not initialized in the constructor.<--- Member variable 'ProcData::endprocessbutton' is not initialized in the constructor.<--- Member variable 'ProcData::popup_menu' is not initialized in the constructor.<--- Member variable 'ProcData::disk_list' is not initialized in the constructor.<--- Member variable 'ProcData::notebook' is not initialized in the constructor.<--- Member variable 'ProcData::config' is not initialized in the constructor.<--- Member variable 'ProcData::selection' is not initialized in the constructor.<--- Member variable 'ProcData::settings' is not initialized in the constructor.<--- Member variable 'ProcData::app' is not initialized in the constructor.<--- Member variable 'ProcData::menu' is not initialized in the constructor.<--- Member variable 'ProcData::frequency' is not initialized in the constructor.<--- Member variable 'ProcData::smooth_refresh' is not initialized in the constructor.
+    : tree(NULL),
+      cpu_graph(NULL),
+      mem_graph(NULL),
+      net_graph(NULL),
+      selected_process(NULL),
+      timeout(0),
+      disk_timeout(0),
+      cpu_total_time(1),
+      cpu_total_time_last(1)
+{ }
+
+ProcData* ProcData::get_instance()
+{
+    static ProcData instance;
+    return &instance;
+}
+
+gboolean
+procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns, *it;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    sort_col = g_settings_get_int (pt_settings, "sort-col");
+
+    order = static_cast<GtkSortType>(g_settings_get_int (pt_settings, "sort-order"));
+
+    if (sort_col != -1)
+        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
+                                              sort_col,
+                                              order);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        for (it = columns; it; it = it->next)
+        {
+            GtkTreeViewColumn *column;
+            gint width;
+            gboolean visible;
+            int id;
+            gchar *key;
+
+            column = static_cast<GtkTreeViewColumn*>(it->data);
+            id = gtk_tree_view_column_get_sort_column_id (column);
+
+            key = g_strdup_printf ("col-%d-width", id);
+            g_settings_get (pt_settings, key, "i", &width);
+            g_free (key);
+
+            key = g_strdup_printf ("col-%d-visible", id);
+            visible = g_settings_get_boolean (pt_settings, key);
+            g_free (key);
+
+            gtk_tree_view_column_set_visible (column, visible);
+            if (visible) {
+                /* ensure column is really visible */
+                width = MAX(width, 20);
+                gtk_tree_view_column_set_fixed_width(column, width);
+            }
+        }
+
+        GVariant     *value;
+        GVariantIter iter;
+        int          sortIndex;
+
+        GSList *order = NULL;<--- Shadow variable
+
+        value = g_settings_get_value(pt_settings, "columns-order");
+        g_variant_iter_init(&iter, value);
+
+        while (g_variant_iter_loop (&iter, "i", &sortIndex))
+            order = g_slist_append(order, GINT_TO_POINTER(sortIndex));
+
+        proctable_set_columns_order(GTK_TREE_VIEW(tree), order);
+
+        g_variant_unref(value);
+        g_slist_free(order);
+    }
+
+    g_object_unref(pt_settings);
+    pt_settings = NULL;
+
+    g_list_free(columns);
+
+    return TRUE;
+}
+
+void
+procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    if (ProcData::get_instance()->terminating)
+        return;
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    if (gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (model), &sort_col,
+                                              &order)) {
+        g_settings_set_int (pt_settings, "sort-col", sort_col);
+        g_settings_set_int (pt_settings, "sort-order", order);
+    }
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        GSList *order;<--- Shadow variable
+        GSList *order_node;
+        GVariantBuilder *builder;
+        GVariant *order_variant;
+
+        order = proctable_get_columns_order(GTK_TREE_VIEW(tree));
+
+        builder = g_variant_builder_new (G_VARIANT_TYPE ("ai"));
+
+        for (order_node = order; order_node; order_node = order_node->next)
+            g_variant_builder_add(builder, "i", GPOINTER_TO_INT(order_node->data));
+
+        order_variant = g_variant_new("ai", builder);
+        g_settings_set_value(pt_settings, "columns-order", order_variant);
+
+        g_slist_free(order);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procman_save_config (ProcData *data)
+{
+    GSettings *settings = data->settings;
+
+    g_assert(data);
+
+    data->config.maximized = gdk_window_get_state(gtk_widget_get_window (data->app)) & GDK_WINDOW_STATE_MAXIMIZED;
+    if (!data->config.maximized) {
+        // we only want to store/overwrite size and position info with non-maximized state info
+        data->config.width  = gdk_window_get_width (gtk_widget_get_window (data->app));
+        data->config.height = gdk_window_get_height(gtk_widget_get_window (data->app));
+
+        gtk_window_get_position(GTK_WINDOW(data->app), &data->config.xpos, &data->config.ypos);
+
+        g_settings_set (settings, "window-state", "(iiii)",
+                        data->config.width, data->config.height,
+                        data->config.xpos, data->config.ypos);
+    }
+    g_settings_set_boolean (settings, "maximized", data->config.maximized);
+
+    g_settings_set_int (settings, "current-tab", data->config.current_tab);
+}
+
+int
+main (int argc, char *argv[])
+{
+    bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+    textdomain (GETTEXT_PACKAGE);
+    setlocale (LC_ALL, "");
+
+    Glib::RefPtr<ProcmanApp> application = ProcmanApp::create();
+    return application->run (argc, argv);
+}
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/16.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/16.html new file mode 100644 index 00000000..91267585 --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/16.html @@ -0,0 +1,913 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
/* Process properties dialog
+ * Copyright (C) 2010 Krishnan Parthasarathi <krishnan.parthasarathi@gmail.com>
+ *                    Robert Ancell <robert.ancell@canonical.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <glibtop/procmem.h>
+#include <glibtop/procmap.h>
+#include <glibtop/procstate.h>
+
+#include "procman.h"
+#include "procproperties.h"
+#include "proctable.h"
+#include "util.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
+enum
+{
+    COL_PROP = 0,
+    COL_VAL,
+    NUM_COLS,
+};
+
+typedef struct _proc_arg {
+    const gchar *prop;
+    gchar *val;
+} proc_arg;
+
+static void
+get_process_memory_writable (ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info (ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+static gchar*
+format_memsize(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
+}
+
+static gchar*
+format_size(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size(size);
+}
+
+static void
+fill_proc_properties (GtkWidget *tree, ProcInfo *info)
+{
+    guint i;
+    GtkListStore *store;
+
+    if (!info)
+        return;
+
+    get_process_memory_info(info);
+
+    proc_arg proc_props[] = {
+        { N_("Process Name"), g_strdup_printf("%s", info->name)},
+        { N_("User"), g_strdup_printf("%s (%d)", info->user.c_str(), info->uid)},
+        { N_("Status"), g_strdup(format_process_state(info->status))},
+        { N_("Memory"), format_memsize(info->mem)},
+        { N_("Virtual Memory"), format_memsize(info->vmsize)},
+        { N_("Resident Memory"), format_memsize(info->memres)},
+        { N_("Writable Memory"), format_memsize(info->memwritable)},
+        { N_("Shared Memory"), format_memsize(info->memshared)},
+#ifdef HAVE_WNCK
+        { N_("X Server Memory"), format_memsize(info->memxserver)},
+#endif
+        { N_("Disk Read Total"), format_size(info->disk_read_bytes_total)},
+        { N_("Disk Write Total"), format_size(info->disk_write_bytes_total)},
+        { N_("CPU"), g_strdup_printf("%d%%", info->pcpu)},
+        { N_("CPU Time"), procman::format_duration_for_display(100 * info->cpu_time / ProcData::get_instance()->frequency) },
+        { N_("Started"), procman_format_date_for_display(info->start_time) },
+        { N_("Nice"), g_strdup_printf("%d", info->nice)},
+        { N_("Priority"), g_strdup_printf("%s", procman::get_nice_level(info->nice)) },
+        { N_("ID"), g_strdup_printf("%d", info->pid)},
+        { N_("Security Context"), info->security_context ? g_strdup_printf("%s", info->security_context) : g_strdup(_("N/A"))},
+        { N_("Command Line"), g_strdup_printf("%s", info->arguments)},
+        { N_("Waiting Channel"), g_strdup_printf("%s", info->wchan)},
+        { N_("Control Group"), info->cgroup_name ? g_strdup_printf("%s", info->cgroup_name) : g_strdup(_("N/A"))},
+        { NULL, NULL}
+    };
+
+    store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
+    for (i = 0; proc_props[i].prop; i++) {
+        GtkTreeIter iter;
+
+        if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL(store), &iter, NULL, i)) {
+            gtk_list_store_append(store, &iter);
+            gtk_list_store_set(store, &iter, COL_PROP, _(proc_props[i].prop), -1);
+        }
+
+        gtk_list_store_set(store, &iter, COL_VAL, g_strstrip(proc_props[i].val), -1);
+        g_free(proc_props[i].val);
+    }
+}
+
+static void
+update_procproperties_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    fill_proc_properties(tree, info);
+}
+
+static void
+close_procprop_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    guint timer;
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static GtkWidget *
+create_procproperties_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    model = gtk_list_store_new (NUM_COLS,
+                                G_TYPE_STRING,	/* Property */
+                                G_TYPE_STRING	/* Value */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_COLS; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        column = gtk_tree_view_column_new_with_attributes (NULL,
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tree), FALSE);
+    fill_proc_properties(tree, procdata->selected_process);
+
+    return tree;
+}
+
+static gboolean
+procprop_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_procproperties_dialog (tree);
+
+    return TRUE;
+}
+
+static void
+create_single_procproperties_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                     GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *procpropdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    procpropdialog = gtk_dialog_new_with_buttons (_("Process Properties"), NULL,
+                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                  "gtk-close", GTK_RESPONSE_CLOSE,
+                                                  NULL);
+    gtk_window_set_resizable (GTK_WINDOW (procpropdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (procpropdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (procpropdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (procpropdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("Properties of process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_procproperties_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (procpropdialog), "response",
+                      G_CALLBACK (close_procprop_dialog), tree);
+
+    gtk_widget_show_all (procpropdialog);
+
+    timer = g_timeout_add_seconds (5, procprop_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_procproperties_dialog (tree);
+}
+
+void
+create_procproperties_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_procproperties_dialog,
+                                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/17.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/17.html new file mode 100644 index 00000000..3ce08395 --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/17.html @@ -0,0 +1,2635 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
/* Procman tree view and process updating
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <cairo-gobject.h>
+#include <string.h>
+#include <math.h>
+#include <glib/gi18n.h>
+#include <glib/gprintf.h>
+#include <glibtop.h>
+#include <glibtop/loadavg.h>
+#include <glibtop/proclist.h>
+#include <glibtop/procio.h>
+#include <glibtop/procstate.h>
+#include <glibtop/procmem.h>
+#include <glibtop/procmap.h>
+#include <glibtop/proctime.h>
+#include <glibtop/procuid.h>
+#include <glibtop/procargs.h>
+#include <glibtop/prockernel.h>
+#include <glibtop/mem.h>
+#include <glibtop/swap.h>
+#include <sys/stat.h>
+#include <pwd.h>
+#include <time.h>
+
+#include <set>
+#include <list>
+
+#ifdef HAVE_SYSTEMD
+#include <systemd/sd-login.h>
+#endif
+
+#include "procman.h"
+#include "selection.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "util.h"
+#include "interface.h"
+#include "selinux.h"
+#include "cgroups.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
+ProcInfo::UserMap ProcInfo::users;
+ProcInfo::List ProcInfo::all;
+std::map<pid_t, guint64> ProcInfo::cpu_times;
+
+
+ProcInfo* ProcInfo::find(pid_t pid)
+{
+    Iterator it(ProcInfo::all.find(pid));
+    return (it == ProcInfo::all.end() ? NULL : it->second);
+}
+
+void
+get_last_selected (GtkTreeModel *model, GtkTreePath *path,
+           GtkTreeIter *iter, gpointer data)
+{
+    ProcInfo **info = static_cast<ProcInfo**>(data);
+
+    gtk_tree_model_get (model, iter, COL_POINTER, info, -1);
+}
+
+static void
+cb_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "proctree");
+}
+
+static void
+cb_sort_changed (GtkTreeSortable *model, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state (procdata->settings,
+                             GTK_WIDGET (procdata->tree),
+                             "proctree");
+}
+
+
+static GtkTreeViewColumn*
+my_gtk_tree_view_get_column_with_sort_column_id(GtkTreeView *treeview, int id)
+{
+    GList *columns, *it;
+    GtkTreeViewColumn *col = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(it = columns; it; it = it->next)
+    {
+        if(gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(it->data)) == id)
+        {
+            col = static_cast<GtkTreeViewColumn*>(it->data);
+            break;
+        }
+    }
+
+    g_list_free(columns);
+
+    return col;
+}
+
+
+void
+proctable_set_columns_order(GtkTreeView *treeview, GSList *order)
+{
+    GtkTreeViewColumn* last = NULL;
+    GSList *it;
+
+    for(it = order; it; it = it->next)
+    {
+        int id;
+        GtkTreeViewColumn *cur;
+
+        id = GPOINTER_TO_INT(it->data);
+
+        cur = my_gtk_tree_view_get_column_with_sort_column_id(treeview, id);
+
+        if(cur && cur != last)
+        {
+            gtk_tree_view_move_column_after(treeview, cur, last);
+            last = cur;
+        }
+    }
+}
+
+
+GSList*
+proctable_get_columns_order(GtkTreeView *treeview)
+{
+    GList *columns, *col;
+    GSList *order = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(col = columns; col; col = col->next)
+    {
+        int id;
+
+        id = gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(col->data));
+        order = g_slist_prepend(order, GINT_TO_POINTER(id));
+    }
+
+    g_list_free(columns);
+
+    order = g_slist_reverse(order);
+
+    return order;
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "proctree");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_proctable_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+static gboolean
+search_equal_func(GtkTreeModel *model,
+                  gint column,
+                  const gchar *key,
+                  GtkTreeIter *iter,
+                  gpointer search_data)
+{
+    char* name;
+    char* user;
+    gboolean found;
+
+    gtk_tree_model_get(model, iter,
+                       COL_NAME, &name,
+                       COL_USER, &user,
+                       -1);
+
+    found = !((name && strcasestr(name, key))
+              || (user && strcasestr(user, key)));
+
+    g_free(name);
+    g_free(user);
+
+    return found;
+}
+
+
+
+GtkWidget *
+proctable_new (ProcData * const procdata)
+{
+    GtkWidget *proctree;
+    GtkTreeStore *model;
+    GtkTreeSelection *selection;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell_renderer;
+
+    const gchar *titles[] = {
+        N_("Process Name"),
+        N_("User"),
+        N_("Status"),
+        N_("Virtual Memory"),
+        N_("Resident Memory"),
+        N_("Writable Memory"),
+        N_("Shared Memory"),
+        N_("X Server Memory"),
+        /* xgettext:no-c-format */ N_("% CPU"),
+        N_("CPU Time"),
+        N_("Started"),
+        N_("Nice"),
+        N_("ID"),
+        N_("Security Context"),
+        N_("Command Line"),
+        N_("Memory"),
+        /* xgettext: combined noun, the function the process is waiting in, see wchan ps(1) */
+        N_("Waiting Channel"),
+        N_("Control Group"),
+        N_("Unit"),
+        N_("Session"),
+        /* TRANSLATORS: Seat = i.e. the physical seat the session of the process belongs to, only
+	for multi-seat environments. See http://en.wikipedia.org/wiki/Multiseat_configuration */
+        N_("Seat"),
+        N_("Owner"),
+        N_("Disk Read Total"),
+        N_("Disk Write Total"),
+        N_("Disk Read"),
+        N_("Disk Write"),
+        N_("Priority"),
+        NULL,
+        "POINTER"
+    };
+
+    gint i;
+
+    model = gtk_tree_store_new (NUM_COLUMNS,
+                                G_TYPE_STRING,              /* Process Name */
+                                G_TYPE_STRING,              /* User         */
+                                G_TYPE_UINT,                /* Status       */
+                                G_TYPE_ULONG,               /* VM Size      */
+                                G_TYPE_ULONG,               /* Resident Memory */
+                                G_TYPE_ULONG,               /* Writable Memory */
+                                G_TYPE_ULONG,               /* Shared Memory */
+                                G_TYPE_ULONG,               /* X Server Memory */
+                                G_TYPE_UINT,                /* % CPU        */
+                                G_TYPE_UINT64,              /* CPU time     */
+                                G_TYPE_ULONG,               /* Started      */
+                                G_TYPE_INT,                 /* Nice         */
+                                G_TYPE_UINT,                /* ID           */
+                                G_TYPE_STRING,              /* Security Context */
+                                G_TYPE_STRING,              /* Arguments    */
+                                G_TYPE_ULONG,               /* Memory       */
+                                G_TYPE_STRING,              /* wchan        */
+                                G_TYPE_STRING,              /* Cgroup       */
+                                G_TYPE_STRING,              /* Unit         */
+                                G_TYPE_STRING,              /* Session      */
+                                G_TYPE_STRING,              /* Seat         */
+                                G_TYPE_STRING,              /* Owner        */
+                                G_TYPE_UINT64,              /* Disk read total */
+                                G_TYPE_UINT64,              /* Disk write total*/
+                                G_TYPE_UINT64,              /* Disk read    */
+                                G_TYPE_UINT64,              /* Disk write   */
+                                G_TYPE_STRING,              /* Priority     */
+                                CAIRO_GOBJECT_TYPE_SURFACE, /* Icon         */
+                                G_TYPE_POINTER,             /* ProcInfo     */
+                                G_TYPE_STRING               /* Sexy tooltip */
+        );
+
+    proctree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (proctree), COL_TOOLTIP);
+    g_object_set(G_OBJECT(proctree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+    gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (proctree),
+                                         search_equal_func,
+                                         NULL,
+                                         NULL);
+    g_object_unref (G_OBJECT (model));
+
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree));
+    gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+
+    column = gtk_tree_view_column_new ();
+
+    cell_renderer = gtk_cell_renderer_pixbuf_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "surface", COL_SURFACE,
+                                         NULL);
+
+    cell_renderer = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "text", COL_NAME,
+                                         NULL);
+    gtk_tree_view_column_set_title (column, _(titles[0]));
+    gtk_tree_view_column_set_sort_column_id (column, COL_NAME);
+    gtk_tree_view_column_set_resizable (column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+    gtk_tree_view_column_set_min_width (column, 20);
+    gtk_tree_view_column_set_reorderable (column, TRUE);
+    g_signal_connect(G_OBJECT(column), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (proctree), column);
+    gtk_tree_view_set_expander_column (GTK_TREE_VIEW (proctree), column);
+
+
+    for (i = COL_USER; i <= COL_PRIORITY; i++) {
+
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+#ifndef HAVE_WNCK
+        if (i == COL_MEMXSERVER) {
+          continue;
+        }
+#endif
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(proctree), col);
+
+        // type
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_CPU_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::duration_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_START_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::time_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_STATUS:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::status_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::io_rate_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_PRIORITY:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::priority_cell_data_func,
+                                                        GUINT_TO_POINTER(COL_NICE),
+                                                        NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+        }
+
+        // sorting
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+            case COL_CPU:
+            case COL_CPU_TIME:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_START_TIME:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::number_compare_func, GUINT_TO_POINTER(i),
+                                                NULL);
+                break;
+            case COL_PRIORITY:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::priority_compare_func,
+                                                GUINT_TO_POINTER(COL_NICE), NULL);
+                break;
+            default:
+                break;
+        }
+
+        // xalign
+        switch(i)
+        {
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMWRITABLE:
+            case COL_MEMSHARED:
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_CPU:
+            case COL_NICE:
+            case COL_PID:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_CPU_TIME:
+            case COL_MEM:
+                g_object_set(G_OBJECT(cell), "xalign", 1.0f, NULL);
+                break;
+        }
+
+        // sizing
+        switch (i) {
+            case COL_ARGS:
+                gtk_tree_view_column_set_min_width(col, 150);
+                break;
+            default:
+                gtk_tree_view_column_set_min_width(col, 20);
+                break;
+        }
+    }
+
+    procdata->tree = proctree;
+
+    procman_get_tree_state (procdata->settings, proctree, "proctree");
+
+    /* Override column settings by hiding this column if it's meaningless: */
+    if (!can_show_security_context_column ()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id (GTK_TREE_VIEW (proctree), COL_SECURITYCONTEXT);
+        gtk_tree_view_column_set_visible (column, FALSE);
+    }
+
+    if (!cgroups_enabled()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), COL_CGROUP);
+        gtk_tree_view_column_set_visible(column, FALSE);
+    }
+
+#ifdef HAVE_SYSTEMD
+    if (!LOGIND_RUNNING())
+#endif
+    {
+        for (i = COL_UNIT; i <= COL_OWNER; i++) {
+            column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), i);
+            gtk_tree_view_column_set_visible(column, FALSE);
+        }
+    }
+
+    g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree))),
+                      "changed",
+                      G_CALLBACK (cb_row_selected), procdata);
+    g_signal_connect (G_OBJECT (proctree), "popup_menu",
+                      G_CALLBACK (cb_tree_popup_menu), procdata);
+    g_signal_connect (G_OBJECT (proctree), "button_press_event",
+                      G_CALLBACK (cb_tree_button_pressed), procdata);
+
+    g_signal_connect (G_OBJECT(proctree), "columns-changed",
+                      G_CALLBACK(cb_columns_changed), procdata);
+
+    g_signal_connect (G_OBJECT (model), "sort-column-changed",
+                      G_CALLBACK (cb_sort_changed), procdata);
+
+    return proctree;
+}
+
+
+ProcInfo::~ProcInfo()
+{
+    g_free(this->name);
+    g_free(this->tooltip);
+    g_free(this->arguments);
+    g_free(this->security_context);
+    g_free(this->cgroup_name);
+    g_free(this->unit);
+    g_free(this->session);
+    g_free(this->seat);
+    cairo_surface_destroy(this->surface);
+}
+
+
+static void
+get_process_name (ProcInfo *info,
+                  const gchar *cmd, const GStrv args)
+{
+    if (args) {
+        // look for /usr/bin/very_long_name
+        // and also /usr/bin/interpreter /usr/.../very_long_name
+        // which may have use prctl to alter 'cmd' name
+        for (int i = 0; i != 2 && args[i]; ++i) {
+            char* basename;
+            basename = g_path_get_basename(args[i]);
+
+            if (g_str_has_prefix(basename, cmd)) {
+                info->name = basename;
+                return;
+            }
+
+            g_free(basename);
+        }
+    }
+
+    info->name = g_strdup (cmd);
+}
+
+std::string
+ProcInfo::lookup_user(guint uid)
+{
+    typedef std::pair<ProcInfo::UserMap::iterator, bool> Pair;
+    ProcInfo::UserMap::value_type hint(uid, "");
+    Pair p(ProcInfo::users.insert(hint));
+
+    // procman_debug("User lookup for uid %u: %s", uid, (p.second ? "MISS" : "HIT"));
+
+    if (p.second) {
+        struct passwd* pwd;
+        pwd = getpwuid(uid);
+
+        if (pwd && pwd->pw_name)
+            p.first->second = pwd->pw_name;
+        else {
+            char username[16];
+            g_sprintf(username, "%u", uid);
+            p.first->second = username;
+        }
+    }
+
+    return p.first->second;
+}
+
+void
+ProcInfo::set_user(guint uid)
+{
+    if (G_LIKELY(this->uid == uid))
+        return;
+
+    this->uid = uid;
+    this->user = lookup_user(uid);
+}
+
+static void get_process_memory_writable(ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info(ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+
+static void
+update_info_mutable_cols(ProcInfo *info)
+{
+    ProcData * const procdata = ProcData::get_instance();
+    GtkTreeModel *model;
+    model = gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->tree));
+
+    using procman::tree_store_update;
+
+    tree_store_update(model, &info->node, COL_STATUS, info->status);
+    tree_store_update(model, &info->node, COL_USER, info->user.c_str());
+    tree_store_update(model, &info->node, COL_VMSIZE, info->vmsize);
+    tree_store_update(model, &info->node, COL_MEMRES, info->memres);
+    tree_store_update(model, &info->node, COL_MEMWRITABLE, info->memwritable);
+    tree_store_update(model, &info->node, COL_MEMSHARED, info->memshared);
+#ifdef HAVE_WNCK
+    tree_store_update(model, &info->node, COL_MEMXSERVER, info->memxserver);
+#endif
+    tree_store_update(model, &info->node, COL_CPU, info->pcpu);
+    tree_store_update(model, &info->node, COL_CPU_TIME, info->cpu_time);
+    tree_store_update(model, &info->node, COL_DISK_READ_TOTAL, info->disk_read_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_TOTAL, info->disk_write_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_READ_CURRENT, info->disk_read_bytes_current);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_CURRENT, info->disk_write_bytes_current);
+    tree_store_update(model, &info->node, COL_START_TIME, info->start_time);
+    tree_store_update(model, &info->node, COL_NICE, info->nice);
+    tree_store_update(model, &info->node, COL_MEM, info->mem);
+    tree_store_update(model, &info->node, COL_WCHAN, info->wchan);
+    tree_store_update(model, &info->node, COL_CGROUP, info->cgroup_name);
+    tree_store_update(model, &info->node, COL_UNIT, info->unit);
+    tree_store_update(model, &info->node, COL_SESSION, info->session);
+    tree_store_update(model, &info->node, COL_SEAT, info->seat);
+    tree_store_update(model, &info->node, COL_OWNER, info->owner.c_str());
+}
+
+
+
+static void
+insert_info_to_tree (ProcInfo *info, ProcData *procdata, bool forced = false)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    if (procdata->config.show_tree) {
+
+        ProcInfo *parent = 0;
+
+        if (not forced)
+            parent = ProcInfo::find(info->ppid);
+
+        if (parent) {
+            GtkTreePath *parent_node = gtk_tree_model_get_path(model, &parent->node);
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, &parent->node, 0);
+
+            if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(procdata->tree), parent_node)
+#ifdef __linux__
+                // on linuxes we don't want to expand kthreadd by default (always has pid 2)
+                && (parent->pid != 2)
+#endif
+            )
+                gtk_tree_view_expand_row(GTK_TREE_VIEW(procdata->tree), parent_node, FALSE);
+            gtk_tree_path_free(parent_node);
+        } else
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, NULL, 0);
+    }
+    else
+        gtk_tree_store_insert (GTK_TREE_STORE (model), &info->node, NULL, 0);
+
+    gtk_tree_store_set (GTK_TREE_STORE (model), &info->node,
+                        COL_POINTER, info,
+                        COL_NAME, info->name,
+                        COL_ARGS, info->arguments,
+                        COL_TOOLTIP, info->tooltip,
+                        COL_PID, info->pid,
+                        COL_SECURITYCONTEXT, info->security_context,
+                        -1);
+
+    procdata->pretty_table.set_icon(*info);
+
+    procman_debug("inserted %d%s", info->pid, (forced ? " (forced)" : ""));
+}
+
+
+/* Removing a node with children - make sure the children are queued
+** to be readded.
+*/
+template<typename List>
+static void
+remove_info_from_tree (ProcData *procdata, GtkTreeModel *model,
+                       ProcInfo *current, List &orphans, unsigned lvl = 0)
+{
+    GtkTreeIter child_node;
+
+    if (std::find(orphans.begin(), orphans.end(), current) != orphans.end()) {
+        procman_debug("[%u] %d already removed from tree", lvl, int(current->pid));
+        return;
+    }
+
+    procman_debug("[%u] pid %d, %d children", lvl, int(current->pid),
+                  gtk_tree_model_iter_n_children(model, &current->node));
+
+    // it is not possible to iterate&erase over a treeview so instead we
+    // just pop one child after another and recursively remove it and
+    // its children
+
+    while (gtk_tree_model_iter_children(model, &child_node, &current->node)) {
+        ProcInfo *child = 0;
+        gtk_tree_model_get(model, &child_node, COL_POINTER, &child, -1);
+        remove_info_from_tree(procdata, model, child, orphans, lvl + 1);
+    }
+
+    g_assert(not gtk_tree_model_iter_has_child(model, &current->node));
+
+    if (procdata->selected_process == current)
+        procdata->selected_process = NULL;
+
+    orphans.push_back(current);
+    gtk_tree_store_remove(GTK_TREE_STORE(model), &current->node);
+    procman::poison(current->node, 0x69);
+}
+
+static void
+get_process_systemd_info(ProcInfo *info)
+{
+#ifdef HAVE_SYSTEMD
+    uid_t uid;
+
+    if (!LOGIND_RUNNING())
+        return;
+
+    free(info->unit);
+    info->unit = NULL;
+    sd_pid_get_unit(info->pid, &info->unit);
+
+    free(info->session);
+    info->session = NULL;
+    sd_pid_get_session(info->pid, &info->session);
+
+    free(info->seat);
+    info->seat = NULL;
+
+    if (info->session != NULL)
+        sd_session_get_seat(info->session, &info->seat);
+
+    if (sd_pid_get_owner_uid(info->pid, &uid) >= 0)
+        info->owner = info->lookup_user(uid);
+    else
+        info->owner = "";
+#endif
+}
+
+static void
+update_info (ProcData *procdata, ProcInfo *info)
+{
+    glibtop_proc_state procstate;
+    glibtop_proc_uid procuid;
+    glibtop_proc_time proctime;
+    glibtop_proc_kernel prockernel;
+    glibtop_proc_io procio;
+
+    glibtop_get_proc_kernel(&prockernel, info->pid);
+    g_strlcpy(info->wchan, prockernel.wchan, sizeof info->wchan);
+
+    glibtop_get_proc_state (&procstate, info->pid);
+    info->status = procstate.state;
+
+    glibtop_get_proc_uid (&procuid, info->pid);
+    glibtop_get_proc_time (&proctime, info->pid);
+    glibtop_get_proc_io (&procio, info->pid);
+
+    get_process_memory_info(info);
+
+    info->set_user(procstate.uid);
+
+    // if the cpu time has increased reset the status to running
+    // regardless of kernel state (https://bugzilla.gnome.org/606579)
+    guint64 difference = proctime.rtime - info->cpu_time;
+    if (difference > 0)
+        info->status = GLIBTOP_PROCESS_RUNNING;
+    info->pcpu = difference * 100 / procdata->cpu_total_time;
+    info->pcpu = MIN(info->pcpu, 100);
+
+    if (not procdata->config.solaris_mode)
+      info->pcpu *= procdata->config.num_cpus;
+
+    ProcInfo::cpu_times[info->pid] = info->cpu_time = proctime.rtime;
+    info->nice = procuid.nice;
+
+    gdouble update_interval_seconds = procdata->config.update_interval / 1000.0;
+    difference = procio.disk_wbytes - info->disk_write_bytes_total;
+    info->disk_write_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+    difference = procio.disk_rbytes - info->disk_read_bytes_total;
+    info->disk_read_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+
+    info->disk_write_bytes_total = procio.disk_wbytes;
+    info->disk_read_bytes_total = procio.disk_rbytes;
+
+    // set the ppid only if one can exist
+    // i.e. pid=0 can never have a parent
+    if (info->pid > 0) {
+        info->ppid = procuid.ppid;
+    }
+
+    g_assert(info->pid != info->ppid);
+    g_assert(info->ppid != -1 || info->pid == 0);
+
+    /* get cgroup data */
+    get_process_cgroup_info(info);
+
+    get_process_systemd_info(info);
+}
+
+
+ProcInfo::ProcInfo(pid_t pid)
+    : node(),
+      surface(),
+      tooltip(NULL),
+      name(NULL),
+      arguments(NULL),
+      security_context(NULL),
+      pid(pid),
+      ppid(-1),
+      uid(-1)
+{
+    ProcInfo * const info = this;
+    glibtop_proc_state procstate;
+    glibtop_proc_time proctime;
+    glibtop_proc_args procargs;
+    gchar** arguments;<--- Shadow variable
+
+    glibtop_get_proc_state (&procstate, pid);
+    glibtop_get_proc_time (&proctime, pid);
+    arguments = glibtop_get_proc_argv (&procargs, pid, 0);
+
+    /* FIXME : wrong. name and arguments may change with exec* */
+    get_process_name (info, procstate.cmd, static_cast<const GStrv>(arguments));
+
+    std::string tooltip = make_string(g_strjoinv(" ", arguments));<--- Shadow variable
+    if (tooltip.empty())
+        tooltip = procstate.cmd;
+
+    info->tooltip = g_markup_escape_text(tooltip.c_str(), -1);
+
+    info->arguments = g_strescape(tooltip.c_str(), "\\\"");
+    g_strfreev(arguments);
+
+    guint64 cpu_time = proctime.rtime;
+    std::map<pid_t, guint64>::iterator it(ProcInfo::cpu_times.find(pid));
+    if (it != ProcInfo::cpu_times.end())
+    {
+        if (proctime.rtime >= it->second)
+          cpu_time = it->second;
+    }
+    info->cpu_time = cpu_time;
+    info->start_time = proctime.start_time;
+
+    get_process_selinux_context (info);
+    info->cgroup_name = NULL;
+    get_process_cgroup_info(info);
+
+    info->unit = info->session = info->seat = NULL;
+    get_process_systemd_info(info);
+}
+
+static void
+refresh_list (ProcData *procdata, const pid_t* pid_list, const guint n)
+{
+    typedef std::list<ProcInfo*> ProcList;
+    ProcList addition;
+
+    GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+    guint i;
+
+    // Add or update processes in the process list
+    for(i = 0; i < n; ++i) {
+        ProcInfo *info = ProcInfo::find(pid_list[i]);
+
+        if (!info) {
+            info = new ProcInfo(pid_list[i]);
+            ProcInfo::all[info->pid] = info;
+            addition.push_back(info);
+        }
+
+        update_info (procdata, info);
+    }
+
+
+    // Remove dead processes from the process list and from the
+    // tree. children are queued to be readded at the right place
+    // in the tree.
+
+    const std::set<pid_t> pids(pid_list, pid_list + n);
+
+    ProcInfo::Iterator it(ProcInfo::begin());<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration
+
+    while (it != ProcInfo::end()) {
+        ProcInfo * const info = it->second;
+        ProcInfo::Iterator next(it);
+        ++next;
+
+        if (pids.find(info->pid) == pids.end()) {
+            procman_debug("ripping %d", info->pid);
+            remove_info_from_tree(procdata, model, info, addition);
+            addition.remove(info);
+            ProcInfo::all.erase(it);
+            delete info;
+        }
+
+        it = next;
+    }
+
+    // INVARIANT
+    // pid_list == ProcInfo::all + addition
+
+
+    if (procdata->config.show_tree) {
+
+        // insert process in the tree. walk through the addition list
+        // (new process + process that have a new parent). This loop
+        // handles the dependencies because we cannot insert a process
+        // until its parent is in the tree.
+
+        std::set<pid_t> in_tree(pids);
+
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            in_tree.erase((*it)->pid);
+
+
+        while (not addition.empty()) {
+            procman_debug("looking for %d parents", int(addition.size()));
+            ProcList::iterator it(addition.begin());<--- Shadow variable
+
+            while (it != addition.end()) {
+                procman_debug("looking for %d's parent with ppid %d",
+                              int((*it)->pid), int((*it)->ppid));
+
+
+                // inserts the process in the treeview if :
+                // - it has no parent (ppid = -1),
+                //   ie it is for example the [kernel] on FreeBSD
+                // - it is init
+                // - its parent is already in tree
+                // - its parent is unreachable
+                //
+                // rounds == 2 means that addition contains processes with
+                // unreachable parents
+                //
+                // FIXME: this is broken if the unreachable parent becomes active
+                // i.e. it gets active or changes ower
+                // so we just clear the tree on __each__ update
+                // see proctable_update_list (ProcData * const procdata)
+
+
+                if ((*it)->ppid <= 0 or in_tree.find((*it)->ppid) != in_tree.end()) {
+                    insert_info_to_tree(*it, procdata);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ProcInfo *parent = ProcInfo::find((*it)->ppid);
+                // if the parent is unreachable
+                if (not parent) {
+                    // or std::find(addition.begin(), addition.end(), parent) == addition.end()) {
+                    insert_info_to_tree(*it, procdata, true);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ++it;
+            }
+        }
+    }
+    else {
+        // don't care of the tree
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            insert_info_to_tree(*it, procdata);
+    }
+
+
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)<--- Shadow variable
+        update_info_mutable_cols(it->second);
+}
+
+
+static void
+proctable_update_list (ProcData * const procdata)
+{
+    pid_t* pid_list;
+    glibtop_proclist proclist;
+    glibtop_cpu cpu;
+    gint which, arg;
+    procman::SelectionMemento selection;
+
+    switch (procdata->config.whose_process) {
+        case ALL_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL;
+            arg = 0;
+            break;
+
+        case ACTIVE_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL | GLIBTOP_EXCLUDE_IDLE;
+            arg = 0;
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+
+        default:
+            which = GLIBTOP_KERN_PROC_UID;
+            arg = getuid ();
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+    }
+
+    pid_list = glibtop_get_proclist (&proclist, which, arg);
+
+    /* FIXME: total cpu time elapsed should be calculated on an individual basis here
+    ** should probably have a total_time_last gint in the ProcInfo structure */
+    glibtop_get_cpu (&cpu);
+    procdata->cpu_total_time = MAX(cpu.total - procdata->cpu_total_time_last, 1);
+    procdata->cpu_total_time_last = cpu.total;
+
+    // FIXME: not sure if glibtop always returns a sorted list of pid
+    // but it is important otherwise refresh_list won't find the parent
+    std::sort(pid_list, pid_list + proclist.number);
+
+    refresh_list (procdata, pid_list, proclist.number);
+
+    selection.restore(procdata->tree);
+
+    g_free (pid_list);
+
+    /* proclist.number == g_list_length(procdata->info) == g_hash_table_size(procdata->pids) */
+}
+
+
+void
+proctable_update (ProcData * const procdata)
+{
+    char* string;
+
+    string = make_loadavg_string();
+    gtk_label_set_text (GTK_LABEL(procdata->loadavg), string);
+    g_free (string);
+
+    proctable_update_list (procdata);
+}
+
+
+void
+proctable_free_table (ProcData * const procdata)
+{
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)
+        delete it->second;
+
+    ProcInfo::all.clear();
+}
+
+
+void
+proctable_clear_tree (ProcData * const procdata)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    gtk_tree_store_clear (GTK_TREE_STORE (model));
+
+    proctable_free_table (procdata);
+
+    update_sensitivity(procdata);
+}
+
+
+char*
+make_loadavg_string(void)
+{
+    glibtop_loadavg buf;
+
+    glibtop_get_loadavg(&buf);
+
+    return g_strdup_printf(
+        _("Load averages for the last 1, 5, 15 minutes: "
+          "%0.2f, %0.2f, %0.2f"),
+        buf.loadavg[0],
+        buf.loadavg[1],
+        buf.loadavg[2]);
+}
+
+
+
+void
+ProcInfo::set_icon(Glib::RefPtr<Gdk::Pixbuf> icon)
+{
+  this->surface = gdk_cairo_surface_create_from_pixbuf (icon->gobj(), 0, NULL);
+
+  GtkTreeModel *model;
+  model = gtk_tree_view_get_model(GTK_TREE_VIEW(ProcData::get_instance()->tree));
+  gtk_tree_store_set(GTK_TREE_STORE(model), &this->node,
+                     COL_SURFACE, this->surface,
+                    -1);
+}
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/18.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/18.html new file mode 100644 index 00000000..4e691255 --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/18.html @@ -0,0 +1,405 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
#include <config.h>
+
+#include <glib.h>
+
+#include "selinux.h"
+#include "procman.h"
+#include "util.h"
+
+
+static int (*getpidcon)(pid_t, char**);
+static void (*freecon)(char*);
+static int (*is_selinux_enabled)(void);
+
+static gboolean has_selinux;
+
+static gboolean load_selinux(void)
+{
+    return load_symbols("libselinux.so.1",
+                        "getpidcon", &getpidcon,
+                        "freecon", &freecon,
+                        "is_selinux_enabled", &is_selinux_enabled,
+                        NULL);
+}
+
+
+
+void
+get_process_selinux_context (ProcInfo *info)
+{
+    char *con;
+
+    if (has_selinux && !getpidcon (info->pid, &con)) {
+        info->security_context = g_strdup (con);
+        freecon (con);
+    }
+}
+
+
+
+gboolean
+can_show_security_context_column (void)
+{
+    if (!(has_selinux = load_selinux()))
+        return FALSE;
+
+    switch (is_selinux_enabled()) {
+        case 1:
+            /* We're running on an SELinux kernel */
+            return TRUE;
+
+        case -1:
+            /* Error; hide the security context column */
+
+        case 0:
+            /* We're not running on an SELinux kernel:
+               hide the security context column */
+
+        default:
+            g_warning("SELinux was found but is not enabled.\n");
+            return FALSE;
+    }
+}
+
+
+
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/19.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/19.html new file mode 100644 index 00000000..913bbae3 --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/19.html @@ -0,0 +1,2359 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
#include <config.h>
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <glibmm.h>
+#include <glib/gi18n.h>
+
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+
+#include <glibtop/fsusage.h>
+#include <glibtop/mountlist.h>
+#include <glibtop/mem.h>
+#include <glibtop/sysinfo.h>
+
+#include <unistd.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#include <math.h>
+#include <errno.h>
+
+#include <exception>
+#include <string>
+#include <vector>
+#include <fstream>
+#include <sstream>
+#include <sys/utsname.h>
+
+#include "sysinfo.h"
+#include "procman.h"
+#include "util.h"
+
+
+using std::string;
+using std::vector;
+
+
+namespace {
+
+    class SysInfo
+    {
+    public:
+        string hostname;
+        string distro_name;
+        string distro_release;
+        string kernel;
+        string mate_version;
+        guint64 memory_bytes;
+        guint64 free_space_bytes;
+
+        string graphics;
+        string processors;
+
+        SysInfo()
+        {
+            this->load_processors_info();
+            this->load_graphics_info();
+            this->load_memory_info();
+            this->load_disk_info();
+            this->load_uname_info();
+            this->load_mate_version();
+        }
+
+        virtual ~SysInfo()
+        { }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Virtual function in base class
+        {
+            g_object_set(G_OBJECT(name),
+                        "label",
+                        ("<big><big><b>" + this->distro_name + "</b></big></big>").c_str(),
+                        NULL);
+
+            char* markup;
+#ifdef __linux__
+            if (this->distro_release != "")
+            {
+                /* Translators: The first string parameter is release version (codename),
+                 * the second one is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("Release %s %s"),
+                                         this->distro_release.c_str(),
+                                         SysInfo::get_os_type().c_str());
+            }
+            else
+            {
+                /* Translators: The string parameter is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("%s Version"),
+                                         SysInfo::get_os_type().c_str());
+            }
+#else
+            /* Translators: The string parameter is release version (codename) */
+            markup = g_strdup_printf(_("Release %s"),
+                                     this->distro_release.c_str());
+#endif
+
+            g_object_set(G_OBJECT(release),
+                         "label",
+                         markup,
+                         NULL);
+
+            g_free(markup);
+        }
+
+        static string release()
+        {
+            return uname().release;
+        }
+
+        static string system()
+        {
+            return uname().sysname;
+        }
+
+    private:
+
+        void load_memory_info()
+        {
+            glibtop_mem mem;
+
+            glibtop_get_mem(&mem);
+            this->memory_bytes = mem.total;
+        }
+
+        static string get_os_type ()<--- Unused private function: 'SysInfo::get_os_type'
+        {
+            int bits;
+
+            if (GLIB_SIZEOF_VOID_P == 8)
+                bits = 64;
+            else
+                bits = 32;
+
+            /* translators: This is the type of architecture, for example:
+             * "64-bit" or "32-bit" */
+            char* bytes = g_strdup_printf (_("%d-bit"), bits);
+            string retval(bytes);
+            g_free(bytes);
+            return retval;
+        }
+
+        typedef struct
+        {
+            const char* regex;
+            const char* replacement;
+        } ReplaceStrings;
+
+        static char* remove_duplicate_whitespace (const char* old)
+        {
+            char* result;
+            GRegex* re;
+            GError* error = NULL;
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+
+            re = g_regex_new ("[ \t\n\r]+", G_REGEX_MULTILINE, flags, &error);
+            if (re == NULL) {
+                g_warning ("Error building regex: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+            result = g_regex_replace (re, old, -1, 0, " ", flags, &error);
+            g_regex_unref (re);
+            if (result == NULL) {
+                g_warning ("Error replacing string: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+
+            return result;
+        }
+
+        static char* prettify_info (const char *info)
+        {
+            char* pretty;
+            const GRegexCompileFlags cflags = static_cast<GRegexCompileFlags>(0);
+            const GRegexMatchFlags mflags = static_cast<GRegexMatchFlags>(0);
+
+            static const ReplaceStrings rs[] = {
+                { "Intel[(]R[)]", "Intel\302\256"},
+                { "Core[(]TM[)]", "Core\342\204\242"},
+                { "Atom[(]TM[)]", "Atom\342\204\242"},
+            };
+
+            pretty = g_markup_escape_text (info, -1);
+
+            for (uint i = 0; i < G_N_ELEMENTS (rs); i++) {
+                GError* error;
+                GRegex* re;
+                char* result;
+
+                error = NULL;
+
+                re = g_regex_new (rs[i].regex, cflags, mflags, &error);
+                if (re == NULL) {
+                    g_warning ("Error building regex: %s", error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                result = g_regex_replace_literal (re, pretty, -1, 0,
+                                             rs[i].replacement, mflags, &error);
+
+                g_regex_unref (re);
+
+                if (error != NULL) {
+                    g_warning ("Error replacing %s: %s", rs[i].regex, error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                g_free (pretty);
+                pretty = result;
+            }
+
+            return pretty;
+        }
+
+        static char* get_renderer_from_helper (gboolean discrete_gpu)
+        {
+            int status;
+            const char *argv[] = { LIBEXECDIR "/mate-session-check-accelerated", NULL };
+            g_auto(GStrv) envp = NULL;
+            g_autofree char *renderer = NULL;
+            g_autoptr(GError) error = NULL;
+
+            if (discrete_gpu)
+            {
+                envp = g_get_environ ();
+                envp = g_environ_setenv (envp, "DRI_PRIME", "1", TRUE);
+            }
+
+            if (!g_spawn_sync (NULL, (char **) argv, envp, G_SPAWN_DEFAULT, NULL, NULL, &renderer, NULL, &status, &error))
+            {
+                g_debug ("Failed to get %s GPU: %s",
+                         discrete_gpu ? "discrete" : "integrated",
+                         error->message);
+                return NULL;
+            }
+
+            if (!g_spawn_check_exit_status (status, NULL))
+                return NULL;
+
+            if (renderer == NULL || *renderer == '\0')
+                return NULL;
+
+            return prettify_info (renderer);
+        }
+
+
+        void load_graphics_info()
+        {
+            g_autofree char *renderer = NULL;
+
+            try
+            {
+                g_autoptr(GDBusProxy) session_proxy = NULL;
+                g_autoptr(GVariant) renderer_variant = NULL;
+                g_autoptr(GError) error = NULL;
+
+                session_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                               G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL,
+                                                               "org.gnome.SessionManager",
+                                                               "/org/gnome/SessionManager",
+                                                               "org.gnome.SessionManager",
+                                                               NULL, &error);
+                if (error != NULL)
+                {
+                    throw std::runtime_error ("Unable to connect to create a proxy for org.gnome.SessionManager");
+                }
+
+                renderer_variant = g_dbus_proxy_get_cached_property (session_proxy, "Renderer");
+                if (!renderer_variant)
+                {
+                    throw std::runtime_error ("Unable to retrieve org.gnome.SessionManager.Renderer property.");
+                }
+
+                renderer = prettify_info (g_variant_get_string (renderer_variant, NULL));
+            }
+            catch (std::exception& e)
+            {
+                g_warning ("%s", e.what());
+            }
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (FALSE);
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (TRUE);
+
+            if (renderer)
+            {
+                this->graphics = g_strdup (renderer);
+            }
+            else
+            {
+                this->graphics = _("Unknown");
+            }
+        }
+
+        void load_processors_info()
+        {
+            const glibtop_sysinfo *info = glibtop_get_sysinfo();
+
+            GHashTable* counts;
+            GString* cpu;
+            GHashTableIter iter;
+            gpointer key, value;
+
+            counts = g_hash_table_new (g_str_hash, g_str_equal);
+
+            /* count duplicates */
+            for (uint i = 0; i != info->ncpu; ++i) {
+                const char* const keys[] = { "model name", "cpu", "Processor" };
+                char* model;
+                int* count;
+
+                model = NULL;
+
+                for (int j = 0; model == NULL && j != G_N_ELEMENTS (keys); ++j) {
+                    model = static_cast<char*>(g_hash_table_lookup (info->cpuinfo[i].values,
+                                                 keys[j]));
+                }
+
+                if (model == NULL)
+                    continue;
+
+                count = static_cast<int*>(g_hash_table_lookup (counts, model));
+                if (count == NULL)
+                    g_hash_table_insert (counts, model, GINT_TO_POINTER (1));
+                else
+                    g_hash_table_replace (counts, model, GINT_TO_POINTER (GPOINTER_TO_INT (count) + 1));
+            }
+
+            cpu = g_string_new (NULL);
+            g_hash_table_iter_init (&iter, counts);
+            while (g_hash_table_iter_next (&iter, &key, &value)) {
+                char* stripped;
+                int   count;
+
+                count = GPOINTER_TO_INT (value);
+                stripped = remove_duplicate_whitespace ((const char *)key);
+                if (count > 1)
+                    g_string_append_printf (cpu, "%s \303\227 %d ", stripped, count);
+                else
+                    g_string_append_printf (cpu, "%s ", stripped);
+                g_free (stripped);
+            }
+
+            g_hash_table_destroy (counts);
+            this->processors = string(prettify_info (cpu->str));
+            g_string_free (cpu, TRUE);
+        }
+
+        void load_disk_info()
+        {
+            GHashTable *devices;
+            glibtop_mountentry *entries;
+            glibtop_mountlist mountlist;
+
+            entries = glibtop_get_mountlist(&mountlist, 0);
+            devices = g_hash_table_new(g_str_hash, g_str_equal);
+            this->free_space_bytes = 0;
+
+            for (guint i = 0; i != mountlist.number; ++i) {
+                if ((string(entries[i].mountdir).compare("/") == 0) && \
+                    (string(entries[i].type).compare("zfs") == 0)) {
+                    // Root filesystem is ZFS based: Calculate usage based on "/".
+                    glibtop_fsusage usage;
+                    glibtop_get_fsusage(&usage, "/");
+                    this->free_space_bytes = usage.bavail * usage.block_size;
+                    break;
+                }
+
+                if (string(entries[i].devname).find("/dev/") != 0)
+                    continue;
+
+                if (string(entries[i].mountdir).find("/media/") == 0)
+                    continue;
+
+                /* avoid adding a device more than once such as for btrfs filesystem */
+                if (g_hash_table_contains (devices, entries[i].devname))
+                    continue;
+                else
+                    g_hash_table_insert (devices, entries[i].devname, entries[i].mountdir);
+
+                glibtop_fsusage usage;
+                glibtop_get_fsusage(&usage, entries[i].mountdir);
+                this->free_space_bytes += usage.bavail * usage.block_size;
+            }
+
+            g_hash_table_destroy (devices);
+            g_free(entries);
+        }
+
+        static const struct utsname & uname()
+        {
+            static struct utsname name;
+
+            if (!name.sysname[0]) {
+                ::uname(&name);
+            }
+
+            return name;
+        }
+
+        void load_uname_info()
+        {
+            this->hostname = uname().nodename;
+#if defined(__linux__)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().machine;
+#elif defined(__sun) && defined(__SVR4)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().version + ' ' + uname().machine;
+#else
+            this->kernel = string(uname().version) + ' ' + uname().machine;
+#endif
+        }
+
+
+        void load_mate_version()
+        {
+            xmlDocPtr document;
+            xmlXPathContextPtr context;
+            const string nodes[3] = { "string(/mate-version/platform)",
+                                      "string(/mate-version/minor)",
+                                      "string(/mate-version/micro)" };
+            string values[3];
+
+            if (not (document = xmlParseFile(DATADIR "/mate-about/mate-version.xml")))
+                return;
+
+            if (not (context = xmlXPathNewContext(document)))
+                return;
+
+            for (size_t i = 0; i != 3; ++i)
+            {
+                xmlXPathObjectPtr xpath;
+                xpath = xmlXPathEvalExpression(BAD_CAST nodes[i].c_str(), context);
+
+                if (xpath and xpath->type == XPATH_STRING)
+                    values[i] = reinterpret_cast<const char*>(xpath->stringval);
+
+                xmlXPathFreeObject(xpath);
+            }
+
+            xmlXPathFreeContext(context);
+            xmlFreeDoc(document);
+
+            if (!values[0].empty() && !values[1].empty() && !values[2].empty())
+                this->mate_version = values[0] + '.' + values[1] + '.' + values[2];
+        }
+    };
+
+    class FreeBSDSysInfo
+        : public SysInfo
+    {
+    public:
+	FreeBSDSysInfo()
+        {
+            this->load_freebsd_info();
+        }
+
+    private:
+        void load_freebsd_info()
+        {
+            this->distro_name = "FreeBSD";
+            this->distro_release = release();
+        }
+    };
+
+    class SolarisSysInfo
+        : public SysInfo
+    {
+    public:
+        SolarisSysInfo()
+        {
+            this->load_solaris_info();
+        }
+
+    private:
+        void load_solaris_info()
+        {
+            std::ifstream input("/etc/release");
+
+            if (input) {
+                std::string s;
+                std::getline(input, s);
+                std::size_t found = s.find("OpenIndiana ");
+                if (found!=std::string::npos) {
+                    this->distro_name = "OpenIndiana";
+                    this->distro_release = s.substr(found + strlen("OpenIndiana "));
+                } else if (!s.empty()) {
+                    this->distro_release = s;
+                }
+            }
+
+            if (this->distro_release.empty()) {
+                this->distro_name = "Solaris";
+            }
+        }
+    };
+
+
+    class LSBSysInfo
+        : public SysInfo
+    {
+    public:
+        LSBSysInfo()<--- Member variable 'LSBSysInfo::lsb_fd' is not initialized in the constructor.<--- Member variable 'LSBSysInfo::name' is not initialized in the constructor.<--- Member variable 'LSBSysInfo::release' is not initialized in the constructor.
+            : re(Glib::Regex::create("^.+?:\\s*(.+)\\s*$"))
+        {
+            // start();
+        }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Function in derived class
+        {
+            this->name = name;
+            this->release = release;
+
+            this->start();
+        }
+
+
+    private:
+
+        sigc::connection child_watch;
+        int lsb_fd;
+        GtkWidget* name;
+        GtkWidget* release;<--- Shadowed declaration<--- Shadowed declaration
+
+        void strip_description(string &s) const
+        {
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+            GMatchInfo* info = 0;
+
+           if (g_regex_match(this->re->gobj(), s.c_str(), flags, &info)) {
+               s = make_string(g_match_info_fetch(info, 1));
+               g_match_info_free(info);
+           }
+        }
+
+        std::istream& get_value(std::istream &is, string &s) const
+        {
+            if (std::getline(is, s))
+                this->strip_description(s);
+            return is;
+        }
+
+
+        void read_lsb(Glib::Pid pid, int status)
+        {
+            this->child_watch.disconnect();
+
+            if (!WIFEXITED(status) or WEXITSTATUS(status) != 0) {
+                g_error("Child %d failed with status %d", int(pid), status);
+                return;
+            }
+
+            Glib::RefPtr<Glib::IOChannel> channel = Glib::IOChannel::create_from_fd(this->lsb_fd);
+            Glib::ustring content;
+
+            while (channel->read_to_end(content) == Glib::IO_STATUS_AGAIN)
+                ;
+
+            channel->close();
+            Glib::spawn_close_pid(pid);
+
+            procman_debug("lsb_release output = '%s'", content.c_str());
+
+            string release, codename;<--- Shadow variable
+            std::istringstream input(content);
+
+            this->get_value(input, this->distro_name)
+                and this->get_value(input, release)
+                and this->get_value(input, codename);
+
+            this->distro_release = release;
+            if (codename != "" && codename != "n/a")
+                this->distro_release += " (" + codename + ')';
+
+            this->SysInfo::set_distro_labels(this->name, this->release);
+        }
+
+
+        void start()
+        {
+            std::vector<string> argv(2);
+            argv[0] = "lsb_release";
+            argv[1] = "-irc";
+
+            Glib::SpawnFlags flags = Glib::SPAWN_DO_NOT_REAP_CHILD
+                | Glib::SPAWN_SEARCH_PATH
+                | Glib::SPAWN_STDERR_TO_DEV_NULL;
+
+            Glib::Pid child;
+
+            try {
+                Glib::spawn_async_with_pipes("/", // wd
+                                             argv,
+                                             flags,
+                                             sigc::slot<void>(), // child setup
+                                             &child,
+                                             0, // stdin
+                                             &this->lsb_fd); // stdout
+            } catch (Glib::SpawnError &e) {
+                g_error("g_spawn_async_with_pipes error: %s", e.what().c_str());
+                return;
+            }
+
+            sigc::slot<void,GPid, int> slot = sigc::mem_fun(this, &LSBSysInfo::read_lsb);
+            this->child_watch = Glib::signal_child_watch().connect(slot, child);
+        }
+
+
+        void sync_lsb_release()<--- Unused private function: 'LSBSysInfo::sync_lsb_release'
+        {
+            char *out= 0;
+            GError *error = 0;
+            int status;
+
+            if (g_spawn_command_line_sync("lsb_release -irc",
+                                          &out,
+                                          0,
+                                          &status,
+                                          &error)) {
+                string release, codename;<--- Shadow variable
+                if (!error and WIFEXITED(status) and WEXITSTATUS(status) == 0) {
+                    std::istringstream input(out);
+                    this->get_value(input, this->distro_name)
+                        and this->get_value(input, release)
+                        and this->get_value(input, codename);
+                    this->distro_release = release;
+                if (codename != "" && codename != "n/a")
+                    this->distro_release += " (" + codename + ')';
+                }
+            }
+
+            if (error)
+                g_error_free(error);
+
+            g_free(out);
+        }
+
+    private:
+        Glib::RefPtr<Glib::Regex> re;
+    };
+
+
+    class NetBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        NetBSDSysInfo()
+        {
+            this->load_netbsd_info();
+        }
+
+    private:
+        void load_netbsd_info()
+        {
+            this->distro_name = "NetBSD";
+
+            std::ifstream input("/etc/release");
+
+            if (input)
+                std::getline(input, this->distro_release);
+        }
+    };
+
+
+    class GenericSysInfo
+        : public SysInfo
+    {
+    public:
+        GenericSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            std::ifstream input("/etc/os-release");
+
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int start;
+                    std::getline(input, s);
+                    if (s.find("NAME=") == 0) {
+                        start = strlen("NAME=");
+                        if ((s.at(start) == '\"') && (s.at(s.size() - 1) == '\"')) {
+                            this->distro_name = s.substr(start + 1, s.size() - start - 2);
+                        } else {
+                            this->distro_name = s.substr(start);
+                        }
+                    } else if (s.find("VERSION=") == 0) {
+                        start = strlen("VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    } else if (s.find("# VERSION=") == 0) {
+                        start = strlen("# VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    }
+                }
+                input.close();
+                input.clear();
+            }
+            if (this->distro_release.empty()) {
+                input.open("/etc/debian_version");
+                if (input) {
+                    getline(input, this->distro_release);
+                }
+            }
+        }
+    };
+
+    class MintSysInfo
+        : public SysInfo
+    {
+    public:
+        MintSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            this->distro_name = "Linux Mint";
+            std::ifstream input("/etc/linuxmint/info");
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int len;
+                    std::getline(input, s);
+                    if (s.find("DESCRIPTION=") == 0) {
+                        len = strlen("DESCRIPTION=");
+                        // also strip the surrounding quotes
+                       this->distro_release = s.substr(len + 1, s.size() - len - 2);
+                   }
+                }
+            }
+        }
+    };
+
+    class OpenBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        OpenBSDSysInfo()
+        {
+            this->load_openbsd_info();
+        }
+
+    private:
+        void load_openbsd_info()
+        {
+            this->distro_name = "OpenBSD";
+            this->distro_release = this->kernel;
+
+            std::ifstream input("/etc/motd");
+
+            if (input)
+                std::getline(input, this->kernel);
+        }
+    };
+
+    SysInfo* get_sysinfo()
+    {
+        if (g_file_test ("/etc/linuxmint/info", G_FILE_TEST_EXISTS)) {
+            return new MintSysInfo;
+        }
+        else if (g_file_test ("/etc/os-release", G_FILE_TEST_EXISTS)) {
+            return new GenericSysInfo;
+        }
+        else if (char *p = g_find_program_in_path("lsb_release")) {
+            g_free(p);
+            return new LSBSysInfo;
+        }
+        else if (SysInfo::system() == "FreeBSD") {
+            return new FreeBSDSysInfo;
+        }
+        else if (SysInfo::system() == "SunOS") {
+            return new SolarisSysInfo;
+        }
+        else if (SysInfo::system() == "NetBSD") {
+            return new NetBSDSysInfo;
+        }
+        else if (SysInfo::system() == "OpenBSD") {
+            return new OpenBSDSysInfo;
+        }
+
+        return new SysInfo;
+    }
+}
+
+
+#define X_PAD  0
+#define Y_PAD  0
+#define LOGO_W 92
+#define LOGO_H 351
+#define RADIUS 5
+
+static gboolean sysinfo_logo_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    GtkStyle *style;
+    cairo_t *cr;
+    cairo_pattern_t *cp;
+
+    cr = gdk_cairo_create(gtk_widget_get_window(widget));
+
+    gtk_widget_get_allocation (widget, &allocation);
+    cairo_translate(cr, allocation.x, allocation.y);
+
+    cairo_move_to(cr, X_PAD + RADIUS, Y_PAD);
+    cairo_line_to(cr, X_PAD + LOGO_W - RADIUS, Y_PAD);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + RADIUS, RADIUS, -0.5 * M_PI, 0);
+    cairo_line_to(cr, X_PAD + LOGO_W, Y_PAD + LOGO_H - RADIUS);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0, 0.5 * M_PI);
+    cairo_line_to(cr, X_PAD + RADIUS, Y_PAD + LOGO_H);
+    cairo_arc(cr, X_PAD + RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0.5 * M_PI, -1.0 * M_PI);
+    cairo_line_to(cr, X_PAD, Y_PAD + RADIUS);
+    cairo_arc(cr,  X_PAD + RADIUS, Y_PAD + RADIUS, RADIUS, -1.0 * M_PI, -0.5 * M_PI);
+
+    cp = cairo_pattern_create_linear(0, Y_PAD, 0, Y_PAD + LOGO_H);
+    style = gtk_widget_get_style (widget);
+    cairo_pattern_add_color_stop_rgba(cp, 0.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      1.0);
+    cairo_pattern_add_color_stop_rgba(cp, 1.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      0.0);
+    cairo_set_source(cr, cp);
+    cairo_fill(cr);
+
+    cairo_pattern_destroy(cp);
+    cairo_destroy(cr);
+
+    return FALSE;
+}
+
+static GtkWidget*
+add_section(GtkBox *vbox , const char * title, int num_row, int num_col, GtkWidget **out_frame)
+{
+    GtkWidget *table;
+
+    GtkWidget *frame = gtk_frame_new(title);
+    gtk_frame_set_label_align(GTK_FRAME(frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
+
+    table = gtk_grid_new();
+    gtk_grid_set_row_spacing(GTK_GRID(table), 6);
+    gtk_grid_set_column_spacing(GTK_GRID(table), 6);
+    gtk_widget_set_margin_start (GTK_WIDGET(table), 12);
+    gtk_container_set_border_width(GTK_CONTAINER(table), 6);
+    gtk_container_add(GTK_CONTAINER(frame), table);
+
+    if(out_frame)
+        *out_frame = frame;
+
+    return table;
+}
+
+
+static GtkWidget*
+add_row(GtkGrid * table, const char * label, const char * value, int row)
+{
+    GtkWidget *header = gtk_label_new(NULL);
+    gtk_label_set_markup(GTK_LABEL(header), label);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        table, header,
+        0, row, 1, 1);
+
+    GtkWidget *label_widget = gtk_label_new(value);
+    gtk_label_set_selectable(GTK_LABEL(label_widget), TRUE);
+    gtk_widget_set_can_focus(label_widget, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (label_widget), 0.0);
+    gtk_grid_attach(
+        table, label_widget,
+        1, row, 1, 1);
+
+    return label_widget;
+}
+
+
+static GtkWidget *
+procman_create_sysinfo_view(void)
+{
+    GtkWidget *hbox;
+    GtkWidget *vbox;
+
+    SysInfo *data = get_sysinfo();;
+
+    GtkWidget * logo;
+
+    GtkWidget *distro_frame;
+    GtkWidget *distro_release_label;
+    GtkWidget *distro_table;
+
+    GtkWidget *hardware_table;
+    GtkWidget *disk_space_table;
+
+    GtkWidget *header;
+
+    gchar *markup;
+
+    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);
+
+    /* left-side logo */
+    if (g_file_test (DATADIR "/pixmaps/mate-system-monitor/distribution/side.png", G_FILE_TEST_EXISTS)) {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/distribution/side.png");
+    }
+    else {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/side.png");
+    }
+    gtk_widget_set_valign (logo, GTK_ALIGN_START);
+    gtk_widget_set_margin_start (logo, 5);
+    gtk_widget_set_margin_end (logo, 5);
+    gtk_widget_set_margin_top (logo, 12);
+    gtk_widget_set_margin_bottom (logo, 12);
+    gtk_box_pack_start(GTK_BOX(hbox), logo, FALSE, FALSE, 0);
+
+    g_signal_connect(G_OBJECT(logo), "draw", G_CALLBACK(sysinfo_logo_draw), NULL);
+
+    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
+    gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
+
+    // hostname
+
+    markup = g_strdup_printf("<big><big><b><u>%s</u></b></big></big>",
+                             data->hostname.c_str());
+    GtkWidget *hostname_frame = gtk_frame_new(markup);
+    g_free(markup);
+    gtk_frame_set_label_align(GTK_FRAME(hostname_frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(hostname_frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(hostname_frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), hostname_frame, FALSE, FALSE, 0);
+
+
+    /* distro section */
+
+    unsigned table_size = 2;
+    if (data->mate_version != "")
+        table_size++;
+    distro_table = add_section(GTK_BOX(vbox), "???", table_size, 1, &distro_frame);
+
+    unsigned table_count = 0;
+
+    distro_release_label = gtk_label_new("???");
+    gtk_label_set_selectable(GTK_LABEL(distro_release_label), TRUE);
+    gtk_widget_set_can_focus(distro_release_label, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (distro_release_label), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), distro_release_label,
+        0, table_count, 1, 1);
+    table_count++;
+    data->set_distro_labels(gtk_frame_get_label_widget(GTK_FRAME(distro_frame)), distro_release_label);
+
+    markup = g_strdup_printf(_("Kernel %s"), data->kernel.c_str());
+    header = gtk_label_new(markup);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    g_free(markup);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), header,
+        0, table_count, 1, 1);
+    table_count++;
+
+    if (data->mate_version != "")
+    {
+        markup = g_strdup_printf(_("MATE %s"), data->mate_version.c_str());
+        header = gtk_label_new(markup);
+        gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+        gtk_widget_set_can_focus(header, FALSE);
+        g_free(markup);
+        gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+        gtk_grid_attach(
+            GTK_GRID(distro_table), header,
+            0, table_count, 1, 1);
+        table_count++;<--- Variable 'table_count' is assigned a value that is never used.
+    }
+
+    /* hardware section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("Hardware"));
+    hardware_table = add_section(GTK_BOX(vbox), markup, 1, 3, NULL);
+    g_free(markup);
+
+    markup = g_format_size_full(data->memory_bytes, G_FORMAT_SIZE_IEC_UNITS);
+    add_row(GTK_GRID(hardware_table), _("Memory:"), markup, 0);
+    g_free(markup);
+
+    add_row(GTK_GRID(hardware_table), _("Processor:"),
+            data->processors.c_str(), 1);
+    add_row(GTK_GRID(hardware_table), _("Graphics:"),
+            data->graphics.c_str(), 2);
+
+    /* disk space section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("System Status"));
+    disk_space_table = add_section(GTK_BOX(vbox), markup, 1, 2, NULL);
+    g_free(markup);
+
+    markup = g_format_size(data->free_space_bytes);
+    add_row(GTK_GRID(disk_space_table), _("Available disk space:"), markup, 0);
+    g_free(markup);
+
+    return hbox;
+}
+
+
+
+namespace procman
+{
+    void build_sysinfo_ui()
+    {
+        static GtkWidget* ui;
+
+        if (!ui) {
+            ProcData* procdata = ProcData::get_instance();
+            ui = procman_create_sysinfo_view();
+            GtkBox* box = GTK_BOX(gtk_notebook_get_nth_page(GTK_NOTEBOOK(procdata->notebook),
+                                                            PROCMAN_TAB_SYSINFO));
+            gtk_box_pack_start(box, ui, TRUE, TRUE, 0);
+            gtk_widget_show_all(ui);
+        }
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/2.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/2.html new file mode 100644 index 00000000..0154b48f --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/2.html @@ -0,0 +1,489 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
#ifndef _PROCMAN_LOAD_GRAPH_H_
+#define _PROCMAN_LOAD_GRAPH_H_
+
+#include <glib.h>
+#include <glibtop/cpu.h>
+
+enum
+{
+    LOAD_GRAPH_CPU,
+    LOAD_GRAPH_MEM,
+    LOAD_GRAPH_NET
+};
+
+enum {
+    CPU_TOTAL,
+    CPU_USED,
+    N_CPU_STATES
+};
+
+struct LoadGraphLabels
+{
+    GtkWidget *cpu[GLIBTOP_NCPU];
+    GtkWidget *memory;
+    GtkWidget *swap;
+    GtkWidget *net_in;
+    GtkWidget *net_in_total;
+    GtkWidget *net_out;
+    GtkWidget *net_out_total;
+};
+
+struct LoadGraph {
+
+    static const unsigned NUM_POINTS = 60 + 2;
+    static const unsigned GRAPH_MIN_HEIGHT = 40;
+
+    LoadGraph(guint type);
+    ~LoadGraph();
+
+    unsigned num_bars() const;
+    void clear_background();
+
+    double fontsize;
+    double rmargin;
+    double indent;
+
+    guint n;
+    gint type;
+    guint speed;
+    guint draw_width, draw_height;
+    guint render_counter;
+    guint frames_per_unit;
+    guint graph_dely;
+    guint real_draw_height;
+    double graph_delx;
+    guint graph_buffer_offset;
+
+    std::vector<GdkRGBA> colors;
+
+    std::vector<float> data_block;
+    gfloat* data[NUM_POINTS];
+
+    GtkWidget *main_widget;
+    GtkWidget *disp;
+
+    cairo_pattern_t *background;
+
+    guint timer_index;
+
+    gboolean draw;
+
+    LoadGraphLabels labels;
+    GtkWidget *mem_color_picker;
+    GtkWidget *swap_color_picker;
+
+    /* union { */
+        struct {
+            guint now; /* 0 -> current, 1 -> last
+                    now ^ 1 each time */
+            /* times[now], times[now ^ 1] is last */
+            guint64 times[2][GLIBTOP_NCPU][N_CPU_STATES];
+        } cpu;
+
+        struct {
+            guint64 last_in, last_out;
+#if GLIB_CHECK_VERSION(2,61,2)
+            gint64 time;
+#else
+            GTimeVal time;
+#endif
+            guint64 max;
+            unsigned values[NUM_POINTS];
+            size_t cur;
+        } net;
+    /* }; */
+};
+
+/* Force a drawing update */
+void
+load_graph_queue_draw (LoadGraph *g);
+
+/* Start load graph. */
+void
+load_graph_start (LoadGraph *g);
+
+/* Stop load graph. */
+void
+load_graph_stop (LoadGraph *g);
+
+/* Change load graph speed and restart it if it has been previously started */
+void
+load_graph_change_speed (LoadGraph *g,
+                         guint new_speed);
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+#endif /* _PROCMAN_LOAD_GRAPH_H_ */
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/3.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/3.html new file mode 100644 index 00000000..e0d59e5d --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/3.html @@ -0,0 +1,645 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
#include <config.h>
+
+#include <cstring>
+#include <glib/gi18n.h>
+
+#include "cgroups.h"
+#include "util.h"
+
+gboolean
+cgroups_enabled(void)
+{
+    static gboolean initialized = FALSE;
+    static gboolean has_cgroups;
+
+    if (!initialized) {
+        initialized = TRUE;
+        has_cgroups = g_file_test("/proc/cgroups", G_FILE_TEST_EXISTS);
+    }
+
+    return has_cgroups;
+}
+
+static void
+append_cgroup_name(char *line, gchar **current_cgroup_name)
+{
+    gchar *controller, *path, *tmp, *path_plus_space;
+    int paren_offset, off, tmp_size;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return;
+
+    *(path - 1) = '\0';
+    g_strdelimit(controller, ",", '/');
+
+    if ((std::strcmp(path, "/") == 0) || (std::strncmp(controller, "name=", 5) == 0))
+        return;
+
+    if (*current_cgroup_name == NULL) {
+        *current_cgroup_name = g_strdup_printf("%s (%s)", path, controller);
+        return;
+    }
+
+    /* add a space to the end of the path string */
+    path_plus_space = g_strdup_printf("%s ", path);
+
+    if ((tmp = g_strstr_len(*current_cgroup_name, -1, path_plus_space))) {
+        tmp_size = strlen(*current_cgroup_name) + strlen(controller) + 1;
+        paren_offset = g_strstr_len(tmp + strlen(path), -1, ")") - *current_cgroup_name;
+        *(*current_cgroup_name + paren_offset) = '\0';
+        tmp = (gchar *)g_strnfill(tmp_size, '\0');
+        off = g_strlcat(tmp, *current_cgroup_name, tmp_size);
+        *(tmp + off) = '/';
+        off++;
+        off += g_strlcat(tmp + off, controller, tmp_size);
+        *(tmp + off) = ')';
+        off++;
+        g_strlcat(tmp + off, *current_cgroup_name + paren_offset + 1, tmp_size);
+    } else
+        tmp = g_strdup_printf("%s, %s(%s)", *current_cgroup_name, path_plus_space, controller);
+
+    g_free(path_plus_space);
+    g_free(*current_cgroup_name);
+    *current_cgroup_name = tmp;
+}
+
+static int
+check_cgroup_changed(gchar *line, gchar *current_cgroup_set)
+{
+    /* check if line is contained in current_cgroup_set */
+    gchar *controller, *path, *tmp, *found, *close_paren, *open_paren;
+    int ret = 0;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return 1;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return 1;
+
+    *(path - 1) = '\0';
+
+    if (std::strncmp(controller, "name=", 5) == 0)
+        goto out;
+
+    /* if there are multiple controllers just report string has changed */
+    if (g_strstr_len(controller, -1, ",")) {
+        ret = 1;
+        goto out;
+    }
+
+    if (!current_cgroup_set) {
+        if (std::strcmp(path, "/") != 0)
+            ret = 1;
+        goto out;
+    }
+
+    /* special case for root cgroup */
+    tmp = current_cgroup_set;
+    if (std::strcmp(path, "/") == 0) {
+        while ((found = g_strstr_len(tmp, -1, controller))) {
+            close_paren = g_strstr_len(found, -1, ")");
+            open_paren = g_strstr_len(found, -1, "(");
+            if (close_paren) {
+                if (!open_paren || (close_paren < open_paren)) {
+                    ret = 1;
+                    goto out;
+                }
+            }
+            tmp = found + strlen(controller);
+        }
+        goto out;
+    }
+
+    tmp = current_cgroup_set;
+    while ((found = g_strstr_len(tmp, -1, path))) {
+            found = found + strlen(path);
+            close_paren = g_strstr_len(found, -1, ")");
+            if (*found == ' ') {
+                if (g_strstr_len(found + 1, close_paren - found, controller))
+                    goto out;
+            }
+            tmp = close_paren + 1;
+    }
+    ret = 1;
+out:
+    *(path - 1) = ':';
+    return ret;
+}
+
+void
+get_process_cgroup_info(ProcInfo *info)
+{
+    gchar *path;
+    gchar *cgroup_name = NULL;
+    int cgroups_changed = 0;
+    gchar *text;
+    char **lines;
+    int i;
+
+    if (!cgroups_enabled())
+        return;
+
+    /* read out of /proc/pid/cgroup */
+    path = g_strdup_printf("/proc/%d/cgroup", info->pid);
+    if (!path)
+        return;
+    if(!g_file_get_contents(path, &text, NULL, NULL))
+        goto out;
+    lines = g_strsplit(text, "\n", -1);
+    g_free(text);
+    if (!lines)
+        goto out;
+
+    for (i = 0; lines[i] != NULL; i++) {
+        if (lines[i][0] == '\0')
+            continue;
+        if (check_cgroup_changed(lines[i], info->cgroup_name)) {
+            cgroups_changed = 1;
+            break;
+        }
+    }
+
+    if (cgroups_changed) {
+        for (i = 0; lines[i] != NULL; i++) {
+            if (lines[i][0] == '\0')
+                continue;
+            append_cgroup_name(lines[i], &cgroup_name);
+        }
+        if (info->cgroup_name)
+            g_free(info->cgroup_name);
+        if (!cgroup_name)
+            info->cgroup_name = g_strdup("");
+        else
+            info->cgroup_name = cgroup_name;
+    }
+
+    g_strfreev(lines);
+out:
+    g_free(path);
+}
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/4.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/4.html new file mode 100644 index 00000000..cc9dbf88 --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/4.html @@ -0,0 +1,1277 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
#include <config.h>
+
+#ifdef __linux__
+#include <mntent.h>
+#endif // __linux__
+
+#include <giomm.h>
+#include <giomm/themedicon.h>
+#include <gtk/gtk.h>
+#include <glibtop/mountlist.h>
+#include <glibtop/fsusage.h>
+#include <glib/gi18n.h>
+
+#include "procman.h"
+#include "disks.h"
+#include "util.h"
+#include "interface.h"
+#include "iconthemewrapper.h"
+
+namespace
+{
+  const unsigned DISK_ICON_SIZE = 24;
+}
+
+enum DiskColumns
+{
+    /* string columns* */
+    DISK_DEVICE,
+    DISK_DIR,
+    DISK_TYPE,
+    DISK_SUBVOLUME,
+    DISK_TOTAL,
+    DISK_FREE,
+    DISK_AVAIL,
+    /* USED has to be the last column */
+    DISK_USED,
+    // then unvisible columns
+    /* Surface column */
+    DISK_ICON,
+    /* numeric columns */
+    DISK_USED_PERCENTAGE,
+    DISK_N_COLUMNS
+};
+
+
+
+static void
+fsusage_stats(const glibtop_fsusage *buf,
+              guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
+              gint *percentage)
+{
+    guint64 total = buf->blocks * buf->block_size;
+
+    if (!total) {
+        /* not a real device */
+        *btotal = *bfree = *bavail = *bused = 0ULL;
+        *percentage = 0;
+    } else {
+        int percent;
+        *btotal = total;
+        *bfree = buf->bfree * buf->block_size;
+        *bavail = buf->bavail * buf->block_size;
+        *bused = *btotal - *bfree;
+        /* percent = 100.0f * *bused / *btotal; */
+        percent = 100 * *bused / (*bused + *bavail);
+        *percentage = CLAMP(percent, 0, 100);
+    }
+}
+
+
+namespace
+{
+    string get_icon_for_path(const std::string& path)
+    {
+        using namespace Glib;
+        using namespace Gio;
+
+        // FIXME: I don't know whether i should use Volume or Mount or UnixMount
+        // all i need an icon name.
+        RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+        std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
+
+        for (size_t i = 0; i != mounts.size(); ++i) {
+            if (mounts[i]->get_name() != path)
+                continue;
+
+            RefPtr<Icon> icon = mounts[i]->get_icon();
+            RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
+
+            if (themed_icon) {
+                char* name = 0;
+                // FIXME: not wrapped yet
+                g_object_get(G_OBJECT(themed_icon->gobj()), "name", &name, NULL);
+                return make_string(name);
+            }
+        }
+
+        return "";
+    }
+}
+
+
+static Glib::RefPtr<Gdk::Pixbuf>
+get_icon_for_device(const char *mountpoint)
+{
+    procman::IconThemeWrapper icon_theme;
+    string icon_name = get_icon_for_path(mountpoint);
+    if (icon_name == "")
+        // FIXME: defaults to a safe value
+        icon_name = "drive-harddisk"; // get_icon_for_path("/");
+    return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
+}
+
+
+static gboolean
+find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
+                   GtkTreeIter *result)
+{
+    GtkTreeIter iter;
+    gboolean found = FALSE;
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        do {
+            char *dir;
+
+            gtk_tree_model_get(model, &iter,
+                               DISK_DIR, &dir,
+                               -1);
+
+            if (dir && !strcmp(dir, mountpoint)) {
+                *result = iter;
+                found = TRUE;
+            }
+
+            g_free(dir);
+
+        } while (!found && gtk_tree_model_iter_next(model, &iter));
+    }
+
+    return found;
+}
+
+
+
+static void
+remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
+{
+    GtkTreeIter iter;
+
+    if (!gtk_tree_model_get_iter_first(model, &iter))
+        return;
+
+    while (true) {
+        char *dir;
+        guint i;
+        gboolean found = FALSE;
+
+        gtk_tree_model_get(model, &iter,
+                           DISK_DIR, &dir,
+                           -1);
+
+        for (i = 0; i != n; ++i) {
+            if (!strcmp(dir, entries[i].mountdir)) {
+                found = TRUE;
+                break;
+            }
+        }
+
+        g_free(dir);
+
+        if (!found) {
+            if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                break;
+            else
+                continue;
+        }
+
+        if (!gtk_tree_model_iter_next(model, &iter))
+            break;
+    }
+}
+
+#ifdef __linux__
+static char *
+get_mount_opt(const glibtop_mountentry *entry, const char* opt)
+{
+    char *opt_value = NULL;
+    const struct mntent *mnt;
+    FILE *fp;
+
+    if (!(fp = setmntent(MOUNTED, "r"))) {
+        goto out;
+    }
+
+    while ((mnt = getmntent(fp))) {
+        if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
+            (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
+            char *res;
+
+            res = hasmntopt(mnt, "subvol");<--- res is assigned
+            if ((res = hasmntopt(mnt, "subvol")) != NULL) {<--- res is overwritten
+                char **strs = g_strsplit_set(res, "=", 2);
+
+                if (g_strv_length(strs) == 2) {
+                    char *value = strs[1];
+                    if (g_strcmp0 (value,"/root") == 0)
+                       opt_value = g_strdup("/");
+                    else
+                        opt_value = g_strdup(strs[1]);
+                    g_strfreev(strs);
+                }
+            }
+            break;
+        }
+    }
+
+    endmntent(fp);
+
+  out:
+     return opt_value;
+}
+#endif // __linux__
+
+
+static void
+add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
+{
+    Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+    cairo_surface_t *surface;
+    GtkTreeIter iter;
+    glibtop_fsusage usage;
+    guint64 bused, bfree, bavail, btotal;
+    gint percentage;
+#ifdef __linux__
+    char *subvol = NULL;
+#endif // __linux__
+
+    glibtop_get_fsusage(&usage, entry->mountdir);
+
+    if (not show_all_fs and usage.blocks == 0) {
+        if (find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+            gtk_list_store_remove(list, &iter);
+        return;
+    }
+
+    fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
+#ifdef __linux__
+    subvol = get_mount_opt(entry, "subvol");
+#endif // __linux__
+    pixbuf = get_icon_for_device(entry->mountdir);
+    surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL);
+
+    /* if we can find a row with the same mountpoint, we get it but we
+       still need to update all the fields.
+       This makes selection persistent.
+    */
+    if (!find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+        gtk_list_store_append(list, &iter);
+
+    gtk_list_store_set(list, &iter,
+                       DISK_ICON, surface,
+                       DISK_DEVICE, entry->devname,
+                       DISK_DIR, entry->mountdir,
+                       DISK_TYPE, entry->type,
+#ifdef __linux__
+
+                       DISK_SUBVOLUME, subvol != NULL ? subvol : "",
+#else
+                       DISK_SUBVOLUME, "",
+#endif // __linux__
+                       DISK_USED_PERCENTAGE, percentage,
+                       DISK_TOTAL, btotal,
+                       DISK_FREE, bfree,
+                       DISK_AVAIL, bavail,
+                       DISK_USED, bused,
+                       -1);
+#ifdef __linux__
+    g_free (subvol);
+#endif // __linux__
+}
+
+
+
+int
+cb_update_disks(gpointer data)
+{
+    ProcData *const procdata = static_cast<ProcData*>(data);
+
+    GtkListStore *list;
+    glibtop_mountentry * entries;
+    glibtop_mountlist mountlist;
+    guint i;
+
+    list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)));
+
+    entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
+
+    remove_old_disks(GTK_TREE_MODEL(list), entries, mountlist.number);
+
+    for (i = 0; i < mountlist.number; i++)
+        add_disk(list, &entries[i], procdata->config.show_all_fs);
+
+    g_free(entries);
+
+    return TRUE;
+}
+
+
+static void
+cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "disktreenew");
+}
+
+
+static void
+open_dir(GtkTreeView       *tree_view,
+         GtkTreePath       *path,
+         GtkTreeViewColumn *column,
+         gpointer           user_data)
+{
+    GtkTreeIter iter;
+    GtkTreeModel *model;
+    char *dir, *url;
+
+    model = gtk_tree_view_get_model(tree_view);
+
+    if (!gtk_tree_model_get_iter(model, &iter, path)) {
+        char *p;
+        p = gtk_tree_path_to_string(path);
+        g_warning("Cannot get iter for path '%s'\n", p);
+        g_free(p);
+        return;
+    }
+
+    gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
+
+    url = g_strdup_printf("file://%s", dir);
+
+    GError* error = 0;
+    if (!g_app_info_launch_default_for_uri(url, NULL, &error)) {
+        g_warning("Cannot open '%s' : %s\n", url, error->message);
+        g_error_free(error);
+    }
+
+    g_free(url);
+    g_free(dir);
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "disktreenew");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+void
+create_disk_view(ProcData *procdata, GtkBuilder *builder)
+{
+    GtkWidget *scrolled;
+    GtkWidget *disk_tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *col;
+    GtkCellRenderer *cell;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Device"),
+        N_("Directory"),
+        N_("Type"),
+        N_("SubVolume"),
+        N_("Total"),
+        N_("Free"),
+        N_("Available"),
+        N_("Used")
+    };
+
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"));
+
+    model = gtk_list_store_new(DISK_N_COLUMNS,             /* n columns */
+                               G_TYPE_STRING,              /* DISK_DEVICE */
+                               G_TYPE_STRING,              /* DISK_DIR */
+                               G_TYPE_STRING,              /* DISK_TYPE */
+                               G_TYPE_STRING,              /* DISK_SUBVOLUME */
+                               G_TYPE_UINT64,              /* DISK_TOTAL */
+                               G_TYPE_UINT64,              /* DISK_FREE */
+                               G_TYPE_UINT64,              /* DISK_AVAIL */
+                               G_TYPE_UINT64,              /* DISK_USED */
+                               CAIRO_GOBJECT_TYPE_SURFACE, /* DISK_ICON */
+                               G_TYPE_INT);                /* DISK_USED_PERCENTAGE */
+
+    disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL);
+    procdata->disk_list = disk_tree;
+    gtk_container_add(GTK_CONTAINER(scrolled), disk_tree);
+    g_object_unref(G_OBJECT(model));
+
+    /* icon + device */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
+                                        NULL);
+
+    cell = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
+                                        NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 30);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* sizes - used */
+
+    for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_min_width (col, 30);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+        switch (i) {
+            case DISK_TOTAL:
+            case DISK_FREE:
+            case DISK_AVAIL:
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+        default:
+            gtk_tree_view_column_set_attributes(col, cell,
+                                                "text", i,
+                                                NULL);
+            break;
+        }
+    }
+
+    /* used + percentage */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_text_new();
+    g_object_set(cell, "xalign", 1.0f, NULL);
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_cell_data_func(col, cell,
+                                            &procman::storage_size_cell_data_func,
+                                            GUINT_TO_POINTER(DISK_USED),
+                                            NULL);
+
+    cell = gtk_cell_renderer_progress_new();
+    gtk_tree_view_column_pack_start(col, cell, TRUE);
+    gtk_tree_view_column_set_attributes(col, cell, "value",
+                                        DISK_USED_PERCENTAGE, NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_USED]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 150);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* numeric sort */
+
+    procman_get_tree_state(procdata->settings, disk_tree,
+                   "disktreenew");
+
+    g_signal_connect (G_OBJECT(disk_tree), "columns-changed",
+                      G_CALLBACK(cb_disk_columns_changed), procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/5.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/5.html new file mode 100644 index 00000000..17de817b --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/5.html @@ -0,0 +1,2141 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
+852
+853
+854
+855
+856
+857
+858
+859
+860
+861
+862
+863
+864
+865
+866
+867
+868
+869
+870
+871
+872
+873
+874
+875
+876
+877
+878
+879
+880
+881
+882
+883
+884
+885
+886
+887
+888
+889
+890
+891
+892
+893
+894
+895
+896
+897
+898
+899
+900
+901
+902
+903
+904
+905
+906
+907
+908
+909
+910
+911
+912
+913
+914
+915
+916
+917
+918
+919
+920
+921
+922
+923
+924
+925
+926
+927
+928
+929
+930
+931
+932
+933
+934
+935
+936
+937
+938
+939
+940
+941
+942
+943
+944
+945
+946
/*
+ * Mate system monitor color pickers
+ * Copyright (C) 2007 Karl Lattimer <karl@qdh.org.uk>
+ * Copyright (C) 2012-2021 MATE Developers
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with the software; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <gdk/gdkkeysyms.h>
+#include <math.h>
+#include <cairo.h>
+#include <librsvg/rsvg.h>
+
+#include "gsm_color_button.h"
+
+typedef struct {
+    GtkWidget *cc_dialog;		/* Color chooser dialog */
+
+    gchar *title;            /* Title for the color selection window */
+
+    GdkRGBA color;
+
+    gdouble fraction;        /* Only used by GSMCP_TYPE_PIE */
+    guint type;
+    cairo_surface_t *image_buffer;
+    gdouble highlight;
+    gboolean button_down;
+    gboolean in_button;
+} GSMColorButtonPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GSMColorButton, gsm_color_button, GTK_TYPE_DRAWING_AREA)
+
+/* Properties */
+enum
+{
+    PROP_0,
+    PROP_PERCENTAGE,
+    PROP_TITLE,
+    PROP_COLOR,
+    PROP_TYPE
+};
+
+/* Signals */
+enum
+{
+    COLOR_SET,
+    LAST_SIGNAL
+};
+
+#define GSMCP_MIN_WIDTH 15
+#define GSMCP_MIN_HEIGHT 15
+
+static void gsm_color_button_finalize (GObject * object);
+static void gsm_color_button_set_property (GObject * object, guint param_id,
+                                           const GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_get_property (GObject * object, guint param_id,
+                                           GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_realize (GtkWidget * widget);
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width);
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height);
+static void gsm_color_button_size_allocate (GtkWidget * widget,
+                                            GtkAllocation * allocation);
+static void gsm_color_button_unrealize (GtkWidget * widget);
+static void gsm_color_button_state_changed (GtkWidget * widget,
+                                            GtkStateType previous_state);
+static void gsm_color_button_style_set (GtkWidget * widget,
+                                        GtkStyle * previous_style);
+static gint gsm_color_button_pressed (GtkWidget * widget,
+                                      GdkEventButton * event);
+static gint gsm_color_button_released (GtkWidget * widget,
+                                       GdkEventButton * event);
+static gboolean gsm_color_button_enter_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+static gboolean gsm_color_button_leave_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+/* source side drag signals */
+static void gsm_color_button_drag_begin (GtkWidget * widget,
+                                         GdkDragContext * context,
+                                         gpointer data);
+static void gsm_color_button_drag_data_get (GtkWidget * widget,
+                                            GdkDragContext * context,
+                                            GtkSelectionData * selection_data,
+                                            guint info, guint time,
+                                            GSMColorButton * color_button);
+
+/* target side drag signals */
+static void gsm_color_button_drag_data_received (GtkWidget * widget,
+                                                 GdkDragContext * context,
+                                                 gint x,
+                                                 gint y,
+                                                 GtkSelectionData *
+                                                 selection_data, guint info,
+                                                 guint32 time,
+                                                 GSMColorButton *
+                                                 color_button);
+
+static guint color_button_signals[LAST_SIGNAL] = { 0 };
+
+static const GtkTargetEntry drop_types[] = { {"application/x-color", 0, 0} };
+
+static void
+gsm_color_button_class_init (GSMColorButtonClass * klass)
+{
+    GObjectClass *gobject_class;
+    GtkWidgetClass *widget_class;
+
+    gobject_class = G_OBJECT_CLASS (klass);
+    widget_class = GTK_WIDGET_CLASS (klass);
+
+    gobject_class->get_property = gsm_color_button_get_property;
+    gobject_class->set_property = gsm_color_button_set_property;
+    gobject_class->finalize = gsm_color_button_finalize;
+    widget_class->state_changed = gsm_color_button_state_changed;
+    widget_class->get_preferred_width = gsm_color_button_get_preferred_width;
+    widget_class->get_preferred_height = gsm_color_button_get_preferred_height;
+    widget_class->size_allocate = gsm_color_button_size_allocate;
+    widget_class->realize = gsm_color_button_realize;
+    widget_class->unrealize = gsm_color_button_unrealize;
+    widget_class->style_set = gsm_color_button_style_set;
+    widget_class->button_release_event = gsm_color_button_released;
+    widget_class->button_press_event = gsm_color_button_pressed;
+    widget_class->enter_notify_event = gsm_color_button_enter_notify;
+    widget_class->leave_notify_event = gsm_color_button_leave_notify;
+
+    klass->color_set = NULL;
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_PERCENTAGE,
+                                     g_param_spec_double ("fraction",
+                                                          _("Fraction"),
+                                     // TRANSLATORS: description of the pie color picker's (mem, swap) filled percentage property
+                                                          _("Percentage full for pie color pickers"),
+                                                          0, 1, 0.5,
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TITLE,
+                                     g_param_spec_string ("title",
+                                                          _("Title"),
+                                                          _("The title of the color selection dialog"),
+                                                          _("Pick a Color"),
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_COLOR,
+                                     g_param_spec_boxed ("color",
+                                                         _("Current Color"),
+                                                         _("The selected color"),
+                                                         GDK_TYPE_RGBA,
+                                                         G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TYPE,
+                                     g_param_spec_uint ("type", _("Type"),
+                                                        _("Type of color picker"),
+                                                        0, 4, 0,
+                                                        G_PARAM_READWRITE));
+
+    color_button_signals[COLOR_SET] = g_signal_new ("color_set",
+                                                    G_TYPE_FROM_CLASS
+                                                    (gobject_class),
+                                                    G_SIGNAL_RUN_FIRST,
+                                                    G_STRUCT_OFFSET
+                                                    (GSMColorButtonClass,
+                                                    color_set), NULL, NULL,
+                                                    g_cclosure_marshal_VOID__VOID,
+                                                    G_TYPE_NONE, 0);
+
+}
+
+static cairo_surface_t *
+fill_image_buffer_from_file (cairo_t *cr, const char *filePath)
+{
+    GError *error = NULL;
+    RsvgHandle *handle;
+    cairo_surface_t *tmp_surface;
+    cairo_t *tmp_cr;
+
+    handle = rsvg_handle_new_from_file (filePath, &error);
+
+    if (handle == NULL) {
+        g_warning("rsvg_handle_new_from_file(\"%s\") failed: %s",
+              filePath, (error ? error->message : "unknown error"));
+    if (error)
+          g_error_free(error);
+    return NULL;
+    }
+
+    tmp_surface = cairo_surface_create_similar (cairo_get_target (cr),
+                                                CAIRO_CONTENT_COLOR_ALPHA,
+                                                32, 32);
+    tmp_cr = cairo_create (tmp_surface);
+    rsvg_handle_render_cairo (handle, tmp_cr);
+    cairo_destroy (tmp_cr);
+    g_object_unref (handle);
+    return tmp_surface;
+}
+
+static void
+render (GtkWidget * widget)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GdkRGBA *color;
+    GdkRGBA tmp_color = priv->color;
+    color = &tmp_color;
+    cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
+    cairo_path_t *path = NULL;
+    gint width, height;
+    gdouble radius, arc_start, arc_end;
+    gdouble highlight_factor;
+
+    if (priv->highlight > 0) {
+        highlight_factor = 0.125 * priv->highlight;
+
+    if (color->red + highlight_factor > 1.0)
+        color->red = 1.0;
+    else
+        color->red = color->red + highlight_factor;
+
+    if (color->blue + highlight_factor > 1.0)
+        color->blue = 1.0;
+    else
+      color->blue = color->blue + highlight_factor;
+
+    if (color->green + highlight_factor > 1.0)
+        color->green = 1.0;
+    else
+        color->green = color->green + highlight_factor;
+    }
+    gdk_cairo_set_source_rgba (cr, color);
+
+    width = gdk_window_get_width(gtk_widget_get_window(widget));
+    height = gdk_window_get_height(gtk_widget_get_window(widget));
+
+    switch (priv->type)
+        {
+        case GSMCP_TYPE_CPU:
+            //gtk_widget_set_size_request (widget, GSMCP_MIN_WIDTH, GSMCP_MIN_HEIGHT);
+            cairo_paint (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1);
+            cairo_stroke (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.4);
+            cairo_rectangle (cr, 1.5, 1.5, width - 3, height - 3);
+            cairo_stroke (cr);
+            break;
+        case GSMCP_TYPE_PIE:
+            if (width < 32)        // 32px minimum size
+                gtk_widget_set_size_request (widget, 32, 32);
+            if (width < height)
+                radius = width / 2;
+            else
+                radius = height / 2;
+
+            arc_start = -G_PI_2 + 2 * G_PI * priv->fraction;
+            arc_end = -G_PI_2;
+
+            cairo_set_line_width (cr, 1);
+
+            // Draw external stroke and fill
+            if (priv->fraction < 0.01) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_end);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    arc_end, arc_start);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_start);
+            }
+            cairo_fill_preserve (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.7);
+            cairo_stroke (cr);
+
+            // Draw internal highlight
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.45);
+            cairo_set_line_width (cr, 1);
+
+            if (priv->fraction < 0.03) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_end - (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    arc_end - (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+            }
+            cairo_stroke (cr);
+
+            // Draw external shape
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.2);
+            cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 1.25, 0,
+                G_PI * 2);
+            cairo_stroke (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_IN:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                    fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/download.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 8.5, 1.5);
+            cairo_line_to (cr, 23.5, 1.5);
+            cairo_line_to (cr, 23.5, 11.5);
+            cairo_line_to (cr, 29.5, 11.5);
+            cairo_line_to (cr, 16.5, 27.5);
+            cairo_line_to (cr, 15.5, 27.5);
+            cairo_line_to (cr, 2.5, 11.5);
+            cairo_line_to (cr, 8.5, 11.5);
+            cairo_line_to (cr, 8.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_OUT:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/upload.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 16.5, 1.5);
+            cairo_line_to (cr, 29.5, 17.5);
+            cairo_line_to (cr, 23.5, 17.5);
+            cairo_line_to (cr, 23.5, 27.5);
+            cairo_line_to (cr, 8.5, 27.5);
+            cairo_line_to (cr, 8.5, 17.5);
+            cairo_line_to (cr, 2.5, 17.5);
+            cairo_line_to (cr, 15.5, 1.5);
+            cairo_line_to (cr, 16.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        }
+    cairo_destroy (cr);
+}
+
+/* Handle exposure events for the color picker's drawing area */
+static gboolean draw (GtkWidget * widget, cairo_t * cr, gpointer data)
+{
+    render (GTK_WIDGET (data));
+
+    return FALSE;
+}
+
+static void
+gsm_color_button_realize (GtkWidget * widget)
+{
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->realize (widget);
+    render (widget);
+}
+
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width)
+{
+    g_return_if_fail (widget != NULL && minimum_width != NULL && natural_width != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_width = GSMCP_MIN_WIDTH;
+    *natural_width = GSMCP_MIN_WIDTH;
+}
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height)
+{
+    g_return_if_fail (widget != NULL && minimum_height != NULL && natural_height != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_height = GSMCP_MIN_HEIGHT;
+    *natural_height = GSMCP_MIN_HEIGHT;
+}
+
+static void
+gsm_color_button_size_allocate (GtkWidget * widget,
+                                GtkAllocation * allocation)
+{
+    g_return_if_fail (widget != NULL || allocation != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    gtk_widget_set_allocation (widget, allocation);
+
+    if (gtk_widget_get_realized (widget))
+    {
+        gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y,
+                                allocation->width, allocation->height);
+    }
+}
+
+static void
+gsm_color_button_unrealize (GtkWidget * widget)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->unrealize (widget);
+}
+
+static void
+gsm_color_button_style_set (GtkWidget * widget, GtkStyle * previous_style)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->style_set (widget,
+                                                                 previous_style);
+
+}
+
+static void
+gsm_color_button_state_changed (GtkWidget * widget,
+                                GtkStateType previous_state)
+{
+}
+
+static void
+gsm_color_button_drag_data_received (GtkWidget * widget,
+                                     GdkDragContext * context,
+                                     gint x,
+                                     gint y,
+                                     GtkSelectionData * selection_data,
+                                     guint info,
+                                     guint32 time,
+                                     GSMColorButton * color_button)
+{
+    gint length;
+    guint16 *dropped;
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    length = gtk_selection_data_get_length (selection_data);
+
+    if (length < 0)
+        return;
+
+    /* We accept drops with the wrong format, since the KDE color
+     * chooser incorrectly drops application/x-color with format 8.
+     */
+    if (length != 8)
+    {
+        g_warning (_("Received invalid color data\n"));
+        return;
+    }
+
+    dropped = (guint16 *) gtk_selection_data_get_data (selection_data);
+
+    priv->color.red =   ((double) dropped[0]) / 65535.0;
+    priv->color.green = ((double) dropped[1]) / 65535.0;
+    priv->color.blue =  ((double) dropped[2]) / 65535.0;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+    g_object_freeze_notify (G_OBJECT (color_button));
+    g_object_notify (G_OBJECT (color_button), "color");
+    g_object_thaw_notify (G_OBJECT (color_button));
+}
+
+static void
+set_color_icon (GdkDragContext * context, GdkRGBA * color)
+{
+    GdkPixbuf *pixbuf;
+    guint32 pixel;
+
+    pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 48, 32);
+
+    pixel = ((guint32)(color->red * 0xff) << 24) |
+            ((guint32)(color->green * 0xff) << 16) |
+            ((guint32)(color->blue * 0xff) << 8);
+
+    gdk_pixbuf_fill (pixbuf, pixel);
+
+    gtk_drag_set_icon_pixbuf (context, pixbuf, -2, -2);
+    g_object_unref (pixbuf);
+}
+
+static void
+gsm_color_button_drag_begin (GtkWidget * widget,
+                             GdkDragContext * context, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = data;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    set_color_icon (context, &priv->color);
+}
+
+static void
+gsm_color_button_drag_data_get (GtkWidget * widget,
+                                GdkDragContext * context,
+                                GtkSelectionData * selection_data,
+                                guint info,
+                                guint time, GSMColorButton * color_button)
+{
+    guint16 dropped[4];
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    dropped[0] = (guint16) (65535.0 * priv->color.red);
+    dropped[1] = (guint16) (65535.0 * priv->color.green);
+    dropped[2] = (guint16) (65535.0 * priv->color.blue);
+    dropped[3] = 65535;        // This widget doesn't care about alpha
+
+    gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data),
+                            16, (guchar *) dropped, 8);
+}
+
+static void
+gsm_color_button_init (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = 0;
+    priv->color.green = 0;
+    priv->color.blue = 0;
+    priv->fraction = 0.5;
+    priv->type = GSMCP_TYPE_CPU;
+    priv->image_buffer = NULL;
+    priv->title = g_strdup (_("Pick a Color"));     /* default title */
+    priv->in_button = FALSE;
+    priv->button_down = FALSE;
+
+    gtk_drag_dest_set (GTK_WIDGET (color_button),
+                       GTK_DEST_DEFAULT_MOTION |
+                       GTK_DEST_DEFAULT_HIGHLIGHT |
+                       GTK_DEST_DEFAULT_DROP, drop_types, 1, GDK_ACTION_COPY);
+    gtk_drag_source_set (GTK_WIDGET (color_button),
+                         GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
+                         drop_types, 1, GDK_ACTION_COPY);
+    g_signal_connect (color_button, "drag_begin",
+                      G_CALLBACK (gsm_color_button_drag_begin), color_button);
+    g_signal_connect (color_button, "drag_data_received",
+                      G_CALLBACK (gsm_color_button_drag_data_received),
+                      color_button);
+    g_signal_connect (color_button, "drag_data_get",
+                      G_CALLBACK (gsm_color_button_drag_data_get),
+                      color_button);
+
+    gtk_widget_add_events (GTK_WIDGET(color_button), GDK_ENTER_NOTIFY_MASK
+                              | GDK_LEAVE_NOTIFY_MASK);
+
+    gtk_widget_set_tooltip_text (GTK_WIDGET(color_button), _("Click to set graph colors"));
+
+    g_signal_connect (color_button, "draw", G_CALLBACK (draw), color_button);
+}
+
+static void
+gsm_color_button_finalize (GObject * object)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    if (priv->cc_dialog != NULL)
+        gtk_widget_destroy (priv->cc_dialog);
+    priv->cc_dialog = NULL;
+
+    g_free (priv->title);
+    priv->title = NULL;
+
+    cairo_surface_destroy (priv->image_buffer);
+    priv->image_buffer = NULL;
+
+    G_OBJECT_CLASS (gsm_color_button_parent_class)->finalize (object);
+}
+
+GtkWidget *
+gsm_color_button_new (const GdkRGBA * color, guint type)
+{
+    return g_object_new (GSM_TYPE_COLOR_BUTTON, "color", color, "type", type,
+                         NULL);
+}
+
+static void
+dialog_response (GtkWidget * widget, GtkResponseType response, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GtkColorChooser *color_chooser;
+
+    if (response == GTK_RESPONSE_OK) {
+        color_chooser = GTK_COLOR_CHOOSER (priv->cc_dialog);
+
+        gtk_color_chooser_get_rgba (color_chooser, &priv->color);
+
+        gtk_widget_hide (priv->cc_dialog);
+
+        gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+        g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+        g_object_freeze_notify (G_OBJECT (color_button));
+        g_object_notify (G_OBJECT (color_button), "color");
+        g_object_thaw_notify (G_OBJECT (color_button));
+    }
+    else  /* (response == GTK_RESPONSE_CANCEL) */
+        gtk_widget_hide (priv->cc_dialog);
+}
+
+static gboolean
+dialog_destroy (GtkWidget * widget, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->cc_dialog = NULL;
+
+    return FALSE;
+}
+
+static gint
+gsm_color_button_clicked (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    /* if dialog already exists, make sure it's shown and raised */
+    if (!priv->cc_dialog)
+    {
+        /* Create the dialog and connects its buttons */
+        GtkWidget *cc_dialog;
+        GtkWidget *parent;
+
+        parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));
+        if (!gtk_widget_is_toplevel (parent))
+            parent = NULL;
+
+        cc_dialog = gtk_color_chooser_dialog_new (priv->title, GTK_WINDOW (parent));
+
+        gtk_window_set_modal (GTK_WINDOW (cc_dialog), TRUE);
+
+        g_signal_connect (cc_dialog, "response",
+                          G_CALLBACK (dialog_response), color_button);
+
+        g_signal_connect (cc_dialog, "destroy",
+                          G_CALLBACK (dialog_destroy), color_button);
+
+        priv->cc_dialog = cc_dialog;
+    }
+
+    gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (priv->cc_dialog),
+                                &priv->color);
+
+    gtk_window_present (GTK_WINDOW (priv->cc_dialog));
+
+    return 0;
+}
+
+static gint
+gsm_color_button_pressed (GtkWidget * widget, GdkEventButton * event)
+{
+    if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) )
+    {
+	GSMColorButtonPrivate *priv;
+        GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+	priv = gsm_color_button_get_instance_private (color_button);
+	priv->button_down = TRUE;
+    }
+  return 0;
+}
+
+static gint
+gsm_color_button_released (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    if (priv->button_down && priv->in_button)
+        gsm_color_button_clicked (widget, event);
+    priv->button_down = FALSE;
+    return 0;
+}
+
+static gboolean
+gsm_color_button_enter_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 1.0;
+    priv->in_button = TRUE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+static gboolean
+gsm_color_button_leave_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 0;
+    priv->in_button = FALSE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+guint
+gsm_color_button_get_cbtype (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->type;
+}
+
+void
+gsm_color_button_set_cbtype (GSMColorButton * color_button, guint type)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->type = type;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "type");
+}
+
+gdouble
+gsm_color_button_get_fraction (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->fraction;
+}
+
+void
+gsm_color_button_set_fraction (GSMColorButton * color_button,
+                               gdouble fraction)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->fraction = fraction;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "fraction");
+}
+
+void
+gsm_color_button_get_color (GSMColorButton * color_button, GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    color->red = priv->color.red;
+    color->green = priv->color.green;
+    color->blue = priv->color.blue;
+    color->alpha = priv->color.alpha;
+}
+
+void
+gsm_color_button_set_color (GSMColorButton * color_button,
+                            const GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    g_return_if_fail (color != NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = color->red;
+    priv->color.green = color->green;
+    priv->color.blue = color->blue;
+    priv->color.alpha = color->alpha;
+
+    gtk_widget_queue_draw (GTK_WIDGET (color_button));
+
+    g_object_notify (G_OBJECT (color_button), "color");
+}
+
+void
+gsm_color_button_set_title (GSMColorButton * color_button,
+                            const gchar * title)
+{
+    gchar *old_title;
+    GSMColorButtonPrivate *priv;
+
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    old_title = priv->title;
+    priv->title = g_strdup (title);
+    g_free (old_title);
+
+    if (priv->cc_dialog)
+        gtk_window_set_title (GTK_WINDOW (priv->cc_dialog),
+                              priv->title);
+
+    g_object_notify (G_OBJECT (color_button), "title");
+}
+
+const gchar* gsm_color_button_get_title(GSMColorButton* color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail(GSM_IS_COLOR_BUTTON(color_button), NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->title;
+}
+
+static void
+gsm_color_button_set_property (GObject * object,
+                               guint param_id,
+                               const GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            gsm_color_button_set_fraction (color_button,
+                                           g_value_get_double (value));
+            break;
+        case PROP_TITLE:
+            gsm_color_button_set_title (color_button, g_value_get_string (value));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_set_color (color_button, g_value_get_boxed (value));
+            break;
+        case PROP_TYPE:
+            gsm_color_button_set_cbtype (color_button, g_value_get_uint (value));
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+static void
+gsm_color_button_get_property (GObject * object,
+                               guint param_id,
+                               GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+    GdkRGBA color;
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            g_value_set_double (value,
+                                gsm_color_button_get_fraction (color_button));
+            break;
+        case PROP_TITLE:
+            g_value_set_string (value, gsm_color_button_get_title (color_button));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_get_color (color_button, &color);
+                                        g_value_set_boxed (value, &color);
+            break;
+        case PROP_TYPE:
+            g_value_set_uint (value, gsm_color_button_get_cbtype (color_button));
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/6.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/6.html new file mode 100644 index 00000000..f73c90ba --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/6.html @@ -0,0 +1,1599 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
/* Procman - main window
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <gdk/gdkkeysyms.h>
+#include <math.h>
+
+#include "procman.h"
+#include "callbacks.h"
+#include "interface.h"
+#include "proctable.h"
+#include "procactions.h"
+#include "load-graph.h"
+#include "util.h"
+#include "disks.h"
+#include "sysinfo.h"
+#include "gsm_color_button.h"
+
+static void    cb_toggle_tree (GtkAction *action, gpointer data);
+static void    cb_proc_goto_tab (gint tab);
+
+static const GtkActionEntry menu_entries[] =
+{
+    // xgettext: noun, top level menu.
+    // "File" did not make sense for system-monitor
+    { "Monitor", NULL, N_("_Monitor") },
+    { "Edit", NULL, N_("_Edit") },
+    { "View", NULL, N_("_View") },
+    { "Help", NULL, N_("_Help") },
+
+    { "Lsof", "edit-find", N_("Search for _Open Files"), "<control>O",
+      N_("Search for open files"), G_CALLBACK(cb_show_lsof) },
+    { "Quit", "application-exit", N_("_Quit"), "<control>Q",
+      N_("Quit the program"), G_CALLBACK (cb_app_exit) },
+
+
+    { "StopProcess", NULL, N_("_Stop Process"), "<control>S",
+      N_("Stop process"), G_CALLBACK(cb_kill_sigstop) },
+    { "ContProcess", NULL, N_("_Continue Process"), "<control>C",
+      N_("Continue process if stopped"), G_CALLBACK(cb_kill_sigcont) },
+
+    { "EndProcess", NULL, N_("_End Process"), "<control>E",
+      N_("Force process to finish normally"), G_CALLBACK (cb_end_process) },
+    { "KillProcess", NULL, N_("_Kill Process"), "<control>K",
+      N_("Force process to finish immediately"), G_CALLBACK (cb_kill_process) },
+    { "ChangePriority", NULL, N_("_Change Priority"), NULL,
+      N_("Change the order of priority of process"), NULL },
+    { "Preferences", "preferences-desktop", N_("_Preferences"), NULL,
+      N_("Configure the application"), G_CALLBACK (cb_edit_preferences) },
+
+    { "Refresh", "view-refresh", N_("_Refresh"), "<control>R",
+      N_("Refresh the process list"), G_CALLBACK(cb_user_refresh) },
+
+    { "MemoryMaps", NULL, N_("_Memory Maps"), "<control>M",
+      N_("Open the memory maps associated with a process"), G_CALLBACK (cb_show_memory_maps) },
+    // Translators: this means 'Files that are open' (open is no verb here
+    { "OpenFiles", NULL, N_("Open _Files"), "<control>F",
+      N_("View the files opened by a process"), G_CALLBACK (cb_show_open_files) },
+    { "ProcessProperties", NULL, N_("_Properties"), NULL,
+      N_("View additional information about a process"), G_CALLBACK (cb_show_process_properties) },
+
+
+    { "HelpContents", "help-browser", N_("_Contents"), "F1",
+      N_("Open the manual"), G_CALLBACK (cb_help_contents) },
+    { "About", "help-about", N_("_About"), NULL,
+      N_("About this application"), G_CALLBACK (cb_about) }
+};
+
+static const GtkToggleActionEntry toggle_menu_entries[] =
+{
+    { "ShowDependencies", NULL, N_("_Dependencies"), "<control>D",
+      N_("Show parent/child relationship between processes"),
+      G_CALLBACK (cb_toggle_tree), TRUE },
+};
+
+
+static const GtkRadioActionEntry radio_menu_entries[] =
+{
+  { "ShowActiveProcesses", NULL, N_("_Active Processes"), NULL,
+    N_("Show active processes"), ACTIVE_PROCESSES },
+  { "ShowAllProcesses", NULL, N_("A_ll Processes"), NULL,
+    N_("Show all processes"), ALL_PROCESSES },
+  { "ShowMyProcesses", NULL, N_("M_y Processes"), NULL,
+    N_("Show only user-owned processes"), MY_PROCESSES }
+};
+
+static const GtkRadioActionEntry priority_menu_entries[] =
+{
+    { "VeryHigh", NULL, N_("Very High"), NULL,
+      N_("Set process priority to very high"), VERY_HIGH_PRIORITY },
+    { "High", NULL, N_("High"), NULL,
+      N_("Set process priority to high"), HIGH_PRIORITY },
+    { "Normal", NULL, N_("Normal"), NULL,
+      N_("Set process priority to normal"), NORMAL_PRIORITY },
+    { "Low", NULL, N_("Low"), NULL,
+      N_("Set process priority to low"), LOW_PRIORITY },
+    { "VeryLow", NULL, N_("Very Low"), NULL,
+      N_("Set process priority to very low"), VERY_LOW_PRIORITY },
+    { "Custom", NULL, N_("Custom"), NULL,
+      N_("Set process priority manually"), CUSTOM_PRIORITY }
+};
+
+
+static const char ui_info[] =
+    "  <menubar name=\"MenuBar\">"
+    "    <menu name=\"MonitorMenu\" action=\"Monitor\">"
+    "      <menuitem name=\"MonitorLsofMenu\" action=\"Lsof\" />"
+    "      <menuitem name=\"MonitorQuitMenu\" action=\"Quit\" />"
+    "    </menu>"
+    "    <menu name=\"EditMenu\" action=\"Edit\">"
+    "      <menuitem name=\"EditStopProcessMenu\" action=\"StopProcess\" />"
+    "      <menuitem name=\"EditContProcessMenu\" action=\"ContProcess\" />"
+    "      <separator />"
+    "      <menuitem name=\"EditEndProcessMenu\" action=\"EndProcess\" />"
+    "      <menuitem name=\"EditKillProcessMenu\" action=\"KillProcess\" />"
+    "      <separator />"
+    "      <menu name=\"EditChangePriorityMenu\" action=\"ChangePriority\" >"
+    "        <menuitem action=\"VeryHigh\" />"
+    "        <menuitem action=\"High\" />"
+    "        <menuitem action=\"Normal\" />"
+    "        <menuitem action=\"Low\" />"
+    "        <menuitem action=\"VeryLow\" />"
+    "        <separator />"
+    "        <menuitem action=\"Custom\"/>"
+    "      </menu>"
+    "      <separator />"
+    "      <menuitem name=\"EditPreferencesMenu\" action=\"Preferences\" />"
+    "    </menu>"
+    "    <menu name=\"ViewMenu\" action=\"View\">"
+    "      <menuitem name=\"ViewActiveProcesses\" action=\"ShowActiveProcesses\" />"
+    "      <menuitem name=\"ViewAllProcesses\" action=\"ShowAllProcesses\" />"
+    "      <menuitem name=\"ViewMyProcesses\" action=\"ShowMyProcesses\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewDependenciesMenu\" action=\"ShowDependencies\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewMemoryMapsMenu\" action=\"MemoryMaps\" />"
+    "      <menuitem name=\"ViewOpenFilesMenu\" action=\"OpenFiles\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewProcessPropertiesMenu\" action=\"ProcessProperties\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewRefresh\" action=\"Refresh\" />"
+    "    </menu>"
+    "    <menu name=\"HelpMenu\" action=\"Help\">"
+    "      <menuitem name=\"HelpContentsMenu\" action=\"HelpContents\" />"
+    "      <menuitem name=\"HelpAboutMenu\" action=\"About\" />"
+    "    </menu>"
+    "  </menubar>"
+    "  <popup name=\"PopupMenu\" action=\"Popup\">"
+    "    <menuitem action=\"StopProcess\" />"
+    "    <menuitem action=\"ContProcess\" />"
+    "    <separator />"
+    "    <menuitem action=\"EndProcess\" />"
+    "    <menuitem action=\"KillProcess\" />"
+    "    <separator />"
+    "    <menu name=\"ChangePriorityMenu\" action=\"ChangePriority\" >"
+    "      <menuitem action=\"VeryHigh\" />"
+    "      <menuitem action=\"High\" />"
+    "      <menuitem action=\"Normal\" />"
+    "      <menuitem action=\"Low\" />"
+    "      <menuitem action=\"VeryLow\" />"
+    "      <separator />"
+    "      <menuitem action=\"Custom\"/>"
+    "    </menu>"
+    "    <separator />"
+    "    <menuitem action=\"MemoryMaps\" />"
+    "    <menuitem action=\"OpenFiles\" />"
+    "    <separator />"
+    "    <menuitem action=\"ProcessProperties\" />"
+
+    "  </popup>";
+
+
+static void
+create_proc_view(ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *proctree;
+    GtkWidget *scrolled;
+    char* string;
+
+    /* create the processes tab */
+    string = make_loadavg_string ();
+    procdata->loadavg = GTK_WIDGET (gtk_builder_get_object (builder, "load_avg_label"));
+    gtk_label_set_text (GTK_LABEL (procdata->loadavg), string);
+    g_free (string);
+
+    proctree = proctable_new (procdata);
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "processes_scrolled"));
+
+    gtk_container_add (GTK_CONTAINER (scrolled), proctree);
+
+    procdata->endprocessbutton = GTK_WIDGET (gtk_builder_get_object (builder, "endprocessbutton"));
+    g_signal_connect (G_OBJECT (procdata->endprocessbutton), "clicked",
+                      G_CALLBACK (cb_end_process_button_pressed), procdata);
+
+    /* create popup_menu for the processes tab */
+    procdata->popup_menu = gtk_ui_manager_get_widget (procdata->uimanager, "/PopupMenu");
+}
+
+
+GtkWidget *
+make_title_label (const char *text)
+{
+    GtkWidget *label;
+    char *full;
+
+    full = g_strdup_printf ("<span weight=\"bold\">%s</span>", text);
+    label = gtk_label_new (full);
+    g_free (full);
+
+    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+
+    return label;
+}
+
+
+static void
+create_sys_view (ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *cpu_graph_box, *mem_graph_box, *net_graph_box;
+    GtkWidget *label,*cpu_label;
+    GtkWidget *table;
+    GtkWidget *color_picker;
+    GtkWidget *picker_alignment;
+    LoadGraph *cpu_graph, *mem_graph, *net_graph;
+
+    gint i;
+    gchar *title_text;
+    gchar *label_text;
+    gchar *title_template;
+
+    // Translators: color picker title, %s is CPU, Memory, Swap, Receiving, Sending
+    title_template = g_strdup(_("Pick a Color for '%s'"));
+
+    /* The CPU BOX */
+
+    cpu_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_graph_box"));
+
+    cpu_graph = new LoadGraph(LOAD_GRAPH_CPU);
+    gtk_box_pack_start (GTK_BOX (cpu_graph_box),
+                        load_graph_get_widget(cpu_graph),
+                        TRUE,
+                        TRUE,
+                         0);
+
+    GtkWidget* flowbox = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_flow_box"));
+    gtk_box_reorder_child (GTK_BOX (cpu_graph_box), flowbox, 1);
+    for (i=0;i<procdata->config.num_cpus; i++) {
+        GtkWidget *temp_hbox;
+
+        temp_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
+        gtk_container_add (GTK_CONTAINER (flowbox), temp_hbox);
+
+        color_picker = gsm_color_button_new (&cpu_graph->colors.at(i), GSMCP_TYPE_CPU);
+        g_signal_connect (G_OBJECT (color_picker), "color_set",
+                          G_CALLBACK (cb_cpu_color_changed), GINT_TO_POINTER (i));
+        gtk_box_pack_start (GTK_BOX (temp_hbox), color_picker, FALSE, TRUE, 0);
+        gtk_widget_set_size_request(GTK_WIDGET(color_picker), 32, -1);
+        if(procdata->config.num_cpus == 1) {
+            label_text = g_strdup (_("CPU"));
+        } else {
+            label_text = g_strdup_printf (_("CPU%d"), i+1);
+        }
+        title_text = g_strdup_printf(title_template, label_text);
+        label = gtk_label_new (label_text);
+        gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+        g_free(title_text);
+        gtk_box_pack_start (GTK_BOX (temp_hbox), label, FALSE, FALSE, 6);
+        g_free (label_text);
+
+        cpu_label = gtk_label_new (NULL);
+        gtk_label_set_width_chars (GTK_LABEL (cpu_label), 7);
+        gtk_label_set_xalign (GTK_LABEL (cpu_label), 0.0);
+
+        gtk_box_pack_start (GTK_BOX (temp_hbox), cpu_label, TRUE, TRUE, 0);
+        load_graph_get_labels(cpu_graph)->cpu[i] = cpu_label;
+
+    }
+
+    procdata->cpu_graph = cpu_graph;
+
+    /** The memory box */
+    mem_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "mem_graph_box"));
+
+    mem_graph = new LoadGraph(LOAD_GRAPH_MEM);
+    gtk_box_pack_start (GTK_BOX (mem_graph_box),
+                        load_graph_get_widget(mem_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "mem_table"));
+
+    color_picker = load_graph_get_mem_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_mem_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Memory"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 0, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->memory;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 1, 1, 1, 1);
+
+    color_picker = load_graph_get_swap_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_swap_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Swap"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 2, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->swap;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 3, 1, 1, 1);
+
+    procdata->mem_graph = mem_graph;
+
+    /* The net box */
+    net_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "net_graph_box"));
+
+    net_graph = new LoadGraph(LOAD_GRAPH_NET);
+    gtk_box_pack_start (GTK_BOX (net_graph_box),
+                        load_graph_get_widget(net_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "net_table"));
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(0), GSMCP_TYPE_NETWORK_IN);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_in_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Receiving"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "receiving_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_in;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_in_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 1, 1, 1);
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(1), GSMCP_TYPE_NETWORK_OUT);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_out_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Sending"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "sending_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_out;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_out_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 1, 1, 1);
+
+    procdata->net_graph = net_graph;
+    g_free(title_template);
+}
+
+static void
+menu_item_select_cb (GtkMenuItem *proxy,
+                     ProcData *procdata)
+{
+    GtkAction *action;
+    char *message;
+
+    action = gtk_activatable_get_related_action (GTK_ACTIVATABLE(proxy));
+    g_assert(action);
+
+    g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
+    if (message)
+    {
+        gtk_statusbar_push (GTK_STATUSBAR (procdata->statusbar),
+                    procdata->tip_message_cid, message);
+        g_free (message);
+    }
+}
+
+static void
+menu_item_deselect_cb (GtkMenuItem *proxy,
+                       ProcData *procdata)
+{
+    gtk_statusbar_pop (GTK_STATUSBAR (procdata->statusbar),
+               procdata->tip_message_cid);
+}
+
+static void
+connect_proxy_cb (GtkUIManager *manager,
+                  GtkAction *action,
+                  GtkWidget *proxy,
+                  ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_connect (proxy, "select",
+                          G_CALLBACK (menu_item_select_cb), procdata);
+        g_signal_connect (proxy, "deselect",
+                          G_CALLBACK (menu_item_deselect_cb), procdata);
+    }
+}
+
+static void
+disconnect_proxy_cb (GtkUIManager *manager,
+                     GtkAction *action,
+                     GtkWidget *proxy,
+                     ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_select_cb)), procdata);
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_deselect_cb)), procdata);
+    }
+}
+
+void
+create_main_window (ProcData *procdata)
+{
+    gint i;
+    gint width, height, xpos, ypos;
+    GtkWidget *app;
+    GtkAction *action;
+    GtkWidget *menubar;
+    GtkWidget *main_box;
+    GtkWidget *notebook;
+    GtkBuilder *builder;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/interface.ui");
+
+    app = GTK_WIDGET (gtk_builder_get_object (builder, "main_window"));
+    main_box = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
+
+    GdkScreen* screen = gtk_widget_get_screen(app);
+    /* use visual, if available */
+    GdkVisual* visual = gdk_screen_get_rgba_visual(screen);
+    if (visual)
+        gtk_widget_set_visual(app, visual);
+
+    width = procdata->config.width;
+    height = procdata->config.height;
+    xpos = procdata->config.xpos;
+    ypos = procdata->config.ypos;
+    gtk_window_set_default_size (GTK_WINDOW (app), width, height);
+    gtk_window_move(GTK_WINDOW (app), xpos, ypos);
+
+    if (procdata->config.maximized) {
+        gtk_window_maximize(GTK_WINDOW(app));
+    }
+
+    /* create the menubar */
+    procdata->uimanager = gtk_ui_manager_new ();
+
+    /* show tooltips in the statusbar */
+    g_signal_connect (procdata->uimanager, "connect_proxy",
+                      G_CALLBACK (connect_proxy_cb), procdata);
+    g_signal_connect (procdata->uimanager, "disconnect_proxy",
+                      G_CALLBACK (disconnect_proxy_cb), procdata);
+
+    gtk_window_add_accel_group (GTK_WINDOW (app),
+                                gtk_ui_manager_get_accel_group (procdata->uimanager));
+
+    if (!gtk_ui_manager_add_ui_from_string (procdata->uimanager,
+                                            ui_info,
+                                            -1,
+                                            NULL)) {
+        g_error("building menus failed");
+    }
+
+    procdata->action_group = gtk_action_group_new ("ProcmanActions");
+    gtk_action_group_set_translation_domain (procdata->action_group, NULL);
+    gtk_action_group_add_actions (procdata->action_group,
+                                  menu_entries,
+                                  G_N_ELEMENTS (menu_entries),
+                                  procdata);
+    gtk_action_group_add_toggle_actions (procdata->action_group,
+                                         toggle_menu_entries,
+                                         G_N_ELEMENTS (toggle_menu_entries),
+                                         procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                        radio_menu_entries,
+                        G_N_ELEMENTS (radio_menu_entries),
+                        procdata->config.whose_process,
+                        G_CALLBACK(cb_radio_processes),
+                        procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                                        priority_menu_entries,
+                                        G_N_ELEMENTS (priority_menu_entries),
+                                        NORMAL_PRIORITY,
+                                        G_CALLBACK(cb_renice),
+                                        procdata);
+
+    gtk_ui_manager_insert_action_group (procdata->uimanager,
+                                        procdata->action_group,
+                                        0);
+
+    menubar = gtk_ui_manager_get_widget (procdata->uimanager, "/MenuBar");
+    gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0);
+    gtk_box_reorder_child (GTK_BOX (main_box), menubar, 0);
+
+    /* create the main notebook */
+    procdata->notebook = notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
+
+    create_proc_view(procdata, builder);
+    create_sys_view (procdata, builder);
+    create_disk_view (procdata, builder);
+
+    g_signal_connect (G_OBJECT (notebook), "switch-page",
+              G_CALLBACK (cb_switch_page), procdata);
+    g_signal_connect (G_OBJECT (notebook), "change-current-page",
+              G_CALLBACK (cb_change_current_page), procdata);
+
+    gtk_widget_show_all(notebook); // need to make page switch work
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab);
+    cb_change_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab, procdata);
+    g_signal_connect (G_OBJECT (app), "delete_event",
+                      G_CALLBACK (cb_app_delete),
+                      procdata);
+
+    GtkAccelGroup *accel_group;
+    GClosure *goto_tab_closure[4];
+    accel_group = gtk_accel_group_new ();
+    gtk_window_add_accel_group (GTK_WINDOW(app), accel_group);
+    for (i = 0; i < 4; ++i) {
+        goto_tab_closure[i] = g_cclosure_new_swap (G_CALLBACK (cb_proc_goto_tab),
+                                                   GINT_TO_POINTER (i), NULL);
+        gtk_accel_group_connect (accel_group, '0'+(i+1),
+                                 GDK_MOD1_MASK, GTK_ACCEL_VISIBLE,
+                                 goto_tab_closure[i]);
+    }
+
+    /* create the statusbar */
+    procdata->statusbar = GTK_WIDGET (gtk_builder_get_object (builder, "statusbar"));
+    procdata->tip_message_cid = gtk_statusbar_get_context_id
+        (GTK_STATUSBAR (procdata->statusbar), "tip_message");
+
+    action = gtk_action_group_get_action (procdata->action_group, "ShowDependencies");
+    gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+                      procdata->config.show_tree);
+
+    gtk_builder_connect_signals (builder, NULL);
+
+    gtk_widget_show_all(app);
+    procdata->app = app;
+
+    g_object_unref (G_OBJECT (builder));
+}
+
+void
+do_popup_menu (ProcData *procdata, GdkEventButton *event)
+{
+    gtk_menu_popup_at_pointer (GTK_MENU (procdata->popup_menu), NULL);
+}
+
+void
+update_sensitivity(ProcData *data)
+{
+    const char * const selected_actions[] = { "StopProcess",
+                                              "ContProcess",
+                                              "EndProcess",
+                                              "KillProcess",
+                                              "ChangePriority",
+                                              "MemoryMaps",
+                                              "OpenFiles",
+                                              "ProcessProperties" };
+
+    const char * const processes_actions[] = { "ShowActiveProcesses",
+                                               "ShowAllProcesses",
+                                               "ShowMyProcesses",
+                                               "ShowDependencies",
+                                               "Refresh"
+    };
+
+    size_t i;
+    gboolean processes_sensitivity, selected_sensitivity;
+    GtkAction *action;
+
+    processes_sensitivity = (data->config.current_tab == PROCMAN_TAB_PROCESSES);
+    selected_sensitivity = (processes_sensitivity && data->selection && gtk_tree_selection_count_selected_rows (data->selection) > 0);
+
+    if(data->endprocessbutton) {
+        /* avoid error on startup if endprocessbutton
+           has not been built yet */
+        gtk_widget_set_sensitive(data->endprocessbutton, selected_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(processes_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             processes_actions[i]);
+        gtk_action_set_sensitive(action, processes_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(selected_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             selected_actions[i]);
+        gtk_action_set_sensitive(action, selected_sensitivity);
+    }
+}
+
+void
+block_priority_changed_handlers(ProcData *data, bool block)
+{
+    gint i;
+    if (block) {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_block_by_func(action, (gpointer)cb_renice, data);
+        }
+    } else {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_unblock_by_func(action, (gpointer)cb_renice, data);
+        }
+    }
+}
+
+static void
+cb_toggle_tree (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GSettings *settings = procdata->settings;
+    gboolean show;
+
+    show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+    if (show == procdata->config.show_tree)
+        return;
+
+    g_settings_set_boolean (settings, "show-tree", show);
+}
+
+static void
+cb_proc_goto_tab (gint tab)
+{
+    ProcData *data = ProcData::get_instance ();
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (data->notebook), tab);
+}
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/7.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/7.html new file mode 100644 index 00000000..8b385037 --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/7.html @@ -0,0 +1,1939 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
#include <config.h>
+
+#include <gdkmm/pixbuf.h>
+
+#include <stdio.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <signal.h>
+#include <dirent.h>
+#include <string.h>
+#include <time.h>
+
+#include <glib/gi18n.h>
+
+#include <glibtop.h>
+#include <glibtop/cpu.h>
+#include <glibtop/mem.h>
+#include <glibtop/swap.h>
+#include <glibtop/netload.h>
+#include <glibtop/netlist.h>
+#include <math.h>
+
+#include <algorithm>
+
+#include "procman.h"
+#include "load-graph.h"
+#include "util.h"
+#include "gsm_color_button.h"
+
+void LoadGraph::clear_background()
+{
+    if (background) {
+        cairo_pattern_destroy (background);
+        this->background = NULL;
+    }
+}
+
+
+unsigned LoadGraph::num_bars() const
+{
+    unsigned n;<--- Shadow variable
+
+    // keep 100 % num_bars == 0
+    switch (static_cast<int>(this->draw_height / (fontsize + 14)))
+    {
+    case 0:
+    case 1:
+        n = 1;
+        break;
+    case 2:
+    case 3:
+        n = 2;
+        break;
+    case 4:
+        n = 4;
+        break;
+    default:
+        n = 5;
+    }
+
+    return n;
+}
+
+
+
+#define FRAME_WIDTH 4
+static void draw_background(LoadGraph *graph) {
+    GtkAllocation allocation;
+    cairo_t *cr;
+    guint i;<--- Shadowed declaration
+    unsigned num_bars;
+    g_autofree gchar *caption;
+    PangoLayout* layout;
+    PangoFontDescription* font_desc;
+    PangoRectangle extents;
+    cairo_surface_t *surface;
+    GdkRGBA fg, bg;
+
+    num_bars = graph->num_bars();
+    graph->graph_dely = (graph->draw_height - 15) / num_bars; /* round to int to avoid AA blur */
+    graph->real_draw_height = graph->graph_dely * num_bars;
+    graph->graph_delx = (graph->draw_width - 2.0 - graph->rmargin - graph->indent) / (LoadGraph::NUM_POINTS - 3);
+    graph->graph_buffer_offset = (int) (1.5 * graph->graph_delx) + FRAME_WIDTH ;
+
+    gtk_widget_get_allocation (graph->disp, &allocation);
+    surface = gdk_window_create_similar_surface (gtk_widget_get_window (graph->disp), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height);
+    cr = cairo_create (surface);
+
+    GtkStyleContext *context = gtk_widget_get_style_context (ProcData::get_instance()->notebook);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get_background_color (context, gtk_style_context_get_state (context), &bg);
+    gtk_style_context_get_color (context, gtk_style_context_get_state (context), &fg);
+    gtk_style_context_restore (context);
+
+    // set the background color
+    gdk_cairo_set_source_rgba (cr, &bg);
+    cairo_paint (cr);
+
+    layout = pango_cairo_create_layout (cr);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get (context,
+                           gtk_style_context_get_state (context),
+                           GTK_STYLE_PROPERTY_FONT,
+                           &font_desc, NULL);
+    gtk_style_context_restore (context);
+    pango_font_description_set_size (font_desc, 0.8 * graph->fontsize * PANGO_SCALE);
+    pango_layout_set_font_description (layout, font_desc);
+    pango_font_description_free (font_desc);
+
+    /* draw frame */
+    cairo_translate (cr, FRAME_WIDTH, FRAME_WIDTH);
+
+    /* Draw background rectangle */
+    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+    cairo_rectangle (cr, graph->rmargin + graph->indent, 0,
+                     graph->draw_width - graph->rmargin - graph->indent, graph->real_draw_height);
+    cairo_fill(cr);
+
+    cairo_set_line_width (cr, 1.0);
+    cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    for (i = 0; i <= num_bars; ++i) {
+        double y;
+
+        if (i == 0)
+            y = 0.5 + graph->fontsize / 2.0;
+        else if (i == num_bars)
+            y = i * graph->graph_dely + 0.5;
+        else
+            y = i * graph->graph_dely + graph->fontsize / 2.0;
+
+        gdk_cairo_set_source_rgba (cr, &fg);
+        if (graph->type == LOAD_GRAPH_NET) {
+            // operation orders matters so it's 0 if i == num_bars
+            guint64 rate = graph->net.max - (i * graph->net.max / num_bars);
+            caption = g_format_size_full (network_in_bits ? rate*8 : rate, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        } else {
+            // operation orders matters so it's 0 if i == num_bars
+            caption = g_strdup_printf("%d%%", 100 - i * (100 / num_bars));
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        }
+
+        if (i==0 || i==num_bars)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, graph->rmargin + graph->indent - 3, i * graph->graph_dely + 0.5);
+        cairo_line_to (cr, graph->draw_width - 0.5, i * graph->graph_dely + 0.5);
+        cairo_stroke (cr);
+    }
+
+    const unsigned total_seconds = graph->speed * (LoadGraph::NUM_POINTS - 2) / 1000;
+
+    for (unsigned int i = 0; i < 7; i++) {<--- Shadow variable
+        double x = (i) * (graph->draw_width - graph->rmargin - graph->indent) / 6;
+        if (i==0 || i==6)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, 0.5);
+        cairo_line_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, graph->real_draw_height + 4.5);
+        cairo_stroke(cr);
+        unsigned seconds = total_seconds - i * total_seconds / 6;
+        const char* format;
+        if (i == 0)
+            format = dngettext(GETTEXT_PACKAGE, "%u second", "%u seconds", seconds);
+        else
+            format = "%u";
+        caption = g_strdup_printf(format, seconds);
+        pango_layout_set_text (layout, caption, -1);
+        pango_layout_get_extents (layout, NULL, &extents);
+        cairo_move_to (cr, ((ceil(x) + 0.5) + graph->rmargin + graph->indent) - (1.0 * extents.width / PANGO_SCALE/2), graph->draw_height - 1.0 * extents.height / PANGO_SCALE);
+        gdk_cairo_set_source_rgba (cr, &fg);
+        pango_cairo_show_layout (cr, layout);
+    }
+    g_object_unref(layout);
+    cairo_stroke (cr);
+    cairo_destroy (cr);
+    graph->background = cairo_pattern_create_for_surface (surface);
+    cairo_surface_destroy (surface);
+}
+
+/* Redraws the backing buffer for the load graph and updates the window */
+void
+load_graph_queue_draw (LoadGraph *graph)
+{
+    /* repaint */
+    gtk_widget_queue_draw (graph->disp);
+}
+
+static int load_graph_update (gpointer user_data); // predeclare load_graph_update so we can compile ;)
+
+static gboolean
+load_graph_configure (GtkWidget *widget,
+                      GdkEventConfigure *event,
+                      gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    gtk_widget_get_allocation (widget, &allocation);
+    graph->draw_width = allocation.width - 2 * FRAME_WIDTH;
+    graph->draw_height = allocation.height - 2 * FRAME_WIDTH;
+
+    graph->clear_background();
+
+    load_graph_queue_draw (graph);
+
+    return TRUE;
+}
+
+static gboolean load_graph_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+    GdkWindow *window;
+
+    guint i, j;
+    gdouble sample_width, x_offset;
+
+    window = gtk_widget_get_window (graph->disp);
+
+    /* Number of pixels wide for one graph point */
+    sample_width = (float)(graph->draw_width - graph->rmargin - graph->indent) / (float)LoadGraph::NUM_POINTS;
+    /* General offset */
+    x_offset = graph->draw_width - graph->rmargin + (sample_width*2);
+
+    /* Subframe offset */
+    x_offset += graph->rmargin - ((sample_width / graph->frames_per_unit) * graph->render_counter);
+
+    /* draw the graph */
+    cairo_t* cr;
+
+    cr = gdk_cairo_create (window);
+
+    if (graph->background == NULL) {
+        draw_background(graph);
+    }
+    cairo_set_source (cr, graph->background);
+    cairo_paint (cr);
+
+    cairo_set_line_width (cr, 1);
+    cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+    cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+    cairo_rectangle (cr, graph->rmargin + graph->indent + FRAME_WIDTH + 1, FRAME_WIDTH - 1,
+             graph->draw_width - graph->rmargin - graph->indent - 1, graph->real_draw_height + FRAME_WIDTH - 1);
+    cairo_clip(cr);
+
+    for (j = 0; j < graph->n; ++j) {
+        cairo_move_to (cr, x_offset, (1.0f - graph->data[0][j]) * graph->real_draw_height);
+        gdk_cairo_set_source_rgba (cr, &(graph->colors [j]));
+
+        for (i = 1; i < LoadGraph::NUM_POINTS; ++i) {
+            if (graph->data[i][j] == -1.0f)
+                continue;
+            cairo_curve_to (cr,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i-1][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - (i * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f);
+        }
+        cairo_stroke (cr);
+
+    }
+
+    cairo_destroy (cr);
+
+    return TRUE;
+}
+
+static void
+get_load (LoadGraph *graph)
+{
+    guint i;
+    glibtop_cpu cpu;
+
+    glibtop_get_cpu (&cpu);
+
+#undef NOW
+#undef LAST
+#define NOW  (graph->cpu.times[graph->cpu.now])
+#define LAST (graph->cpu.times[graph->cpu.now ^ 1])
+
+    if (graph->n == 1) {
+        NOW[0][CPU_TOTAL] = cpu.total;
+        NOW[0][CPU_USED] = cpu.user + cpu.nice + cpu.sys;
+    } else {
+        for (i = 0; i < graph->n; i++) {
+            NOW[i][CPU_TOTAL] = cpu.xcpu_total[i];
+            NOW[i][CPU_USED] = cpu.xcpu_user[i] + cpu.xcpu_nice[i]
+                + cpu.xcpu_sys[i];
+        }
+    }
+
+    // on the first call, LAST is 0
+    // which means data is set to the average load since boot
+    // that value has no meaning, we just want all the
+    // graphs to be aligned, so the CPU graph needs to start
+    // immediately
+
+    for (i = 0; i < graph->n; i++) {
+        float load;
+        float total, used;
+        gchar *text;
+
+        total = NOW[i][CPU_TOTAL] - LAST[i][CPU_TOTAL];
+        used  = NOW[i][CPU_USED]  - LAST[i][CPU_USED];
+
+        load = used / MAX(total, 1.0f);
+        graph->data[0][i] = load;
+
+        /* Update label */
+        text = g_strdup_printf("%.1f%%", load * 100.0f);
+        gtk_label_set_text(GTK_LABEL(graph->labels.cpu[i]), text);
+        g_free(text);
+    }
+
+    graph->cpu.now ^= 1;
+
+#undef NOW
+#undef LAST
+}
+
+
+namespace
+{
+
+    void set_memory_label_and_picker(GtkLabel* label, GSMColorButton* picker,
+                                   guint64 used, guint64 total, double percent)
+    {
+        char* used_text;
+        char* total_text;
+        char* text;
+
+        used_text = g_format_size_full(used, G_FORMAT_SIZE_IEC_UNITS);
+        total_text = g_format_size_full(total, G_FORMAT_SIZE_IEC_UNITS);
+        if (total == 0) {
+            text = g_strdup(_("not available"));
+        } else {
+            // xgettext: 540MiB (53 %) of 1.0 GiB
+            text = g_strdup_printf(_("%s (%.1f%%) of %s"), used_text, 100.0 * percent, total_text);
+        }
+        gtk_label_set_text(label, text);
+        g_free(used_text);
+        g_free(total_text);
+        g_free(text);
+
+        if (picker)
+            gsm_color_button_set_fraction(picker, percent);
+    }
+}
+
+static void
+get_memory (LoadGraph *graph)
+{
+    float mempercent, swappercent;
+
+    glibtop_mem mem;
+    glibtop_swap swap;
+
+    glibtop_get_mem (&mem);
+    glibtop_get_swap (&swap);
+
+    /* There's no swap on LiveCD : 0.0f is better than NaN :) */
+    swappercent = (swap.total ? (float)swap.used / (float)swap.total : 0.0f);
+    mempercent  = (float)mem.user  / (float)mem.total;
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.memory),
+                                GSM_COLOR_BUTTON(graph->mem_color_picker),
+                                mem.user, mem.total, mempercent);
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.swap),
+                                GSM_COLOR_BUTTON(graph->swap_color_picker),
+                                swap.used, swap.total, swappercent);
+
+    graph->data[0][0] = mempercent;
+    graph->data[0][1] = swappercent;
+}
+
+/* Nice Numbers for Graph Labels after Paul Heckbert
+   nicenum: find a "nice" number approximately equal to x.
+   Round the number if round=1, take ceiling if round=0    */
+
+static double
+nicenum (double x, int round)
+{
+    int expv;				/* exponent of x */
+    double f;				/* fractional part of x */
+    double nf;				/* nice, rounded fraction */
+
+    expv = floor( log10(x) );
+    f = x/pow( 10.0, expv );		/* between 1 and 10 */
+    if (round) {
+        if ( f < 1.5 ) nf = 1.0;
+        else if ( f < 3.0 ) nf = 2.0;
+        else if ( f < 7.0 ) nf = 5.0;
+        else nf = 10.0;
+    } else {
+        if ( f <= 1.0 ) nf = 1.0;
+        else if ( f <= 2.0 ) nf = 2.0;
+        else if ( f <= 5.0 ) nf = 5.0;
+        else nf = 10.0;
+    }
+    return nf * pow(10.0, expv);
+}
+
+static void
+net_scale (LoadGraph *graph, guint64 din, guint64 dout)
+{
+    graph->data[0][0] = 1.0f * din / graph->net.max;
+    graph->data[0][1] = 1.0f * dout / graph->net.max;
+
+    guint64 dmax = std::max(din, dout);
+    graph->net.values[graph->net.cur] = dmax;
+    graph->net.cur = (graph->net.cur + 1) % LoadGraph::NUM_POINTS;
+
+    guint64 new_max;
+    // both way, new_max is the greatest value
+    if (dmax >= graph->net.max)
+        new_max = dmax;
+    else
+        new_max = *std::max_element(&graph->net.values[0],
+                                    &graph->net.values[LoadGraph::NUM_POINTS]);
+
+    //
+    // Round network maximum
+    //
+
+    const guint64 bak_max(new_max);
+
+    if (ProcData::get_instance()->config.network_in_bits) {
+        // nice number is for the ticks
+        unsigned ticks = graph->num_bars();
+
+        // gets messy at low values due to division by 8
+        guint64 bit_max = std::max( new_max*8, G_GUINT64_CONSTANT(10000) );
+
+        // our tick size leads to max
+        double d = nicenum(bit_max/ticks, 0);
+        bit_max = ticks * d;
+        new_max = bit_max / 8;
+
+        procman_debug("bak*8 %" G_GUINT64_FORMAT ", ticks %d, d %f"
+                      ", bit_max %" G_GUINT64_FORMAT ", new_max %" G_GUINT64_FORMAT,
+                      bak_max*8, ticks, d, bit_max, new_max );
+    } else {
+        // round up to get some extra space
+        // yes, it can overflow
+        new_max = 1.1 * new_max;
+        // make sure max is not 0 to avoid / 0
+        // default to 1 KiB
+        new_max = std::max(new_max, G_GUINT64_CONSTANT(1024));
+
+        // decompose new_max = coef10 * 2**(base10 * 10)
+        // where coef10 and base10 are integers and coef10 < 2**10
+        //
+        // e.g: ceil(100.5 KiB) = 101 KiB = 101 * 2**(1 * 10)
+        //      where base10 = 1, coef10 = 101, pow2 = 16
+
+        guint64 pow2 = std::floor(log2(new_max));
+        guint64 base10 = pow2 / 10.0;
+        guint64 coef10 = std::ceil(new_max / double(G_GUINT64_CONSTANT(1) << (base10 * 10)));
+        g_assert(new_max <= (coef10 * (G_GUINT64_CONSTANT(1) << (base10 * 10))));
+
+        // then decompose coef10 = x * 10**factor10
+        // where factor10 is integer and x < 10
+        // so we new_max has only 1 significant digit
+
+        guint64 factor10 = std::pow(10.0, std::floor(std::log10(coef10)));
+        coef10 = std::ceil(coef10 / double(factor10)) * factor10;
+
+        // then make coef10 divisible by num_bars
+        if (coef10 % graph->num_bars() != 0)
+            coef10 = coef10 + (graph->num_bars() - coef10 % graph->num_bars());
+        g_assert(coef10 % graph->num_bars() == 0);
+        new_max = coef10 * (G_GUINT64_CONSTANT(1) << guint64(base10 * 10));
+        procman_debug("bak %" G_GUINT64_FORMAT " new_max %" G_GUINT64_FORMAT
+                      "pow2 %" G_GUINT64_FORMAT " coef10 %" G_GUINT64_FORMAT,
+                      bak_max, new_max, pow2, coef10);
+    }
+
+    if (bak_max > new_max) {
+        procman_debug("overflow detected: bak=%" G_GUINT64_FORMAT
+                      " new=%" G_GUINT64_FORMAT,
+                      bak_max, new_max);
+        new_max = bak_max;
+    }
+
+    // if max is the same or has decreased but not so much, don't
+    // do anything to avoid rescaling
+    if ((0.8 * graph->net.max) < new_max && new_max <= graph->net.max)
+        return;
+
+    const double scale = 1.0f * graph->net.max / new_max;
+
+    for (size_t i = 0; i < LoadGraph::NUM_POINTS; i++) {
+        if (graph->data[i][0] >= 0.0f) {
+            graph->data[i][0] *= scale;
+            graph->data[i][1] *= scale;
+        }
+    }
+
+    procman_debug("rescale dmax = %" G_GUINT64_FORMAT
+                  " max = %" G_GUINT64_FORMAT
+                  " new_max = %" G_GUINT64_FORMAT,
+                  dmax, graph->net.max, new_max);
+
+    graph->net.max = new_max;
+
+    // force the graph background to be redrawn now that scale has changed
+    graph->clear_background();
+}
+
+static void
+get_net (LoadGraph *graph)
+{
+    glibtop_netlist netlist;
+    char **ifnames;
+    guint32 i;
+    guint64 in = 0, out = 0;
+#if GLIB_CHECK_VERSION(2,61,2)
+    gint64 time;
+#else
+    GTimeVal time;
+#endif
+    guint64 din, dout;
+
+    ifnames = glibtop_get_netlist(&netlist);
+
+    for (i = 0; i < netlist.number; ++i)
+    {
+        glibtop_netload netload;
+        glibtop_get_netload (&netload, ifnames[i]);
+
+        if (netload.if_flags & (1 << GLIBTOP_IF_FLAGS_LOOPBACK))
+            continue;
+
+        /* Skip interfaces without any IPv4/IPv6 address (or
+         those with only a LINK ipv6 addr) However we need to
+         be able to exclude these while still keeping the
+         value so when they get online (with NetworkManager
+         for example) we don't get a suddent peak.  Once we're
+         able to get this, ignoring down interfaces will be
+         possible too.  */
+        if (not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS6)
+             and netload.scope6 != GLIBTOP_IF_IN6_SCOPE_LINK)
+            and not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS)))
+            continue;
+
+        /* Don't skip interfaces that are down (GLIBTOP_IF_FLAGS_UP)
+           to avoid spikes when they are brought up */
+
+        in  += netload.bytes_in;
+        out += netload.bytes_out;
+    }
+
+    g_strfreev(ifnames);
+
+#if GLIB_CHECK_VERSION(2,61,2)
+    time = g_get_real_time ();
+
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time != 0) {
+        float dtime = (double) (time - graph->net.time) / G_USEC_PER_SEC;
+#else
+    g_get_current_time (&time);
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time.tv_sec != 0) {
+        float dtime;
+        dtime = time.tv_sec - graph->net.time.tv_sec +
+            (double) (time.tv_usec - graph->net.time.tv_usec) / G_USEC_PER_SEC;
+#endif
+        din   = static_cast<guint64>((in  - graph->net.last_in)  / dtime);
+        dout  = static_cast<guint64>((out - graph->net.last_out) / dtime);
+    } else {
+        /* Don't calc anything if new data is less than old (interface
+           removed, counters reset, ...) or if it is the first time */
+        din  = 0;
+        dout = 0;
+    }
+
+    graph->net.last_in  = in;
+    graph->net.last_out = out;
+    graph->net.time     = time;
+
+    net_scale(graph, din, dout);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    g_autofree gchar *str=NULL, *formatted_str=NULL;
+
+    str = g_format_size_full (network_in_bits ? din*8 : din, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? in*8 : in, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in_total), str);
+
+    str = g_format_size_full (network_in_bits ? dout*8 : dout, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? out*8 : out, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out_total), str);
+}
+
+
+/* Updates the load graph when the timeout expires */
+static gboolean
+load_graph_update (gpointer user_data)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(user_data);
+
+    if (graph->render_counter == graph->frames_per_unit - 1) {
+        std::rotate(&graph->data[0], &graph->data[LoadGraph::NUM_POINTS - 1], &graph->data[LoadGraph::NUM_POINTS]);
+
+        switch (graph->type) {
+        case LOAD_GRAPH_CPU:
+            get_load(graph);
+            break;
+        case LOAD_GRAPH_MEM:
+            get_memory(graph);
+            break;
+        case LOAD_GRAPH_NET:
+            get_net(graph);
+            break;
+        default:
+            g_assert_not_reached();
+        }
+    }
+
+    if (graph->draw)
+        load_graph_queue_draw (graph);
+
+    graph->render_counter++;
+
+    if (graph->render_counter >= graph->frames_per_unit)
+        graph->render_counter = 0;
+
+    return TRUE;
+}
+
+
+
+LoadGraph::~LoadGraph()
+{
+  load_graph_stop(this);
+
+  if (timer_index)
+    g_source_remove(timer_index);
+
+  clear_background();
+}
+
+
+
+static gboolean
+load_graph_destroy (GtkWidget *widget, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    delete graph;
+
+    return FALSE;
+}
+
+
+LoadGraph::LoadGraph(guint type)
+  : fontsize(8.0),
+    rmargin(3.5 * fontsize),
+    indent(24.0),
+    n(0),
+    type(type),
+    speed(0),
+    draw_width(0),
+    draw_height(0),
+    render_counter(0),
+    frames_per_unit(10), // this will be changed but needs initialising
+    graph_dely(0),
+    real_draw_height(0),
+    graph_delx(0.0),
+    graph_buffer_offset(0),
+    main_widget(NULL),
+    disp(NULL),
+    background(NULL),
+    timer_index(0),
+    draw(FALSE),
+    mem_color_picker(NULL),
+    swap_color_picker(NULL)
+{
+    LoadGraph * const graph = this;
+
+    // FIXME:
+    // on configure, graph->frames_per_unit = graph->draw_width/(LoadGraph::NUM_POINTS);
+    // knock FRAMES down to 5 until cairo gets faster
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memset(&cpu, 0, sizeof cpu);
+        n = ProcData::get_instance()->config.num_cpus;
+
+        for(guint i = 0; i < G_N_ELEMENTS(labels.cpu); ++i)
+            labels.cpu[i] = gtk_label_new(NULL);
+
+        break;
+
+    case LOAD_GRAPH_MEM:
+        n = 2;
+        labels.memory = gtk_label_new(NULL);
+        labels.swap = gtk_label_new(NULL);
+        break;
+
+    case LOAD_GRAPH_NET:
+        memset(&net, 0, sizeof net);
+        n = 2;
+        net.max = 1;
+        labels.net_in = gtk_label_new(NULL);
+        labels.net_in_total = gtk_label_new(NULL);
+        labels.net_out = gtk_label_new(NULL);
+        labels.net_out_total = gtk_label_new(NULL);
+        break;
+    }
+
+    speed  = ProcData::get_instance()->config.graph_update_interval;
+
+    colors.resize(n);
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memcpy(&colors[0], ProcData::get_instance()->config.cpu_color,
+               n * sizeof colors[0]);
+        break;
+    case LOAD_GRAPH_MEM:
+        colors[0] = ProcData::get_instance()->config.mem_color;
+        colors[1] = ProcData::get_instance()->config.swap_color;
+        mem_color_picker = gsm_color_button_new (&colors[0],
+                                                 GSMCP_TYPE_PIE);
+        swap_color_picker = gsm_color_button_new (&colors[1],
+                                                  GSMCP_TYPE_PIE);
+        break;
+    case LOAD_GRAPH_NET:
+        colors[0] = ProcData::get_instance()->config.net_in_color;
+        colors[1] = ProcData::get_instance()->config.net_out_color;
+        break;
+    }
+
+    timer_index = 0;
+    render_counter = (frames_per_unit - 1);
+    draw = FALSE;
+
+    main_widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+    gtk_widget_set_size_request(main_widget, -1, LoadGraph::GRAPH_MIN_HEIGHT);
+    gtk_widget_show (main_widget);
+
+    disp = gtk_drawing_area_new ();
+    gtk_widget_show (disp);
+    g_signal_connect (G_OBJECT (disp), "draw", G_CALLBACK (load_graph_draw), graph);
+    g_signal_connect (G_OBJECT(disp), "configure_event",
+                      G_CALLBACK (load_graph_configure), graph);
+    g_signal_connect (G_OBJECT(disp), "destroy",
+                      G_CALLBACK (load_graph_destroy), graph);
+
+    gtk_widget_set_events (disp, GDK_EXPOSURE_MASK);
+
+    gtk_box_pack_start (GTK_BOX (main_widget), disp, TRUE, TRUE, 0);
+
+
+    /* Allocate data in a contiguous block */
+    data_block = std::vector<float>(n * LoadGraph::NUM_POINTS, -1.0f);
+
+    for (guint i = 0; i < LoadGraph::NUM_POINTS; ++i)
+        data[i] = &data_block[0] + i * n;
+
+    gtk_widget_show_all (main_widget);
+}
+
+void
+load_graph_start (LoadGraph *graph)
+{
+    if(!graph->timer_index) {
+
+        load_graph_update(graph);
+
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->draw = TRUE;
+}
+
+void
+load_graph_stop (LoadGraph *graph)
+{
+    /* don't draw anymore, but continue to poll */
+    graph->draw = FALSE;
+}
+
+void
+load_graph_change_speed (LoadGraph *graph,
+             guint new_speed)
+{
+    if (graph->speed == new_speed)
+        return;
+
+    graph->speed = new_speed;
+
+    if(graph->timer_index) {
+        g_source_remove (graph->timer_index);
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->clear_background();
+}
+
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *graph)
+{
+    return &graph->labels;
+}
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *graph)
+{
+    return graph->main_widget;
+}
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *graph)
+{
+    return graph->mem_color_picker;
+}
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *graph)
+{
+    return graph->swap_color_picker;
+}
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/8.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/8.html new file mode 100644 index 00000000..6bd78123 --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/8.html @@ -0,0 +1,1075 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
#include <config.h>
+
+#include <gtkmm/messagedialog.h>
+#include <glibmm/regex.h>
+#include <glib/gi18n.h>
+#include <glibtop/procopenfiles.h>
+
+#include <sys/wait.h>
+
+#include <set>
+#include <string>
+#include <sstream>
+#include <iterator>
+
+#include <glibmm/regex.h>
+
+#include "procman.h"
+#include "lsof.h"
+#include "util.h"
+
+
+using std::string;
+
+
+namespace
+{
+
+    class Lsof
+    {
+        Glib::RefPtr<Glib::Regex> re;
+
+        bool matches(const string &filename) const
+        {
+            return this->re->match(filename);
+        }
+
+    public:
+
+        Lsof(const string &pattern, bool caseless)
+        {
+            Glib::RegexCompileFlags flags = static_cast<Glib::RegexCompileFlags>(0);
+
+            if (caseless)
+                flags |= Glib::REGEX_CASELESS;
+
+            this->re = Glib::Regex::create(pattern, flags);
+        }
+
+
+        template<typename OutputIterator>
+        void search(const ProcInfo &info, OutputIterator out) const
+        {
+            glibtop_open_files_entry *entries;
+            glibtop_proc_open_files buf;
+
+            entries = glibtop_get_proc_open_files(&buf, info.pid);
+
+            for (unsigned i = 0; i != buf.number; ++i) {
+                if (entries[i].type & GLIBTOP_FILE_TYPE_FILE) {
+                    const string filename(entries[i].info.file.name);
+                    if (this->matches(filename))
+                        *out++ = filename;
+                }
+            }
+
+            g_free(entries);
+        }
+    };
+
+
+
+    // GUI Stuff
+
+
+    enum ProcmanLsof {
+        PROCMAN_LSOF_COL_SURFACE,
+        PROCMAN_LSOF_COL_PROCESS,
+        PROCMAN_LSOF_COL_PID,
+        PROCMAN_LSOF_COL_FILENAME,
+        PROCMAN_LSOF_NCOLS
+    };
+
+
+    struct GUI {
+
+        GtkListStore *model;
+        GtkEntry *entry;
+        GtkWindow *window;
+        GtkLabel *count;<--- Shadowed declaration
+        ProcData *procdata;
+        bool case_insensitive;
+
+
+        GUI()
+        {
+            procman_debug("New Lsof GUI %p", this);
+        }
+
+
+        ~GUI()
+        {
+            procman_debug("Destroying Lsof GUI %p", this);
+        }
+
+
+        void clear_results()
+        {
+            gtk_list_store_clear(this->model);
+            gtk_label_set_text(this->count, "");
+        }
+
+
+        void clear()
+        {
+            this->clear_results();
+            gtk_entry_set_text(this->entry, "");
+        }
+
+
+        void display_regex_error(const Glib::RegexError& error)
+        {
+            char * msg = g_strdup_printf ("<b>%s</b>\n%s\n%s",
+                                          _("Error"),
+                                          _("'%s' is not a valid Perl regular expression."),
+                                          "%s");
+            std::string message = make_string(g_strdup_printf(msg, this->pattern().c_str(), error.what().c_str()));
+            g_free(msg);
+
+            Gtk::MessageDialog dialog(message,
+                                      true, // use markup
+                                      Gtk::MESSAGE_ERROR,
+                                      Gtk::BUTTONS_OK,
+                                      true); // modal
+            dialog.run();
+        }
+
+
+        void update_count(unsigned count)
+        {
+            std::ostringstream ss;
+            ss << count;
+            string s = ss.str();
+            gtk_label_set_text(this->count, s.c_str());
+        }
+
+
+        string pattern() const
+        {
+            return gtk_entry_get_text(this->entry);
+        }
+
+
+        void search()
+        {
+            typedef std::set<string> MatchSet;
+            typedef MatchSet::const_iterator iterator;
+
+            this->clear_results();
+
+
+            try {
+                Lsof lsof(this->pattern(), this->case_insensitive);
+
+                unsigned count = 0;<--- Shadow variable
+
+                for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it) {
+                    const ProcInfo &info(*it->second);
+
+                    MatchSet matches;
+                    lsof.search(info, std::inserter(matches, matches.begin()));
+                    count += matches.size();
+
+                    for (iterator it(matches.begin()), end(matches.end()); it != end; ++it) {
+                        GtkTreeIter file;
+                        gtk_list_store_append(this->model, &file);
+                        gtk_list_store_set(this->model, &file,
+                                           PROCMAN_LSOF_COL_SURFACE, info.surface,
+                                           PROCMAN_LSOF_COL_PROCESS, info.name,
+                                           PROCMAN_LSOF_COL_PID, info.pid,
+                                           PROCMAN_LSOF_COL_FILENAME, it->c_str(),
+                                           -1);
+                    }
+                }
+
+                this->update_count(count);
+            }
+            catch (Glib::RegexError& error) {
+                this->display_regex_error(error);
+            }
+        }
+
+
+        static void search_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void search_entry_activate(GtkEntry *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void clear_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->clear();
+        }
+
+
+        static void close_button_clicked(GtkButton *, gpointer data)
+        {
+            GUI *gui = static_cast<GUI*>(data);
+            gtk_widget_destroy(GTK_WIDGET(gui->window));
+            delete gui;
+        }
+
+
+        static void case_button_toggled(GtkToggleButton *button, gpointer data)
+        {
+            bool state = gtk_toggle_button_get_active(button);
+            static_cast<GUI*>(data)->case_insensitive = state;
+        }
+
+
+        static gboolean window_delete_event(GtkWidget *, GdkEvent *, gpointer data)
+        {
+            delete static_cast<GUI*>(data);
+            return FALSE;
+        }
+
+    };
+}
+
+
+
+
+void procman_lsof(ProcData *procdata)
+{
+    GtkListStore *model = \
+        gtk_list_store_new(PROCMAN_LSOF_NCOLS,
+                           CAIRO_GOBJECT_TYPE_SURFACE, // PROCMAN_LSOF_COL_SURFACE
+                           G_TYPE_STRING,              // PROCMAN_LSOF_COL_PROCESS
+                           G_TYPE_UINT,                // PROCMAN_LSOF_COL_PID
+                           G_TYPE_STRING               // PROCMAN_LSOF_COL_FILENAME
+        );
+
+    GtkWidget *tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_object_unref(model);
+
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *renderer;
+
+    // SURFACE / PROCESS
+
+    column = gtk_tree_view_column_new();
+
+    renderer = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "surface", PROCMAN_LSOF_COL_SURFACE,
+                                        NULL);
+
+    renderer = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "text", PROCMAN_LSOF_COL_PROCESS,
+                                        NULL);
+
+    gtk_tree_view_column_set_title(column, _("Process"));
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PROCESS);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_column_set_min_width(column, 10);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), PROCMAN_LSOF_COL_PROCESS,
+                                         GTK_SORT_ASCENDING);
+
+
+    // PID
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("PID"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_PID,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PID);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    // FILENAME
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("Filename"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_FILENAME,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_FILENAME);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    GtkWidget *dialog; /* = gtk_dialog_new_with_buttons(_("Search for Open Files"), NULL,
+                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+                                                        NULL); */
+    dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(procdata->app));
+    gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
+    // gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_title(GTK_WINDOW(dialog), _("Search for Open Files"));
+
+    // g_signal_connect(G_OBJECT(dialog), "response",
+    //                           G_CALLBACK(close_dialog), NULL);
+    gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(dialog), 575, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(dialog), 12);
+    GtkWidget *mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_add(GTK_CONTAINER(dialog), mainbox);
+    gtk_box_set_spacing(GTK_BOX(mainbox), 6);
+
+
+    // Label, entry and search button
+
+    GtkWidget *hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), hbox1, FALSE, FALSE, 0);
+
+    GtkWidget *image = gtk_image_new_from_icon_name("edit-find", GTK_ICON_SIZE_DIALOG);
+    gtk_box_pack_start(GTK_BOX(hbox1), image, FALSE, FALSE, 0);
+
+
+    GtkWidget *vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox1), vbox2, TRUE, TRUE, 0);
+
+
+    GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox, TRUE, TRUE, 0);
+    GtkWidget *label = gtk_label_new_with_mnemonic(_("_Name contains:"));
+    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+    GtkWidget *entry = gtk_entry_new();
+
+    gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
+
+    GtkWidget *search_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                         "label", "gtk-find",
+                                                         "use-stock", TRUE,
+                                                         "use-underline", TRUE,
+                                                         NULL));
+
+    gtk_box_pack_start(GTK_BOX(hbox), search_button, FALSE, FALSE, 0);
+
+    GtkWidget *clear_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-clear",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    /* The default accelerator collides with the default close accelerator. */
+    gtk_button_set_label(GTK_BUTTON(clear_button), _("C_lear"));
+    gtk_box_pack_start(GTK_BOX(hbox), clear_button, FALSE, FALSE, 0);
+
+
+    GtkWidget *case_button = gtk_check_button_new_with_mnemonic(_("Case insensitive matching"));
+    GtkWidget *hbox3 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox3), case_button, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox3, FALSE, FALSE, 0);
+
+
+    GtkWidget *results_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), results_box, FALSE, FALSE, 0);
+    GtkWidget *results_label = gtk_label_new_with_mnemonic(_("S_earch results:"));
+    gtk_box_pack_start(GTK_BOX(results_box), results_label, FALSE, FALSE, 0);
+    GtkWidget *count_label = gtk_label_new(NULL);
+    gtk_box_pack_end(GTK_BOX(results_box), count_label, FALSE, FALSE, 0);
+
+    // Scrolled TreeView
+    GtkWidget *scrolled = gtk_scrolled_window_new(NULL, NULL);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
+                                   GTK_POLICY_AUTOMATIC,
+                                   GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled),
+                                        GTK_SHADOW_IN);
+    gtk_container_add(GTK_CONTAINER(scrolled), tree);
+    gtk_box_pack_start(GTK_BOX(mainbox), scrolled, TRUE, TRUE, 0);
+
+    GtkWidget *bottom_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+
+    GtkWidget *close_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-close",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    gtk_box_pack_start(GTK_BOX(mainbox), bottom_box, FALSE, FALSE, 0);
+    gtk_box_pack_end(GTK_BOX(bottom_box), close_button, FALSE, FALSE, 0);
+
+
+    GUI *gui = new GUI; // wil be deleted by the close button or delete-event
+    gui->procdata = procdata;
+    gui->model = model;
+    gui->window = GTK_WINDOW(dialog);
+    gui->entry = GTK_ENTRY(entry);
+    gui->count = GTK_LABEL(count_label);
+
+    g_signal_connect(G_OBJECT(entry), "activate",
+                     G_CALLBACK(GUI::search_entry_activate), gui);
+    g_signal_connect(G_OBJECT(clear_button), "clicked",
+                     G_CALLBACK(GUI::clear_button_clicked), gui);
+    g_signal_connect(G_OBJECT(search_button), "clicked",
+                     G_CALLBACK(GUI::search_button_clicked), gui);
+    g_signal_connect(G_OBJECT(close_button), "clicked",
+                     G_CALLBACK(GUI::close_button_clicked), gui);
+    g_signal_connect(G_OBJECT(case_button), "toggled",
+                     G_CALLBACK(GUI::case_button_toggled), gui);
+    g_signal_connect(G_OBJECT(dialog), "delete-event",
+                     G_CALLBACK(GUI::window_delete_event), gui);
+
+
+    gtk_widget_show_all(dialog);
+}
+
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/9.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/9.html new file mode 100644 index 00000000..b1d95a0b --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/9.html @@ -0,0 +1,1197 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
#include <config.h>
+
+#include <glibtop/procmap.h>
+#include <glibtop/mountlist.h>
+#include <sys/stat.h>
+#include <glib/gi18n.h>
+
+#include <string>
+#include <map>
+#include <sstream>
+#include <iomanip>
+#include <stdexcept>
+
+using std::string;
+
+
+#include "procman.h"
+#include "memmaps.h"
+#include "proctable.h"
+#include "util.h"
+
+
+/* be careful with this enum, you could break the column names */
+enum
+{
+    MMAP_COL_FILENAME,
+    MMAP_COL_VMSTART,
+    MMAP_COL_VMEND,
+    MMAP_COL_VMSZ,
+    MMAP_COL_FLAGS,
+    MMAP_COL_VMOFFSET,
+    MMAP_COL_PRIVATE_CLEAN,
+    MMAP_COL_PRIVATE_DIRTY,
+    MMAP_COL_SHARED_CLEAN,
+    MMAP_COL_SHARED_DIRTY,
+    MMAP_COL_DEVICE,
+    MMAP_COL_INODE,
+    MMAP_COL_MAX
+};
+
+
+namespace
+{
+    class OffsetFormater
+    {
+        string format;
+
+    public:
+
+        void set(const glibtop_map_entry &last_map)
+        {
+            this->format = (last_map.end <= G_MAXUINT32) ? "%08" G_GINT64_MODIFIER "x" : "%016" G_GINT64_MODIFIER "x";
+        }
+
+        string operator()(guint64 v) const
+        {
+            char buffer[17];
+            g_snprintf(buffer, sizeof buffer, this->format.c_str(), v);
+            return buffer;
+        }
+    };
+
+
+    class InodeDevices
+    {
+        typedef std::map<guint16, string> Map;
+        Map devices;
+
+    public:
+
+        void update()
+        {
+            this->devices.clear();
+
+            glibtop_mountlist list;
+            glibtop_mountentry *entries = glibtop_get_mountlist(&list, 1);
+
+            for (unsigned i = 0; i != list.number; ++i) {
+                struct stat buf;
+
+                if (stat(entries[i].devname, &buf) != -1)
+                    this->devices[buf.st_rdev] = entries[i].devname;
+            }
+
+            g_free(entries);
+        }
+
+        string get(guint64 dev64)
+        {
+            if (dev64 == 0)
+                return "";
+
+            guint16 dev = dev64 & 0xffff;
+
+            if (dev != dev64)
+                g_warning("weird device %" G_GINT64_MODIFIER "x", dev64);
+
+            Map::iterator it(this->devices.find(dev));
+
+            if (it != this->devices.end())
+                return it->second;
+
+            guint8 major, minor;
+            major = dev >> 8;
+            minor = dev;
+
+            std::ostringstream out;
+            out << std::hex
+                << std::setfill('0')
+                << std::setw(2) << unsigned(major)
+                << ':'
+                << std::setw(2) << unsigned(minor);
+
+            this->devices[dev] = out.str();
+            return out.str();
+        }
+    };
+
+
+    class MemMapsData
+    {
+    public:
+        guint timer;
+        GtkWidget *tree;
+        GSettings *settings;
+        ProcInfo *info;
+        OffsetFormater format;
+        mutable InodeDevices devices;
+        const char * const schema;
+
+        MemMapsData(GtkWidget *a_tree, GSettings *a_settings)
+            : tree(a_tree),
+            settings(a_settings),
+            schema("memmapstree")
+        {
+            procman_get_tree_state(this->settings, this->tree, this->schema);
+        }
+
+        ~MemMapsData()
+        {
+            procman_save_tree_state(this->settings, this->tree, this->schema);
+        }
+    };
+}
+
+
+struct glibtop_map_entry_cmp
+{
+    bool operator()(const glibtop_map_entry &a, const guint64 start) const
+    {
+        return a.start < start;
+    }
+
+    bool operator()(const guint64 &start, const glibtop_map_entry &a) const
+    {
+        return start < a.start;
+    }
+
+};
+
+
+static void
+update_row(GtkTreeModel *model, GtkTreeIter &row, const MemMapsData &mm, const glibtop_map_entry *memmaps)
+{
+    guint64 size;
+    string filename, device;
+    string vmstart, vmend, vmoffset;
+    char flags[5] = "----";
+
+    size = memmaps->end - memmaps->start;
+
+    if(memmaps->perm & GLIBTOP_MAP_PERM_READ)    flags [0] = 'r';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_WRITE)   flags [1] = 'w';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_EXECUTE) flags [2] = 'x';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_SHARED)  flags [3] = 's';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_PRIVATE) flags [3] = 'p';
+
+    if (memmaps->flags & (1 << GLIBTOP_MAP_ENTRY_FILENAME))
+      filename = memmaps->filename;
+
+    vmstart  = mm.format(memmaps->start);
+    vmend    = mm.format(memmaps->end);
+    vmoffset = mm.format(memmaps->offset);
+    device   = mm.devices.get(memmaps->device);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        MMAP_COL_FILENAME, filename.c_str(),
+                        MMAP_COL_VMSTART, vmstart.c_str(),
+                        MMAP_COL_VMEND, vmend.c_str(),
+                        MMAP_COL_VMSZ, size,
+                        MMAP_COL_FLAGS, flags,
+                        MMAP_COL_VMOFFSET, vmoffset.c_str(),
+                        MMAP_COL_PRIVATE_CLEAN, memmaps->private_clean,
+                        MMAP_COL_PRIVATE_DIRTY, memmaps->private_dirty,
+                        MMAP_COL_SHARED_CLEAN, memmaps->shared_clean,
+                        MMAP_COL_SHARED_DIRTY, memmaps->shared_dirty,
+                        MMAP_COL_DEVICE, device.c_str(),
+                        MMAP_COL_INODE, memmaps->inode,
+                        -1);
+}
+
+
+
+
+static void
+update_memmaps_dialog (MemMapsData *mmdata)
+{
+    GtkTreeModel *model;
+    glibtop_map_entry *memmaps;
+    glibtop_proc_map procmap;
+
+    memmaps = glibtop_get_proc_map (&procmap, mmdata->info->pid);
+    /* process has disappeared */
+    if(!memmaps or procmap.number == 0) return;
+
+    mmdata->format.set(memmaps[procmap.number - 1]);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+
+    GtkTreeIter iter;<--- Shadowed declaration
+
+    typedef std::map<guint64, GtkTreeIter> IterCache;
+    IterCache iter_cache;
+
+    /*
+      removes the old maps and
+      also fills a cache of start -> iter in order to speed
+      up add
+    */
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        while (true) {
+            char *vmstart = 0;
+            guint64 start;
+            gtk_tree_model_get(model, &iter,
+                               MMAP_COL_VMSTART, &vmstart,
+                               -1);
+
+            try {
+                std::istringstream(vmstart) >> std::hex >> start;
+            } catch (std::logic_error &e) {
+                g_warning("Could not parse %s", vmstart);
+                start = 0;
+            }
+
+            g_free(vmstart);
+
+            bool found = std::binary_search(memmaps, memmaps + procmap.number,
+                                            start, glibtop_map_entry_cmp());
+
+            if (found) {
+                iter_cache[start] = iter;
+                if (!gtk_tree_model_iter_next(model, &iter))
+                    break;
+            } else {
+                if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                    break;
+            }
+        }
+    }
+
+    mmdata->devices.update();
+
+    /*
+      add the new maps
+    */
+
+    for (guint i = 0; i != procmap.number; i++) {
+        GtkTreeIter iter;<--- Shadow variable
+        IterCache::iterator it(iter_cache.find(memmaps[i].start));
+
+        if (it != iter_cache.end())
+            iter = it->second;
+        else
+            gtk_list_store_prepend(GTK_LIST_STORE(model), &iter);
+
+        update_row(model, iter, *mmdata, &memmaps[i]);
+    }
+
+    g_free (memmaps);
+}
+
+
+
+static void
+dialog_response (GtkDialog * dialog, gint response_id, gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+
+    g_source_remove (mmdata->timer);
+
+    delete mmdata;
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+
+static MemMapsData*
+create_memmapsdata (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Filename"),
+        // xgettext: virtual memory start
+        N_("VM Start"),
+        // xgettext: virtual memory end
+        N_("VM End"),
+        // xgettext: virtual memory syze
+        N_("VM Size"),
+        N_("Flags"),
+        // xgettext: virtual memory offset
+        N_("VM Offset"),
+        // xgettext: memory that has not been modified since
+        // it has been allocated
+        N_("Private clean"),
+        // xgettext: memory that has been modified since it
+        // has been allocated
+        N_("Private dirty"),
+        // xgettext: shared memory that has not been modified
+        // since it has been allocated
+        N_("Shared clean"),
+        // xgettext: shared memory that has been modified
+        // since it has been allocated
+        N_("Shared dirty"),
+        N_("Device"),
+        N_("Inode")
+    };
+
+    model = gtk_list_store_new (MMAP_COL_MAX,
+                                G_TYPE_STRING, /* MMAP_COL_FILENAME  */
+                                G_TYPE_STRING, /* MMAP_COL_VMSTART     */
+                                G_TYPE_STRING, /* MMAP_COL_VMEND     */
+                                G_TYPE_UINT64, /* MMAP_COL_VMSZ     */
+                                G_TYPE_STRING, /* MMAP_COL_FLAGS     */
+                                G_TYPE_STRING, /* MMAP_COL_VMOFFSET  */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_DIRTY */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_DIRTY */
+                                G_TYPE_STRING, /* MMAP_COL_DEVICE     */
+                                G_TYPE_UINT64 /* MMAP_COL_INODE     */
+                                );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < MMAP_COL_MAX; i++) {
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(tree), col);
+
+        switch (i) {
+            case MMAP_COL_PRIVATE_CLEAN:
+            case MMAP_COL_PRIVATE_DIRTY:
+            case MMAP_COL_SHARED_CLEAN:
+            case MMAP_COL_SHARED_DIRTY:
+            case MMAP_COL_VMSZ:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                         &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+                break;
+        }
+
+
+        switch (i) {
+            case MMAP_COL_VMSTART:
+            case MMAP_COL_VMEND:
+            case MMAP_COL_FLAGS:
+            case MMAP_COL_VMOFFSET:
+            case MMAP_COL_DEVICE:
+                g_object_set(cell, "family", "monospace", NULL);
+                break;
+        }
+    }
+
+    return new MemMapsData(tree, procdata->settings);
+}
+
+
+static gboolean
+memmaps_timer (gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+    g_assert(model);
+
+    update_memmaps_dialog (mmdata);
+
+    return TRUE;
+}
+
+
+static void
+create_single_memmaps_dialog (GtkTreeModel *model, GtkTreePath *path,
+                              GtkTreeIter *iter, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    MemMapsData *mmdata;
+    GtkWidget *memmapsdialog;
+    GtkWidget *dialog_vbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    ProcInfo *info;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    mmdata = create_memmapsdata (procdata);
+    mmdata->info = info;
+
+    memmapsdialog = gtk_dialog_new_with_buttons (_("Memory Maps"), GTK_WINDOW (procdata->app),
+                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                 "gtk-close", GTK_RESPONSE_CLOSE,
+                                                 NULL);
+    gtk_window_set_resizable(GTK_WINDOW(memmapsdialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(memmapsdialog), 620, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(memmapsdialog), 5);
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG(memmapsdialog));
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Memory maps for process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), label, FALSE, TRUE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    gtk_container_add (GTK_CONTAINER (scrolled), mmdata->tree);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), mmdata->tree);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+
+    g_signal_connect(G_OBJECT(memmapsdialog), "response",
+                              G_CALLBACK(dialog_response), mmdata);
+
+    gtk_widget_show_all (memmapsdialog);
+
+    mmdata->timer = g_timeout_add_seconds (5, memmaps_timer, mmdata);
+
+    update_memmaps_dialog (mmdata);
+}
+
+
+void
+create_memmaps_dialog (ProcData *procdata)
+{
+    /* TODO: do we really want to open multiple dialogs ? */
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_memmaps_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/index.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/index.html new file mode 100644 index 00000000..02bb6ffc --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/index.html @@ -0,0 +1,323 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/cgroups.cpp
27variableScope398styleThe scope of the variable 'paren_offset' can be reduced.
27variableScope398styleThe scope of the variable 'off' can be reduced.
27variableScope398styleThe scope of the variable 'tmp_size' can be reduced.
55cstyleCast398styleC-style pointer casting
src/disks.cpp
202redundantAssignment563styleVariable 'res' is reassigned a value before the old one has been used.
src/gsm_color_button.c
648variableScope398styleThe scope of the variable 'color_chooser' can be reduced.
src/interface.cpp
452cstyleCast398styleC-style pointer casting
454cstyleCast398styleC-style pointer casting
src/load-graph.cpp
41shadowVariable398styleLocal variable 'n' shadows outer variable
164shadowVariable398styleLocal variable 'i' shadows outer variable
src/load-graph.h
36noExplicitConstructor398styleStruct 'LoadGraph' has a constructor with 1 argument that is not explicit.
src/lsof.cpp
164shadowVariable398styleLocal variable 'count' shadows outer variable
src/memmaps.cpp
269shadowVariable398styleLocal variable 'iter' shadows outer variable
src/msm-resources.c
9unusedStructMember563styleunion member 'Anonymous0::alignment' is never used.
9unusedStructMember563styleunion member 'Anonymous0::ptr' is never used.
src/openfiles.cpp
73nullPointerRedundantCheck476warningEither the condition 'res' is redundant or there is possible null pointer dereference: res.
205shadowVariable398styleLocal variable 'openfiles' shadows outer variable
247variableScope398styleThe scope of the variable 'column' can be reduced.
248variableScope398styleThe scope of the variable 'cell' can be reduced.
src/prettytable.h
39unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_opened'
40unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_closed'
src/procdialogs.cpp
294noExplicitConstructor398styleClass 'SpinButtonUpdater' has a constructor with 1 argument that is not explicit.
415shadowVariable398styleLocal variable 'column' shadows outer variable
475cstyleCast398styleC-style pointer casting
498cstyleCast398styleC-style pointer casting
513cstyleCast398styleC-style pointer casting
src/procman-app.cpp
348uninitMemberVar398warningMember variable 'ProcmanApp::procdata' is not initialized in the constructor.
src/procman.cpp
34uninitMemberVarPrivate398warningMember variable 'ProcData::uimanager' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::action_group' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::statusbar' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::loadavg' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::endprocessbutton' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::popup_menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::disk_list' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::notebook' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::config' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::selection' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::settings' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::app' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::frequency' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::smooth_refresh' is not initialized in the constructor.
112shadowVariable398styleLocal variable 'order' shadows outer variable
162shadowVariable398styleLocal variable 'order' shadows outer variable
src/procman.h
103uninitMemberVar398warningMember variable 'MutableProcInfo::cgroup_name' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::unit' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::session' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::seat' is not initialized in the constructor.
173noExplicitConstructor398styleClass 'ProcInfo' has a constructor with 1 argument that is not explicit.
src/procproperties.cpp
208variableScope398styleThe scope of the variable 'column' can be reduced.
209variableScope398styleThe scope of the variable 'cell' can be reduced.
src/proctable.cpp
920shadowVariable398styleLocal variable 'arguments' shadows outer variable
929shadowVariable398styleLocal variable 'tooltip' shadows outer variable
1016shadowVariable398styleLocal variable 'it' shadows outer variable
1022shadowVariable398styleLocal variable 'it' shadows outer variable
1068shadowVariable398styleLocal variable 'it' shadows outer variable
1073shadowVariable398styleLocal variable 'it' shadows outer variable
src/selinux.cpp
21varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
src/smooth_refresh.h
22noExplicitConstructor398styleClass 'SmoothRefresh' has a constructor with 1 argument that is not explicit.
src/sysinfo.cpp
126unusedPrivateFunction398styleUnused private function: 'SysInfo::get_os_type'
233cstyleCast398styleC-style pointer casting
343cstyleCast398styleC-style pointer casting
509uninitMemberVar398warningMember variable 'LSBSysInfo::lsb_fd' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::name' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::release' is not initialized in the constructor.
515missingOverridestyleThe function 'set_distro_labels' overrides a function in a base class but is not marked with a 'override' specifier.
570shadowVariable398styleLocal variable 'release' shadows outer variable
615unusedPrivateFunction398styleUnused private function: 'LSBSysInfo::sync_lsb_release'
626variableScope398styleThe scope of the variable 'codename' can be reduced.
626shadowVariable398styleLocal variable 'release' shadows outer variable
690stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
697stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
701stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
736variableScope398styleThe scope of the variable 'len' can be reduced.
738stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
1001unreadVariable563styleVariable 'table_count' is assigned a value that is never used.
+
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/stats.html b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/stats.html new file mode 100644 index 00000000..aa8922ed --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/stats.html @@ -0,0 +1,189 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+

Top 10 files for warning severity, total findings: 24
+   15  src/procman.cpp
+   4   src/procman.h
+   3   src/sysinfo.cpp
+   1   src/procman-app.cpp
+   1   src/openfiles.cpp
+

+

Top 10 files for portability severity, total findings: 1
+   1  src/selinux.cpp
+

+

Top 10 files for performance severity, total findings: 4
+   4  src/sysinfo.cpp
+

+

Top 10 files for style severity, total findings: 47
+   10  src/sysinfo.cpp
+   6   src/proctable.cpp
+   5   src/procdialogs.cpp
+   4   src/cgroups.cpp
+   3   src/openfiles.cpp
+   2   src/procproperties.cpp
+   2   src/procman.cpp
+   2   src/prettytable.h
+   2   src/msm-resources.c
+   2   src/load-graph.cpp
+

+ +
+ +
+ + diff --git a/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/style.css b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/style.css new file mode 100644 index 00000000..3897bfaf --- /dev/null +++ b/2023-09-04-185553-0784-cppcheck@d0fc4b9c7899_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-09-05-135451-6126-1@c439634163d9_test-ci/index.html b/2023-09-05-135451-6126-1@c439634163d9_test-ci/index.html new file mode 100644 index 00000000..2c50915e --- /dev/null +++ b/2023-09-05-135451-6126-1@c439634163d9_test-ci/index.html @@ -0,0 +1,136 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@415e711939aa
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 16.0.6 (Fedora 16.0.6-2.fc38) +
Date:Tue Sep 5 13:54:51 2023
+

Bug Summary

+ + + + + + + +
Bug TypeQuantityDisplay?
All Bugs14
Logic error
Use of identical expressions1
Unused code
Dead assignment1
Unreachable code12
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
Unused codeDead assignmentrootdir/src/disks.cppget_mount_opt2011View Report
Unused codeUnreachable coderootdir/src/procman-app.cppon_command_line3811View Report
Unused codeUnreachable coderootdir/src/util.cppio_rate_cell_data_func4941View Report
Unused codeUnreachable coderootdir/src/util.cppstatus_cell_data_func5911View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_gicon421View Report
Unused codeUnreachable coderootdir/src/util.cppduration_cell_data_func5351View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_na_cell_data_func3841View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_na_cell_data_func4561View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_cell_data_func4221View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_icon131View Report
Unused codeUnreachable coderootdir/src/util.cpptime_cell_data_func5641View Report
Unused codeUnreachable coderootdir/src/procman-app.cpptimeouts_changed_cb1511View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_cell_data_func3501View Report
Logic errorUse of identical expressionsusr/include/sigc++-2.0/sigc++/visit_each.hoperator()981View Report
+ + diff --git a/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-22e004.html b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-22e004.html new file mode 100644 index 00000000..a0e71fe5 --- /dev/null +++ b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-22e004.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 381, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-05-135451-6126-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
This statement is never executed
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-491eb3.html b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-491eb3.html new file mode 100644 index 00000000..ed708411 --- /dev/null +++ b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-491eb3.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 494, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-05-135451-6126-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-4d889d.html b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-4d889d.html new file mode 100644 index 00000000..9b671e55 --- /dev/null +++ b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-4d889d.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 591, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-05-135451-6126-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-633ebf.html b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-633ebf.html new file mode 100644 index 00000000..d7aeca1d --- /dev/null +++ b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-633ebf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 42, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-05-135451-6126-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
This statement is never executed
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-6c54e6.html b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-6c54e6.html new file mode 100644 index 00000000..ad458bee --- /dev/null +++ b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-6c54e6.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 535, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-05-135451-6126-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-6c8186.html b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-6c8186.html new file mode 100644 index 00000000..4d36bf9c --- /dev/null +++ b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-6c8186.html @@ -0,0 +1,886 @@ + + + +/usr/include/sigc++-2.0/sigc++/visit_each.h + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:usr/include/sigc++-2.0/sigc++/visit_each.h
Warning:line 98, column 64
identical expressions on both sides of logical operator
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-05-135451-6126-1 -x c++ procman.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright 2002, The libsigc++ Development Team
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18#ifndef _SIGC_VISIT_EACH_HPP_
19#define _SIGC_VISIT_EACH_HPP_
20
21#include <sigc++/type_traits.h>
22#include <type_traits>
23
24namespace sigc {
25
26#ifndef DOXYGEN_SHOULD_SKIP_THIS
27namespace internal {
28
29//This should really be an inner class of limit_derived_target, without the T_limit template type,
30//But the SUN CC 5.7 (not earlier versions) compiler finds it ambiguous when we specify a particular specialization of it.
31//and does not seem to allow us to tell it explicitly that it's an inner class.
32template <bool I_derived, class T_type, class T_limit>
33struct with_type;
34
35//Specialization for I_derived = false
36template <class T_type, class T_limit> struct
37with_type<false, T_type, T_limit>
38{
39 static void execute_(const T_type&, const T_limit&) {}
40};
41
42//Specialization for I_derived = true
43template <class T_type, class T_limit>
44struct with_type<true, T_type, T_limit>
45{
46 static void execute_(const T_type& _A_type, const T_limit& _A_action)
47 { _A_action.action_(_A_type); }
48};
49
50
51/// Helper struct for visit_each_type().
52template <class T_target, class T_action>
53struct limit_derived_target
54{
55 typedef limit_derived_target<T_target, T_action> T_self;
56
57 template <class T_type>
58 void operator()(const T_type& _A_type) const
59 {
60 with_type<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
61 }
62
63 limit_derived_target(const T_action& _A_action)
64 : action_(_A_action)
65 {}
66
67 T_action action_;
68};
69
70// Specialization for T_target pointer types, to provide a slightly different execute_() implementation.
71
72template <bool I_derived, class T_type, class T_limit>
73struct with_type_pointer;
74
75//Specialization for I_derived = false
76template <class T_type, class T_limit>
77struct with_type_pointer<false, T_type, T_limit>
78{
79 static void execute_(const T_type&, const T_limit&) {}
80};
81
82//Specialization for I_derived = true
83template <class T_type, class T_limit>
84struct with_type_pointer<true, T_type, T_limit>
85{
86 static void execute_(const T_type& _A_type, const T_limit& _A_action)
87 { _A_action.action_(&_A_type); }
88};
89
90template <class T_target, class T_action>
91struct limit_derived_target<T_target*, T_action>
92{
93 typedef limit_derived_target<T_target*, T_action> T_self;
94
95 template <class T_type>
96 void operator()(const T_type& _A_type) const
97 {
98 with_type_pointer<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
identical expressions on both sides of logical operator
99 }
100
101 limit_derived_target(const T_action& _A_action)
102 : action_(_A_action)
103 {}
104
105 T_action action_;
106};
107
108} /* namespace internal */
109#endif // DOXYGEN_SHOULD_SKIP_THIS
110
111// struct visitor was introduced as a result of https://bugzilla.gnome.org/show_bug.cgi?id=724496
112// The advantage of using specializations of a template struct instead of overloads of
113// a template function is described by Herb Sutter in http://www.gotw.ca/publications/mill17.htm
114// In libsigc++ the main reason for using this technique is that we can avoid using ADL
115// (argument-dependent lookup), and therefore there is no risk that a visit_each() overload
116// in e.g. Boost is selected by mistake.
117
118/** sigc::visitor<T_functor>::do_visit_each() performs a functor on each of the targets of a functor.
119 * All unknown types just call @a _A_action on them.
120 * Add specializations that specialize the @a T_functor argument for your own
121 * functor types, so that subobjects get visited. This is needed to enable
122 * auto-disconnection support for your functor types.
123 *
124 * @par Example:
125 * @code
126 * namespace some_ns
127 * {
128 * struct some_functor
129 * {
130 * void operator()() {}
131 * some_possibly_sigc_trackable_derived_type some_data_member;
132 * some_other_functor_type some_other_functor;
133 * };
134 * }
135 *
136 * namespace sigc
137 * {
138 * template <>
139 * struct visitor<some_ns::some_functor>
140 * {
141 * template <class T_action>
142 * static void do_visit_each(const T_action& _A_action,
143 * const some_ns::some_functor& _A_target)
144 * {
145 * sigc::visit_each(_A_action, _A_target.some_data_member);
146 * sigc::visit_each(_A_action, _A_target.some_other_functor);
147 * }
148 * };
149 * }
150 * @endcode
151 *
152 * @ingroup sigcfunctors
153 */
154template <class T_functor>
155struct visitor
156{
157 template <class T_action>
158 static void do_visit_each(const T_action& _A_action, const T_functor& _A_functor)
159 {
160 _A_action(_A_functor);
161 }
162};
163
164/** This function performs a functor on each of the targets of a functor.
165 *
166 * @ingroup sigcfunctors
167 */
168template <class T_action, class T_functor>
169void visit_each(const T_action& _A_action, const T_functor& _A_functor)
170{ sigc::visitor<T_functor>::do_visit_each(_A_action, _A_functor); }
171
172/** This function performs a functor on each of the targets
173 * of a functor limited to a restricted type.
174 *
175 * @ingroup sigcfunctors
176 */
177template <class T_type, class T_action, class T_functor>
178void visit_each_type(const T_action& _A_action, const T_functor& _A_functor)
179{
180 typedef internal::limit_derived_target<T_type, T_action> type_limited_action;
181
182 type_limited_action limited_action(_A_action);
183
184 //specifying the types of the template specialization prevents disconnection of bound trackable references (such as with std::ref()),
185 //probably because the visit_each<> specializations take various different template types,
186 //in various sequences, and we are probably specifying only a subset of them with this.
187 //
188 //But this is required by the AIX (and maybe IRIX MipsPro and Tru64) compilers.
189 //I guess that std::ref() therefore does not work on those platforms. murrayc
190 // sigc::visit_each<type_limited_action, T_functor>(limited_action, _A_functor);
191
192 //g++ (even slightly old ones) is our primary platform, so we could use the non-crashing version.
193 //However, the explicit version also fixes a crash in a slightly more common case: http://bugzilla.gnome.org/show_bug.cgi?id=169225
194 //Users (and distributors) of libsigc++ on AIX (and maybe IRIX MipsPro and Tru64) do
195 //need to use the version above instead, to allow compilation.
196
197 //Added 2014-03-20: The preceding comment probably does not apply any more,
198 //now when the visit_each<>() overloads have been replaced by visitor<> specializations.
199 //It's probably safe to add explicit template parameters on calls to visit_each(),
200 //visit_each_type() and visitor::do_visit_each(), if necessary.
201
202 sigc::visit_each(limited_action, _A_functor);
203}
204
205} /* namespace sigc */
206#endif
diff --git a/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-77634b.html b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-77634b.html new file mode 100644 index 00000000..149a4131 --- /dev/null +++ b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-77634b.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 384, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-05-135451-6126-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-7bbc8c.html b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-7bbc8c.html new file mode 100644 index 00000000..a3cf1d9b --- /dev/null +++ b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-7bbc8c.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 456, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-05-135451-6126-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-7ce786.html b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-7ce786.html new file mode 100644 index 00000000..fc9043ed --- /dev/null +++ b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-7ce786.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 422, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-05-135451-6126-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-802eaf.html b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-802eaf.html new file mode 100644 index 00000000..11b541b6 --- /dev/null +++ b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-802eaf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 13, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-05-135451-6126-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
This statement is never executed
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-8e6c9c.html b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-8e6c9c.html new file mode 100644 index 00000000..ad025c86 --- /dev/null +++ b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-8e6c9c.html @@ -0,0 +1,1200 @@ + + + +disks.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/disks.cpp
Warning:line 201, column 13
Value stored to 'res' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name disks.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-05-135451-6126-1 -x c++ disks.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#ifdef __linux__1
4#include <mntent.h>
5#endif // __linux__
6
7#include <giomm.h>
8#include <giomm/themedicon.h>
9#include <gtk/gtk.h>
10#include <glibtop/mountlist.h>
11#include <glibtop/fsusage.h>
12#include <glib/gi18n.h>
13
14#include "procman.h"
15#include "disks.h"
16#include "util.h"
17#include "interface.h"
18#include "iconthemewrapper.h"
19
20namespace
21{
22 const unsigned DISK_ICON_SIZE = 24;
23}
24
25enum DiskColumns
26{
27 /* string columns* */
28 DISK_DEVICE,
29 DISK_DIR,
30 DISK_TYPE,
31 DISK_SUBVOLUME,
32 DISK_TOTAL,
33 DISK_FREE,
34 DISK_AVAIL,
35 /* USED has to be the last column */
36 DISK_USED,
37 // then unvisible columns
38 /* Surface column */
39 DISK_ICON,
40 /* numeric columns */
41 DISK_USED_PERCENTAGE,
42 DISK_N_COLUMNS
43};
44
45
46
47static void
48fsusage_stats(const glibtop_fsusage *buf,
49 guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
50 gint *percentage)
51{
52 guint64 total = buf->blocks * buf->block_size;
53
54 if (!total) {
55 /* not a real device */
56 *btotal = *bfree = *bavail = *bused = 0ULL;
57 *percentage = 0;
58 } else {
59 int percent;
60 *btotal = total;
61 *bfree = buf->bfree * buf->block_size;
62 *bavail = buf->bavail * buf->block_size;
63 *bused = *btotal - *bfree;
64 /* percent = 100.0f * *bused / *btotal; */
65 percent = 100 * *bused / (*bused + *bavail);
66 *percentage = CLAMP(percent, 0, 100)(((percent) > (100)) ? (100) : (((percent) < (0)) ? (0)
: (percent)))
;
67 }
68}
69
70
71namespace
72{
73 string get_icon_for_path(const std::string& path)
74 {
75 using namespace Glib;
76 using namespace Gio;
77
78 // FIXME: I don't know whether i should use Volume or Mount or UnixMount
79 // all i need an icon name.
80 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
81
82 std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
83
84 for (size_t i = 0; i != mounts.size(); ++i) {
85 if (mounts[i]->get_name() != path)
86 continue;
87
88 RefPtr<Icon> icon = mounts[i]->get_icon();
89 RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
90
91 if (themed_icon) {
92 char* name = 0;
93 // FIXME: not wrapped yet
94 g_object_get(G_OBJECT(themed_icon->gobj())((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((themed_icon->gobj())), (((GType) ((20) << (2)))
)))))
, "name", &name, NULL__null);
95 return make_string(name);
96 }
97 }
98
99 return "";
100 }
101}
102
103
104static Glib::RefPtr<Gdk::Pixbuf>
105get_icon_for_device(const char *mountpoint)
106{
107 procman::IconThemeWrapper icon_theme;
108 string icon_name = get_icon_for_path(mountpoint);
109 if (icon_name == "")
110 // FIXME: defaults to a safe value
111 icon_name = "drive-harddisk"; // get_icon_for_path("/");
112 return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
113}
114
115
116static gboolean
117find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
118 GtkTreeIter *result)
119{
120 GtkTreeIter iter;
121 gboolean found = FALSE(0);
122
123 if (gtk_tree_model_get_iter_first(model, &iter)) {
124 do {
125 char *dir;
126
127 gtk_tree_model_get(model, &iter,
128 DISK_DIR, &dir,
129 -1);
130
131 if (dir && !strcmp(dir, mountpoint)) {
132 *result = iter;
133 found = TRUE(!(0));
134 }
135
136 g_free(dir);
137
138 } while (!found && gtk_tree_model_iter_next(model, &iter));
139 }
140
141 return found;
142}
143
144
145
146static void
147remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
148{
149 GtkTreeIter iter;
150
151 if (!gtk_tree_model_get_iter_first(model, &iter))
152 return;
153
154 while (true) {
155 char *dir;
156 guint i;
157 gboolean found = FALSE(0);
158
159 gtk_tree_model_get(model, &iter,
160 DISK_DIR, &dir,
161 -1);
162
163 for (i = 0; i != n; ++i) {
164 if (!strcmp(dir, entries[i].mountdir)) {
165 found = TRUE(!(0));
166 break;
167 }
168 }
169
170 g_free(dir);
171
172 if (!found) {
173 if (!gtk_list_store_remove(GTK_LIST_STORE(model)((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_list_store_get_type ()))))))
, &iter))
174 break;
175 else
176 continue;
177 }
178
179 if (!gtk_tree_model_iter_next(model, &iter))
180 break;
181 }
182}
183
184#ifdef __linux__1
185static char *
186get_mount_opt(const glibtop_mountentry *entry, const char* opt)
187{
188 char *opt_value = NULL__null;
189 const struct mntent *mnt;
190 FILE *fp;
191
192 if (!(fp = setmntent(MOUNTED"/etc/mtab", "r"))) {
193 goto out;
194 }
195
196 while ((mnt = getmntent(fp))) {
197 if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
198 (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
199 char *res;
200
201 res = hasmntopt(mnt, "subvol");
Value stored to 'res' is never read
202 if ((res = hasmntopt(mnt, "subvol")) != NULL__null) {
203 char **strs = g_strsplit_set(res, "=", 2);
204
205 if (g_strv_length(strs) == 2) {
206 char *value = strs[1];
207 if (g_strcmp0 (value,"/root") == 0)
208 opt_value = g_strdup("/")g_strdup_inline ("/");
209 else
210 opt_value = g_strdup(strs[1])g_strdup_inline (strs[1]);
211 g_strfreev(strs);
212 }
213 }
214 break;
215 }
216 }
217
218 endmntent(fp);
219
220 out:
221 return opt_value;
222}
223#endif // __linux__
224
225
226static void
227add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
228{
229 Glib::RefPtr<Gdk::Pixbuf> pixbuf;
230 cairo_surface_t *surface;
231 GtkTreeIter iter;
232 glibtop_fsusage usage;
233 guint64 bused, bfree, bavail, btotal;
234 gint percentage;
235#ifdef __linux__1
236 char *subvol = NULL__null;
237#endif // __linux__
238
239 glibtop_get_fsusage(&usage, entry->mountdir);
240
241 if (not show_all_fs and usage.blocks == 0) {
242 if (find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
243 gtk_list_store_remove(list, &iter);
244 return;
245 }
246
247 fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
248#ifdef __linux__1
249 subvol = get_mount_opt(entry, "subvol");
250#endif // __linux__
251 pixbuf = get_icon_for_device(entry->mountdir);
252 surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL__null);
253
254 /* if we can find a row with the same mountpoint, we get it but we
255 still need to update all the fields.
256 This makes selection persistent.
257 */
258 if (!find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
259 gtk_list_store_append(list, &iter);
260
261 gtk_list_store_set(list, &iter,
262 DISK_ICON, surface,
263 DISK_DEVICE, entry->devname,
264 DISK_DIR, entry->mountdir,
265 DISK_TYPE, entry->type,
266#ifdef __linux__1
267
268 DISK_SUBVOLUME, subvol != NULL__null ? subvol : "",
269#else
270 DISK_SUBVOLUME, "",
271#endif // __linux__
272 DISK_USED_PERCENTAGE, percentage,
273 DISK_TOTAL, btotal,
274 DISK_FREE, bfree,
275 DISK_AVAIL, bavail,
276 DISK_USED, bused,
277 -1);
278#ifdef __linux__1
279 g_free (subvol);
280#endif // __linux__
281}
282
283
284
285int
286cb_update_disks(gpointer data)
287{
288 ProcData *const procdata = static_cast<ProcData*>(data);
289
290 GtkListStore *list;
291 glibtop_mountentry * entries;
292 glibtop_mountlist mountlist;
293 guint i;
294
295 list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)))((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_tree_view_get_model(((((GtkTreeView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((procdata->disk_list)), ((gtk_tree_view_get_type
()))))))))), ((gtk_list_store_get_type ()))))))
;
296
297 entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
298
299 remove_old_disks(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entries, mountlist.number);
300
301 for (i = 0; i < mountlist.number; i++)
302 add_disk(list, &entries[i], procdata->config.show_all_fs);
303
304 g_free(entries);
305
306 return TRUE(!(0));
307}
308
309
310static void
311cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
312{
313 ProcData * const procdata = static_cast<ProcData*>(user_data);
314
315 procman_save_tree_state(procdata->settings,
316 GTK_WIDGET(treeview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_widget_get_type ()))))))
,
317 "disktreenew");
318}
319
320
321static void
322open_dir(GtkTreeView *tree_view,
323 GtkTreePath *path,
324 GtkTreeViewColumn *column,
325 gpointer user_data)
326{
327 GtkTreeIter iter;
328 GtkTreeModel *model;
329 char *dir, *url;
330
331 model = gtk_tree_view_get_model(tree_view);
332
333 if (!gtk_tree_model_get_iter(model, &iter, path)) {
334 char *p;
335 p = gtk_tree_path_to_string(path);
336 g_warning("Cannot get iter for path '%s'\n", p);
337 g_free(p);
338 return;
339 }
340
341 gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
342
343 url = g_strdup_printf("file://%s", dir);
344
345 GError* error = 0;
346 if (!g_app_info_launch_default_for_uri(url, NULL__null, &error)) {
347 g_warning("Cannot open '%s' : %s\n", url, error->message);
348 g_error_free(error);
349 }
350
351 g_free(url);
352 g_free(dir);
353}
354
355static guint timeout_id = 0;
356static GtkTreeViewColumn *current_column;
357
358static gboolean
359save_column_width (gpointer data)
360{
361 gint width;
362 gchar *key;
363 int id;
364 GSettings *settings;
365
366 settings = g_settings_get_child (G_SETTINGS (data)((((GSettings*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((g_settings_get_type ()))))))
, "disktreenew");
367 id = gtk_tree_view_column_get_sort_column_id (current_column);
368 width = gtk_tree_view_column_get_width (current_column);
369
370 key = g_strdup_printf ("col-%d-width", id);
371 g_settings_set_int(settings, key, width);
372 g_free (key);
373
374 if (timeout_id) {
375 g_source_remove (timeout_id);
376 timeout_id = 0;
377 }
378
379 return FALSE(0);
380}
381
382static void
383cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
384{
385 current_column = GTK_TREE_VIEW_COLUMN(widget)((((GtkTreeViewColumn*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((widget)), ((gtk_tree_view_column_get_type (
)))))))
;
386
387 if (timeout_id)
388 g_source_remove (timeout_id);
389
390 timeout_id = g_timeout_add (250, save_column_width, data);
391}
392
393void
394create_disk_view(ProcData *procdata, GtkBuilder *builder)
395{
396 GtkWidget *scrolled;
397 GtkWidget *disk_tree;
398 GtkListStore *model;
399 GtkTreeViewColumn *col;
400 GtkCellRenderer *cell;
401 guint i;
402
403 const gchar * const titles[] = {
404 N_("Device")("Device"),
405 N_("Directory")("Directory"),
406 N_("Type")("Type"),
407 N_("SubVolume")("SubVolume"),
408 N_("Total")("Total"),
409 N_("Free")("Free"),
410 N_("Available")("Available"),
411 N_("Used")("Used")
412 };
413
414 scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "disks_scrolled"))), ((
gtk_widget_get_type ()))))))
;
415
416 model = gtk_list_store_new(DISK_N_COLUMNS, /* n columns */
417 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DEVICE */
418 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DIR */
419 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_TYPE */
420 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_SUBVOLUME */
421 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_TOTAL */
422 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_FREE */
423 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_AVAIL */
424 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_USED */
425 CAIRO_GOBJECT_TYPE_SURFACEcairo_gobject_surface_get_type (), /* DISK_ICON */
426 G_TYPE_INT((GType) ((6) << (2)))); /* DISK_USED_PERCENTAGE */
427
428 disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_model_get_type ()))))))
);
429 g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("row-activated"), (((GCallback) (open_dir))), (__null
), __null, (GConnectFlags) 0)
;
430 procdata->disk_list = disk_tree;
431 gtk_container_add(GTK_CONTAINER(scrolled)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((scrolled)), ((gtk_container_get_type ()))))))
, disk_tree);
432 g_object_unref(G_OBJECT(model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
);
433
434 /* icon + device */
435
436 col = gtk_tree_view_column_new();
437 cell = gtk_cell_renderer_pixbuf_new();
438 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
439 gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
440 NULL__null);
441
442 cell = gtk_cell_renderer_text_new();
443 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
444 gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
445 NULL__null);
446 gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE])gettext (titles[DISK_DEVICE]));
447 gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
448 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
449 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
450 gtk_tree_view_column_set_min_width (col, 30);
451 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
452 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
453 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
454
455 /* sizes - used */
456
457 for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
458 cell = gtk_cell_renderer_text_new();
459 col = gtk_tree_view_column_new();
460 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
461 gtk_tree_view_column_set_title(col, _(titles[i])gettext (titles[i]));
462 gtk_tree_view_column_set_sort_column_id(col, i);
463 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
464 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
465 gtk_tree_view_column_set_min_width (col, 30);
466 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
467 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
468 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
469
470 switch (i) {
471 case DISK_TOTAL:
472 case DISK_FREE:
473 case DISK_AVAIL:
474 g_object_set(cell, "xalign", 1.0f, NULL__null);
475 gtk_tree_view_column_set_cell_data_func(col, cell,
476 &procman::storage_size_cell_data_func,
477 GUINT_TO_POINTER(i)((gpointer) (gulong) (i)),
478 NULL__null);
479 break;
480
481 default:
482 gtk_tree_view_column_set_attributes(col, cell,
483 "text", i,
484 NULL__null);
485 break;
486 }
487 }
488
489 /* used + percentage */
490
491 col = gtk_tree_view_column_new();
492 cell = gtk_cell_renderer_text_new();
493 g_object_set(cell, "xalign", 1.0f, NULL__null);
494 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
495 gtk_tree_view_column_set_cell_data_func(col, cell,
496 &procman::storage_size_cell_data_func,
497 GUINT_TO_POINTER(DISK_USED)((gpointer) (gulong) (DISK_USED)),
498 NULL__null);
499
500 cell = gtk_cell_renderer_progress_new();
501 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
502 gtk_tree_view_column_set_attributes(col, cell, "value",
503 DISK_USED_PERCENTAGE, NULL__null);
504 gtk_tree_view_column_set_title(col, _(titles[DISK_USED])gettext (titles[DISK_USED]));
505 gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
506 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
507 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
508 gtk_tree_view_column_set_min_width (col, 150);
509 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
510 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
511 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
512
513 /* numeric sort */
514
515 procman_get_tree_state(procdata->settings, disk_tree,
516 "disktreenew");
517
518 g_signal_connect (G_OBJECT(disk_tree), "columns-changed",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
519 G_CALLBACK(cb_disk_columns_changed), procdata)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
;
520}
diff --git a/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-c673b5.html b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-c673b5.html new file mode 100644 index 00000000..d6097c92 --- /dev/null +++ b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-c673b5.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 564, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-05-135451-6126-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-d507c5.html b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-d507c5.html new file mode 100644 index 00000000..056731e0 --- /dev/null +++ b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-d507c5.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 151, column 9
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-05-135451-6126-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
This statement is never executed
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-e8ff80.html b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-e8ff80.html new file mode 100644 index 00000000..b6b3b6e1 --- /dev/null +++ b/2023-09-05-135451-6126-1@c439634163d9_test-ci/report-e8ff80.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 350, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-05-135451-6126-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-05-135451-6126-1@c439634163d9_test-ci/scanview.css b/2023-09-05-135451-6126-1@c439634163d9_test-ci/scanview.css new file mode 100644 index 00000000..cf8a5a6a --- /dev/null +++ b/2023-09-05-135451-6126-1@c439634163d9_test-ci/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/2023-09-05-135451-6126-1@c439634163d9_test-ci/sorttable.js b/2023-09-05-135451-6126-1@c439634163d9_test-ci/sorttable.js new file mode 100644 index 00000000..32faa078 --- /dev/null +++ b/2023-09-05-135451-6126-1@c439634163d9_test-ci/sorttable.js @@ -0,0 +1,492 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse',''); + cell.className = cell.className.replace('sorttable_sorted',''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j=0; j 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } + else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } + else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i=0; i=0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a,b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); + if (isNaN(bb)) bb = 0; + return aa-bb; + }, + sort_alpha: function(a,b) { + if (a[0]==b[0]) return 0; + if (a[0] 0 ) { + var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for(var i = t; i > b; --i) { + if ( comp_func(list[i], list[i-1]) < 0 ) { + var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write(" + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef _PROCMAN_PROCMAN_H_
+#define _PROCMAN_PROCMAN_H_
+
+#include <glibmm/refptr.h>
+#include <cairo-gobject.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+#include <glibtop/cpu.h>
+
+#include <time.h>
+#include <sys/types.h>
+
+#include <map>
+#include <string>
+
+struct ProcInfo;
+struct ProcData;
+struct LoadGraph;
+
+#include "smooth_refresh.h"
+#include "prettytable.h"
+
+#define GSM_GSETTINGS_SCHEMA "org.mate.system-monitor"
+
+enum
+{
+    ALL_PROCESSES,
+    MY_PROCESSES,
+    ACTIVE_PROCESSES
+};
+
+enum
+{
+    VERY_HIGH_PRIORITY,
+    HIGH_PRIORITY,
+    NORMAL_PRIORITY,
+    LOW_PRIORITY,
+    VERY_LOW_PRIORITY,
+    CUSTOM_PRIORITY
+};
+
+static const unsigned MIN_UPDATE_INTERVAL =   1 * 1000;
+static const unsigned MAX_UPDATE_INTERVAL = 100 * 1000;
+
+enum ProcmanTab
+{
+    PROCMAN_TAB_SYSINFO,
+    PROCMAN_TAB_PROCESSES,
+    PROCMAN_TAB_RESOURCES,
+    PROCMAN_TAB_DISKS
+};
+
+struct ProcConfig
+{
+    gint        width;
+    gint        height;
+    gint        xpos;
+    gint        ypos;
+    gboolean    maximized;
+    gboolean    show_kill_warning;
+    gboolean    show_tree;
+    gboolean    show_all_fs;
+    int         update_interval;
+    int         graph_update_interval;
+    int         disks_update_interval;
+    gint        whose_process;
+    gint        current_tab;
+    GdkRGBA     cpu_color[GLIBTOP_NCPU];
+    GdkRGBA     mem_color;
+    GdkRGBA     swap_color;
+    GdkRGBA     net_in_color;
+    GdkRGBA     net_out_color;
+    GdkRGBA     bg_color;
+    GdkRGBA     frame_color;
+    gint        num_cpus;
+    bool solaris_mode;
+    bool network_in_bits;
+};
+
+struct MutableProcInfo
+{
+MutableProcInfo()<--- Member variable 'MutableProcInfo::cgroup_name' is not initialized in the constructor.<--- Member variable 'MutableProcInfo::unit' is not initialized in the constructor.<--- Member variable 'MutableProcInfo::session' is not initialized in the constructor.<--- Member variable 'MutableProcInfo::seat' is not initialized in the constructor.
+  : disk_write_bytes_current(0ULL),
+    disk_read_bytes_current(0ULL),
+    disk_write_bytes_total(0ULL),
+    disk_read_bytes_total(0ULL),
+    status(0U)
+    { }
+
+    std::string user;
+
+    gchar wchan[40];
+
+    // all these members are filled with libgtop which uses
+    // guint64 (to have fixed size data) but we don't need more
+    // than an unsigned long (even for 32bit apps on a 64bit
+    // kernel) as these data are amounts, not offsets.
+    gulong vmsize;
+    gulong memres;
+    gulong memshared;
+    gulong memwritable;
+    gulong mem;
+
+#ifdef HAVE_WNCK
+    // wnck gives an unsigned long
+    gulong memxserver;
+#endif
+
+    gulong start_time;
+    guint64 cpu_time;
+    guint64 disk_write_bytes_current;
+    guint64 disk_read_bytes_current;
+    guint64 disk_write_bytes_total;
+    guint64 disk_read_bytes_total;
+    guint status;
+    guint pcpu;
+    gint nice;
+    gchar *cgroup_name;
+
+    gchar *unit;
+    gchar *session;
+    gchar *seat;
+
+    std::string owner;
+};
+
+class ProcInfo
+: public MutableProcInfo
+{
+    /* undefined */ ProcInfo& operator=(const ProcInfo&);
+    /* undefined */ ProcInfo(const ProcInfo&);
+
+    typedef std::map<guint, std::string> UserMap;
+    /* cached username */
+    static UserMap users;
+
+  public:
+
+    // TODO: use a set instead
+    // sorted by pid. The map has a nice property : it is sorted
+    // by pid so this helps a lot when looking for the parent node
+    // as ppid is nearly always < pid.
+    typedef std::map<pid_t, ProcInfo*> List;
+    typedef List::iterator Iterator;
+
+    static List all;
+
+    static ProcInfo* find(pid_t pid);
+    static Iterator begin() { return ProcInfo::all.begin(); }
+    static Iterator end() { return ProcInfo::all.end(); }
+
+    ProcInfo(pid_t pid);
+    ~ProcInfo();
+    // adds one more ref to icon
+    void set_icon(Glib::RefPtr<Gdk::Pixbuf> icon);
+    void set_user(guint uid);
+    std::string lookup_user(guint uid);
+
+    GtkTreeIter      node;
+    cairo_surface_t *surface;
+    gchar           *tooltip;
+    gchar           *name;
+    gchar           *arguments;
+    gchar           *security_context;
+
+    const pid_t      pid;
+    pid_t            ppid;
+    guint            uid;
+
+// private:
+    // tracks cpu time per process keeps growing because if a
+    // ProcInfo is deleted this does not mean that the process is
+    // not going to be recreated on the next update.  For example,
+    // if dependencies + (My or Active), the proclist is cleared
+    // on each update.  This is a workaround
+    static std::map<pid_t, guint64> cpu_times;
+};
+
+struct ProcData
+{
+    // lazy initialization
+    static ProcData* get_instance();
+
+    GtkUIManager    *uimanager;
+    GtkActionGroup    *action_group;
+    GtkWidget    *statusbar;
+    gint        tip_message_cid;
+    GtkWidget    *tree;
+    GtkWidget    *loadavg;
+    GtkWidget    *endprocessbutton;
+    GtkWidget    *popup_menu;
+    GtkWidget    *disk_list;
+    GtkWidget    *notebook;
+    ProcConfig    config;
+    LoadGraph    *cpu_graph;
+    LoadGraph    *mem_graph;
+    LoadGraph    *net_graph;
+    gint        cpu_label_fixed_width;
+    gint        net_label_fixed_width;
+    ProcInfo    *selected_process;
+    GtkTreeSelection *selection;
+    guint        timeout;
+    guint        disk_timeout;
+
+    PrettyTable    pretty_table;
+
+    GSettings       *settings;
+    GtkWidget        *app;
+    GtkUIManager    *menu;
+
+    unsigned    frequency;
+
+    SmoothRefresh  *smooth_refresh;
+
+    guint64 cpu_total_time;
+    guint64 cpu_total_time_last;
+
+    gboolean terminating;
+
+private:
+    ProcData();
+    /* undefined */ ProcData(const ProcData &);
+    /* undefined */ ProcData& operator=(const ProcData &);
+};
+
+void        procman_save_config (ProcData *data);
+void        procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+gboolean    procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+
+struct ReniceArgs
+{
+    ProcData *procdata;
+    int nice_value;
+};
+
+struct KillArgs
+{
+    ProcData *procdata;
+    int signal;
+};
+
+#endif /* _PROCMAN_PROCMAN_H_ */
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/1.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/1.html new file mode 100644 index 00000000..b83a4070 --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/1.html @@ -0,0 +1,435 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
#ifndef _PROCMAN_SMOOTH_REFRESH
+#define _PROCMAN_SMOOTH_REFRESH
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <string>
+
+using std::string;
+
+class SmoothRefresh
+{
+  public:
+
+    /*
+      smooth_refresh_new
+
+      @config_interval : pointer to config_interval so we can observe
+      config_interval changes.
+
+      @return : initialized SmoothRefresh
+    */
+    SmoothRefresh(GSettings *a_settings);
+
+    ~SmoothRefresh();
+
+    /*
+      smooth_refresh_reset
+
+      Resets state and re-read config_interval
+    */
+    void reset();
+
+    /*
+      smooth_refresh_get
+
+      Computes the new refresh_interval so that CPU usage is lower than
+      SMOOTH_REFRESH_PCPU.
+
+      @new_interval : where the new refresh_interval is stored.
+
+      @return : TRUE is refresh_interval has changed. The new refresh_interval
+      is stored in @new_interval. Else FALSE;
+    */
+    bool get(guint &new_interval);
+
+    static const string KEY;
+    static const bool KEY_DEFAULT_VALUE;
+
+  private:
+
+    unsigned get_own_cpu_usage();
+
+    static void status_changed(GSettings *settings,
+                               const gchar *key,
+                               gpointer user_data);
+
+    void load_settings_value(const gchar *key);
+
+    /*
+      fuzzy logic:
+      - decrease refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_LO
+      - increase refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_HI
+
+    */
+
+    enum
+    {
+        PCPU_HI = 22,
+        PCPU_LO = 18
+    };
+
+    /*
+      -self : procman's PID (so we call getpid() only once)
+
+      -interval : current refresh interval
+
+      -config_interval : pointer to the configuration refresh interval.
+      Used to watch configuration changes
+
+      -interval >= -config_interval
+
+      -last_pcpu : to avoid spikes, the last CPU%. See PCPU_{LO,HI}
+
+      -last_total_time:
+      -last_cpu_time: Save last cpu and process times to compute CPU%
+    */
+
+    GSettings *settings;
+    bool active;
+    guint connection;
+    guint interval;
+    unsigned  last_pcpu;
+    guint64 last_total_time;
+    guint64 last_cpu_time;
+};
+
+#endif /* _PROCMAN_SMOOTH_REFRESH */
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/10.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/10.html new file mode 100644 index 00000000..cb5e0f54 --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/10.html @@ -0,0 +1,1067 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
#include <gio/gio.h>
+
+#if defined (__ELF__) && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
+# define SECTION __attribute__ ((section (".gresource.msm"), aligned (8)))
+#else
+# define SECTION
+#endif
+
+static const SECTION union { const guint8 data[3353]; const double alignment; void * const ptr;}  msm_resource_data = { {<--- union member 'Anonymous0::alignment' is never used.<--- union member 'Anonymous0::ptr' is never used.
+  0107, 0126, 0141, 0162, 0151, 0141, 0156, 0164, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0030, 0000, 0000, 0000, 0310, 0000, 0000, 0000, 0000, 0000, 0000, 0050, 0006, 0000, 0000, 0000, 
+  0000, 0000, 0000, 0000, 0001, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0005, 0000, 0000, 0000, 0376, 0236, 0033, 0101, 0005, 0000, 0000, 0000, 
+  0310, 0000, 0000, 0000, 0024, 0000, 0114, 0000, 0334, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 
+  0113, 0120, 0220, 0013, 0002, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 0004, 0000, 0114, 0000, 
+  0350, 0000, 0000, 0000, 0354, 0000, 0000, 0000, 0324, 0265, 0002, 0000, 0377, 0377, 0377, 0377, 
+  0354, 0000, 0000, 0000, 0001, 0000, 0114, 0000, 0360, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 
+  0173, 0250, 0316, 0037, 0000, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 0014, 0000, 0166, 0000, 
+  0000, 0001, 0000, 0000, 0034, 0006, 0000, 0000, 0234, 0164, 0275, 0021, 0000, 0000, 0000, 0000, 
+  0034, 0006, 0000, 0000, 0016, 0000, 0166, 0000, 0060, 0006, 0000, 0000, 0017, 0015, 0000, 0000, 
+  0201, 0321, 0040, 0031, 0001, 0000, 0000, 0000, 0017, 0015, 0000, 0000, 0005, 0000, 0114, 0000, 
+  0024, 0015, 0000, 0000, 0030, 0015, 0000, 0000, 0155, 0141, 0164, 0145, 0055, 0163, 0171, 0163, 
+  0164, 0145, 0155, 0055, 0155, 0157, 0156, 0151, 0164, 0157, 0162, 0057, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0157, 0162, 0147, 0057, 0005, 0000, 0000, 0000, 0057, 0000, 0000, 0000, 
+  0001, 0000, 0000, 0000, 0151, 0156, 0164, 0145, 0162, 0146, 0141, 0143, 0145, 0056, 0165, 0151, 
+  0242, 0073, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0133, 0133, 0163, 0352, 0066, 
+  0020, 0176, 0317, 0257, 0160, 0375, 0332, 0161, 0010, 0227, 0320, 0164, 0006, 0070, 0323, 0166, 
+  0232, 0364, 0241, 0347, 0114, 0046, 0344, 0114, 0037, 0031, 0331, 0136, 0260, 0212, 0054, 0271, 
+  0222, 0314, 0345, 0337, 0237, 0065, 0066, 0004, 0002, 0370, 0102, 0210, 0061, 0224, 0067, 0154, 
+  0257, 0054, 0355, 0267, 0253, 0335, 0317, 0253, 0245, 0363, 0145, 0346, 0063, 0143, 0002, 0122, 
+  0121, 0301, 0273, 0146, 0375, 0366, 0316, 0064, 0200, 0073, 0302, 0245, 0174, 0324, 0065, 0277, 
+  0277, 0076, 0132, 0017, 0346, 0227, 0336, 0115, 0347, 0047, 0313, 0062, 0236, 0200, 0203, 0044, 
+  0032, 0134, 0143, 0112, 0265, 0147, 0214, 0030, 0161, 0301, 0150, 0336, 0066, 0037, 0156, 0033, 
+  0206, 0145, 0241, 0020, 0345, 0032, 0344, 0220, 0070, 0320, 0353, 0110, 0370, 0057, 0244, 0022, 
+  0224, 0301, 0250, 0335, 0065, 0107, 0172, 0374, 0263, 0371, 0066, 0113, 0363, 0266, 0321, 0062, 
+  0153, 0275, 0216, 0260, 0377, 0005, 0107, 0033, 0016, 0043, 0112, 0165, 0315, 0047, 0075, 0376, 
+  0207, 0162, 0127, 0114, 0115, 0203, 0272, 0135, 0323, 0047, 0224, 0017, 0246, 0361, 0215, 0136, 
+  0047, 0220, 0042, 0000, 0251, 0347, 0006, 0047, 0076, 0164, 0115, 0207, 0160, 0153, 0050, 0234, 
+  0120, 0231, 0275, 0107, 0302, 0024, 0164, 0152, 0113, 0201, 0055, 0121, 0115, 0065, 0003, 0323, 
+  0320, 0222, 0160, 0305, 0210, 0046, 0066, 0303, 0233, 0163, 0300, 0221, 0375, 0271, 0322, 0340, 
+  0033, 0137, 0005, 0247, 0132, 0310, 0224, 0127, 0270, 0060, 0044, 0041, 0323, 0326, 0224, 0272, 
+  0332, 0063, 0173, 0255, 0326, 0135, 0016, 0141, 0017, 0350, 0310, 0323, 0050, 0375, 0353, 0375, 
+  0272, 0264, 0343, 0121, 0346, 0356, 0120, 0375, 0167, 0061, 0133, 0323, 0333, 0306, 0253, 0255, 
+  0067, 0117, 0250, 0242, 0270, 0172, 0263, 0367, 0052, 0303, 0064, 0215, 0013, 0200, 0043, 0044, 
+  0005, 0256, 0211, 0106, 0263, 0230, 0075, 0264, 0217, 0246, 0016, 0141, 0073, 0226, 0033, 0060, 
+  0264, 0252, 0047, 0230, 0013, 0022, 0355, 0126, 0113, 0356, 0356, 0323, 0345, 0233, 0320, 0140, 
+  0013, 0061, 0216, 0025, 0342, 0313, 0253, 0143, 0050, 0224, 0041, 0351, 0023, 0071, 0242, 0334, 
+  0122, 0232, 0110, 0204, 0276, 0336, 0310, 0026, 0005, 0356, 0346, 0023, 0324, 0042, 0170, 0057, 
+  0230, 0151, 0113, 0065, 0127, 0224, 0017, 0105, 0151, 0346, 0364, 0140, 0026, 0220, 0110, 0241, 
+  0214, 0127, 0116, 0162, 0312, 0331, 0102, 0242, 0305, 0227, 0176, 0237, 0212, 0222, 0012, 0210, 
+  0203, 0061, 0143, 0017, 0104, 0251, 0376, 0263, 0373, 0141, 0055, 0206, 0365, 0235, 0264, 0241, 
+  0347, 0101, 0264, 0251, 0211, 0155, 0356, 0000, 0376, 0157, 0142, 0003, 0333, 0204, 0236, 0055, 
+  0156, 0225, 0001, 0176, 0074, 0323, 0376, 0100, 0263, 0076, 0164, 0245, 0034, 0242, 0066, 0106, 
+  0330, 0266, 0243, 0026, 0261, 0255, 0041, 0145, 0154, 0307, 0264, 0265, 0325, 0230, 0254, 0175, 
+  0270, 0362, 0103, 0034, 0354, 0374, 0037, 0234, 0060, 0063, 0234, 0355, 0165, 0332, 0207, 0074, 
+  0373, 0172, 0315, 0275, 0230, 0040, 0356, 0200, 0114, 0106, 0045, 0372, 0227, 0107, 0030, 0035, 
+  0241, 0136, 0213, 0340, 0126, 0310, 0231, 0226, 0100, 0147, 0315, 0020, 0073, 0134, 0306, 0212, 
+  0003, 0241, 0150, 0014, 0360, 0335, 0141, 0136, 0331, 0167, 0244, 0140, 0014, 0334, 0365, 0144, 
+  0037, 0071, 0050, 0050, 0005, 0152, 0240, 0222, 0247, 0145, 0144, 0213, 0143, 0173, 0252, 0362, 
+  0010, 0152, 0144, 0105, 0041, 0312, 0354, 0121, 0236, 0073, 0016, 0236, 0312, 0200, 0365, 0003, 
+  0303, 0112, 0250, 0065, 0016, 0137, 0030, 0016, 0323, 0147, 0142, 0073, 0073, 0276, 0133, 0040, 
+  0054, 0376, 0311, 0135, 0143, 0360, 0034, 0217, 0116, 0131, 0157, 0250, 0300, 0042, 0116, 0264, 
+  0142, 0213, 0004, 0001, 0020, 0174, 0221, 0003, 0331, 0130, 0034, 0337, 0135, 0044, 0070, 0100, 
+  0047, 0240, 0254, 0204, 0342, 0145, 0373, 0127, 0262, 0143, 0021, 0244, 0014, 0375, 0102, 0216, 
+  0036, 0301, 0050, 0337, 0261, 0334, 0123, 0071, 0107, 0043, 0335, 0071, 0062, 0227, 0125, 0314, 
+  0315, 0162, 0347, 0365, 0105, 0052, 0253, 0102, 0122, 0177, 0136, 0206, 0254, 0102, 0306, 0332, 
+  0203, 0312, 0247, 0146, 0177, 0374, 0014, 0273, 0046, 0377, 0242, 0214, 0165, 0077, 0234, 0116, 
+  0020, 0126, 0347, 0373, 0154, 0257, 0116, 0167, 0005, 0011, 0115, 0244, 0125, 0025, 0266, 0325, 
+  0037, 0317, 0337, 0215, 0277, 0250, 0302, 0017, 0362, 0171, 0312, 0370, 0131, 0022, 0131, 0067, 
+  0264, 0044, 0132, 0113, 0212, 0151, 0010, 0324, 0332, 0357, 0144, 0300, 0064, 0376, 0032, 0067, 
+  0046, 0204, 0205, 0013, 0267, 0142, 0156, 0124, 0201, 0250, 0255, 0217, 0071, 0063, 0036, 0265, 
+  0341, 0220, 0043, 0111, 0002, 0357, 0154, 0167, 0371, 0301, 0156, 0336, 0376, 0160, 0255, 0342, 
+  0221, 0211, 0351, 0006, 0222, 0103, 0274, 0121, 0032, 0220, 0223, 0175, 0234, 0076, 0265, 0256, 
+  0161, 0377, 0113, 0332, 0354, 0202, 0205, 0076, 0212, 0056, 0041, 0112, 0013, 0231, 0022, 0331, 
+  0152, 0056, 0101, 0037, 0047, 0137, 0040, 0050, 0201, 0133, 0370, 0300, 0212, 0271, 0112, 0063, 
+  0165, 0311, 0263, 0135, 0103, 0322, 0213, 0010, 0300, 0040, 0146, 0172, 0276, 0160, 0121, 0230, 
+  0013, 0176, 0112, 0056, 0204, 0223, 0044, 0144, 0076, 0235, 0301, 0345, 0246, 0072, 0025, 0045, 
+  0372, 0347, 0032, 0370, 0174, 0360, 0057, 0060, 0023, 0107, 0132, 0125, 0041, 0023, 0177, 0005, 
+  0037, 0223, 0260, 0201, 0206, 0067, 0372, 0123, 0022, 0134, 0263, 0162, 0161, 0347, 0274, 0146, 
+  0345, 0174, 0131, 0071, 0072, 0135, 0302, 0004, 0263, 0310, 0134, 0252, 0333, 0302, 0337, 0230, 
+  0231, 0124, 0167, 0161, 0254, 0264, 0015, 0361, 0223, 0244, 0356, 0033, 0306, 0013, 0227, 0055, 
+  0005, 0337, 0002, 0111, 0070, 0257, 0051, 0066, 0022, 0160, 0273, 0100, 0126, 0157, 0147, 0274, 
+  0324, 0023, 0276, 0030, 0001, 0007, 0261, 0253, 0256, 0221, 0043, 0010, 0051, 0334, 0361, 0145, 
+  0326, 0066, 0163, 0342, 0225, 0122, 0143, 0307, 0005, 0027, 0015, 0115, 0231, 0241, 0205, 0301, 
+  0120, 0133, 0030, 0214, 0210, 0343, 0245, 0223, 0035, 0055, 0202, 0225, 0334, 0201, 0201, 0143, 
+  0063, 0003, 0140, 0240, 0075, 0053, 0370, 0343, 0144, 0361, 0271, 0006, 0250, 0037, 0325, 0000, 
+  0007, 0034, 0111, 0235, 0342, 0341, 0225, 0362, 0136, 0024, 0345, 0255, 0177, 0220, 0125, 0160, 
+  0320, 0027, 0110, 0171, 0043, 0255, 0252, 0100, 0171, 0277, 0201, 0236, 0012, 0071, 0276, 0122, 
+  0335, 0342, 0116, 0171, 0245, 0272, 0173, 0330, 0154, 0073, 0067, 0233, 0215, 0140, 0074, 0031, 
+  0233, 0155, 0345, 0154, 0225, 0151, 0076, 0134, 0062, 0355, 0215, 0217, 0370, 0160, 0252, 0263, 
+  0042, 0137, 0057, 0313, 0125, 0237, 0023, 0377, 0112, 0063, 0203, 0026, 0232, 0260, 0101, 0162, 
+  0336, 0352, 0236, 0225, 0055, 0136, 0243, 0245, 0033, 0057, 0311, 0322, 0253, 0141, 0220, 0372, 
+  0207, 0015, 0242, 0160, 0357, 0237, 0333, 0256, 0350, 0143, 0104, 0377, 0134, 0374, 0357, 0113, 
+  0336, 0020, 0150, 0005, 0175, 0206, 0233, 0241, 0072, 0206, 0070, 0302, 0106, 0300, 0101, 0040, 
+  0267, 0341, 0137, 0034, 0120, 0133, 0121, 0327, 0063, 0050, 0235, 0221, 0045, 0077, 0215, 0322, 
+  0366, 0156, 0112, 0256, 0156, 0154, 0071, 0114, 0334, 0362, 0334, 0070, 0014, 0346, 0337, 0042, 
+  0077, 0360, 0321, 0131, 0336, 0347, 0342, 0200, 0072, 0143, 0220, 0003, 0262, 0172, 0136, 0006, 
+  0244, 0233, 0235, 0007, 0355, 0343, 0065, 0163, 0155, 0300, 0176, 0127, 0071, 0330, 0227, 0241, 
+  0376, 0202, 0101, 0157, 0225, 0016, 0372, 0045, 0026, 0176, 0076, 0122, 0146, 0313, 0255, 0134, 
+  0306, 0262, 0057, 0243, 0050, 0164, 0274, 0126, 0273, 0306, 0061, 0133, 0355, 0242, 0276, 0261, 
+  0052, 0124, 0145, 0136, 0100, 0211, 0120, 0072, 0007, 0167, 0332, 0065, 0112, 0353, 0264, 0033, 
+  0226, 0327, 0150, 0127, 0106, 0143, 0134, 0073, 0317, 0327, 0363, 0256, 0166, 0156, 0227, 0252, 
+  0361, 0265, 0225, 0273, 0102, 0045, 0274, 0002, 0273, 0245, 0171, 0314, 0020, 0062, 0254, 0106, 
+  0004, 0171, 0244, 0014, 0214, 0370, 0137, 0070, 0207, 0006, 0221, 0346, 0261, 0202, 0310, 0231, 
+  0235, 0074, 0364, 0061, 0160, 0204, 0312, 0046, 0062, 0141, 0207, 0253, 0313, 0112, 0237, 0100, 
+  0064, 0076, 0261, 0153, 0054, 0113, 0252, 0170, 0136, 0337, 0276, 0361, 0366, 0117, 0332, 0233, 
+  0037, 0325, 0360, 0311, 0023, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0160, 0162, 0145, 0146, 
+  0145, 0162, 0145, 0156, 0143, 0145, 0163, 0056, 0165, 0151, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0065, 0123, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0134, 0335, 0162, 0342, 0066, 
+  0024, 0276, 0357, 0123, 0250, 0276, 0355, 0050, 0004, 0262, 0155, 0167, 0072, 0301, 0073, 0335, 
+  0335, 0046, 0335, 0231, 0266, 0263, 0323, 0354, 0266, 0227, 0036, 0331, 0076, 0140, 0155, 0204, 
+  0344, 0112, 0002, 0102, 0257, 0372, 0054, 0175, 0264, 0076, 0111, 0217, 0177, 0010, 0140, 0300, 
+  0066, 0004, 0210, 0041, 0334, 0331, 0346, 0110, 0072, 0072, 0377, 0237, 0216, 0206, 0353, 0067, 
+  0017, 0003, 0101, 0106, 0240, 0015, 0127, 0262, 0353, 0264, 0057, 0056, 0035, 0002, 0062, 0120, 
+  0041, 0227, 0375, 0256, 0363, 0371, 0323, 0015, 0175, 0355, 0274, 0161, 0277, 0272, 0376, 0232, 
+  0122, 0162, 0013, 0022, 0064, 0263, 0020, 0222, 0061, 0267, 0021, 0351, 0013, 0026, 0002, 0271, 
+  0272, 0270, 0172, 0175, 0321, 0041, 0224, 0042, 0021, 0227, 0026, 0164, 0217, 0005, 0340, 0136, 
+  0153, 0370, 0153, 0310, 0065, 0030, 0042, 0270, 0337, 0165, 0372, 0366, 0376, 0033, 0147, 0266, 
+  0312, 0325, 0105, 0347, 0225, 0323, 0162, 0257, 0225, 0377, 0005, 0002, 0113, 0002, 0301, 0214, 
+  0351, 0072, 0267, 0366, 0376, 0303, 0200, 0365, 0301, 0041, 0074, 0354, 0072, 0074, 0171, 0154, 
+  0073, 0356, 0165, 0254, 0125, 0014, 0332, 0116, 0210, 0144, 0003, 0350, 0072, 0043, 0156, 0270, 
+  0057, 0300, 0161, 0077, 0351, 0041, 0134, 0267, 0246, 0277, 0056, 0321, 0005, 0114, 0322, 0236, 
+  0012, 0206, 0306, 0161, 0157, 0230, 0060, 0145, 0244, 0074, 0120, 0222, 0046, 0217, 0216, 0073, 
+  0346, 0062, 0124, 0143, 0032, 0010, 0265, 0070, 0242, 0225, 0261, 0132, 0203, 0345, 0316, 0241, 
+  0131, 0216, 0100, 0304, 0324, 0327, 0152, 0154, 0100, 0327, 0143, 0371, 0075, 0147, 0102, 0365, 
+  0063, 0236, 0143, 0015, 0075, 0320, 0250, 0161, 0060, 0136, 0230, 0175, 0177, 0012, 0137, 0276, 
+  0322, 0041, 0150, 0072, 0346, 0241, 0215, 0034, 0367, 0333, 0022, 0112, 0313, 0055, 0212, 0204, 
+  0130, 0315, 0244, 0021, 0314, 0062, 0024, 0120, 0327, 0231, 0000, 0256, 0161, 0067, 0061, 0026, 
+  0006, 0344, 0127, 0045, 0271, 0125, 0232, 0174, 0234, 0161, 0130, 0062, 0135, 0010, 0075, 0066, 
+  0024, 0166, 0272, 0362, 0253, 0313, 0313, 0032, 0304, 0021, 0360, 0176, 0144, 0221, 0272, 0123, 
+  0116, 0155, 0254, 0126, 0023, 0232, 0030, 0075, 0215, 0031, 0262, 0142, 0053, 0125, 0151, 0047, 
+  0061, 0320, 0210, 0047, 0224, 0231, 0124, 0347, 0151, 0203, 0210, 0213, 0220, 0244, 0316, 0042, 
+  0231, 0240, 0351, 0053, 0132, 0211, 0257, 0036, 0234, 0025, 0332, 0172, 0213, 0237, 0123, 0125, 
+  0145, 0023, 0171, 0202, 0115, 0324, 0320, 0076, 0111, 0113, 0003, 0246, 0373, 0134, 0122, 0253, 
+  0342, 0162, 0035, 0345, 0164, 0276, 0262, 0126, 0015, 0312, 0111, 0225, 0346, 0050, 0027, 0146, 
+  0321, 0277, 0035, 0027, 0035, 0335, 0362, 0200, 0211, 0022, 0172, 0023, 0263, 0000, 0103, 0214, 
+  0343, 0166, 0252, 0045, 0303, 0202, 0144, 0132, 0017, 0045, 0317, 0126, 0012, 0150, 0210, 0354, 
+  0311, 0242, 0230, 0026, 0007, 0155, 0040, 0253, 0164, 0321, 0265, 0313, 0144, 0153, 0044, 0076, 
+  0347, 0371, 0331, 0207, 0245, 0311, 0005, 0363, 0101, 0070, 0356, 0317, 0110, 0123, 0042, 0200, 
+  0241, 0001, 0232, 0361, 0110, 0131, 0034, 0003, 0103, 0077, 0010, 0240, 0132, 0165, 0133, 0304, 
+  0222, 0012, 0112, 0015, 0001, 0360, 0021, 0030, 0232, 0173, 0105, 0345, 0200, 0064, 0314, 0071, 
+  0156, 0026, 0355, 0126, 0106, 0034, 0324, 0355, 0075, 0052, 0167, 0151, 0044, 0074, 0304, 0114, 
+  0206, 0325, 0233, 0354, 0161, 0041, 0052, 0331, 0210, 0225, 0341, 0231, 0271, 0055, 0070, 0157, 
+  0353, 0161, 0361, 0126, 0256, 0311, 0072, 0012, 0115, 0003, 0176, 0225, 0106, 0337, 0025, 0263, 
+  0302, 0111, 0252, 0264, 0335, 0004, 0225, 0266, 0313, 0125, 0172, 0140, 0266, 0160, 0021, 0232, 
+  0104, 0164, 0307, 0005, 0031, 0356, 0320, 0044, 0223, 0242, 0112, 0322, 0100, 0211, 0341, 0100, 
+  0232, 0156, 0033, 0237, 0223, 0064, 0216, 0017, 0130, 0115, 0055, 0333, 0353, 0255, 0346, 0141, 
+  0156, 0255, 0012, 0043, 0244, 0264, 0136, 0077, 0371, 0162, 0210, 0162, 0143, 0323, 0350, 0236, 
+  0155, 0211, 0226, 0004, 0371, 0025, 0373, 0373, 0115, 0131, 0360, 0225, 0272, 0317, 0366, 0050, 
+  0247, 0157, 0007, 0360, 0227, 0150, 0152, 0056, 0025, 0164, 0243, 0232, 0164, 0045, 0125, 0120, 
+  0271, 0346, 0073, 0125, 0232, 0307, 0211, 0260, 0016, 0062, 0130, 0254, 0141, 0305, 0344, 0345, 
+  0166, 0160, 0020, 0023, 0330, 0257, 0214, 0332, 0235, 0035, 0132, 0037, 0212, 0162, 0146, 0172, 
+  0355, 0327, 0173, 0021, 0277, 0017, 0021, 0033, 0161, 0245, 0017, 0042, 0373, 0205, 0015, 0175, 
+  0127, 0307, 0227, 0176, 0111, 0063, 0326, 0032, 0236, 0275, 0074, 0237, 0035, 0302, 0152, 0230, 
+  0340, 0175, 0324, 0232, 0261, 0114, 0333, 0022, 0272, 0214, 0243, 0125, 0150, 0340, 0155, 0316, 
+  0164, 0131, 0055, 0211, 0162, 0021, 0100, 0005, 0227, 0100, 0007, 0052, 0134, 0261, 0001, 0146, 
+  0255, 0346, 0230, 0335, 0301, 0314, 0075, 0347, 0243, 0307, 0031, 0010, 0040, 0043, 0046, 0206, 
+  0251, 0135, 0212, 0060, 0301, 0246, 0255, 0371, 0061, 0225, 0371, 0106, 0100, 0317, 0122, 0034, 
+  0301, 0202, 0250, 0020, 0374, 0213, 0300, 0100, 0305, 0253, 0351, 0066, 0115, 0022, 0257, 0066, 
+  0267, 0125, 0317, 0100, 0220, 0071, 0321, 0001, 0064, 0237, 0143, 0207, 0124, 0361, 0025, 0376, 
+  0135, 0151, 0336, 0213, 0042, 0350, 0324, 0316, 0223, 0303, 0070, 0144, 0026, 0274, 0024, 0117, 
+  0240, 0172, 0017, 0227, 0057, 0353, 0006, 0313, 0142, 0236, 0154, 0167, 0266, 0166, 0356, 0307, 
+  0115, 0036, 0316, 0271, 0327, 0073, 0255, 0367, 0071, 0225, 0074, 0231, 0062, 0205, 0017, 0004, 
+  0215, 0117, 0311, 0320, 0374, 0120, 0121, 0100, 0017, 0045, 0246, 0205, 0304, 0225, 0053, 0071, 
+  0035, 0110, 0030, 0050, 0311, 0203, 0044, 0207, 0364, 0001, 0215, 0154, 0205, 0060, 0114, 0314, 
+  0245, 0134, 0163, 0056, 0362, 0014, 0276, 0274, 0244, 0312, 0073, 0344, 0157, 0036, 0207, 0254, 
+  0337, 0302, 0041, 0352, 0040, 0056, 0363, 0071, 0021, 0171, 0063, 0134, 0361, 0277, 0177, 0376, 
+  0055, 0233, 0127, 0360, 0201, 0117, 0223, 0003, 0301, 0102, 0275, 0136, 0074, 0077, 0341, 0175, 
+  0156, 0115, 0241, 0010, 0334, 0114, 0013, 0355, 0335, 0150, 0241, 0121, 0252, 0177, 0027, 0101, 
+  0260, 0200, 0101, 0315, 0100, 0051, 0033, 0125, 0200, 0320, 0125, 0336, 0366, 0223, 0114, 0136, 
+  0210, 0227, 0115, 0100, 0064, 0364, 0064, 0230, 0350, 0070, 0201, 0152, 0025, 0017, 0233, 0205, 
+  0210, 0120, 0263, 0061, 0345, 0062, 0304, 0202, 0321, 0046, 0265, 0132, 0221, 0174, 0077, 0006, 
+  0321, 0336, 0221, 0101, 0004, 0311, 0207, 0055, 0354, 0341, 0107, 0201, 0144, 0304, 0207, 0236, 
+  0322, 0100, 0020, 0261, 0342, 0352, 0104, 0151, 0342, 0335, 0043, 0330, 0115, 0236, 0037, 0203, 
+  0314, 0331, 0104, 0236, 0313, 0104, 0072, 0273, 0212, 0031, 0112, 0060, 0315, 0315, 0026, 0106, 
+  0342, 0275, 0347, 0043, 0036, 0002, 0171, 0367, 0361, 0063, 0031, 0032, 0326, 0007, 0342, 0117, 
+  0322, 0227, 0100, 0015, 0245, 0075, 0133, 0306, 0163, 0131, 0306, 0325, 0163, 0244, 0260, 0166, 
+  0163, 0363, 0346, 0323, 0241, 0172, 0217, 0203, 0010, 0315, 0121, 0036, 0222, 0354, 0010, 0370, 
+  0147, 0022, 0150, 0004, 0062, 0370, 0040, 0061, 0053, 0015, 0322, 0263, 0034, 0162, 0223, 0262, 
+  0125, 0062, 0315, 0227, 0241, 0261, 0274, 0067, 0161, 0334, 0344, 0230, 0266, 0204, 0016, 0060, 
+  0257, 0305, 0206, 0377, 0135, 0171, 0100, 0133, 0175, 0122, 0120, 0030, 0360, 0220, 0237, 0137, 
+  0134, 0236, 0370, 0151, 0302, 0306, 0356, 0324, 0074, 0054, 0135, 0327, 0247, 0052, 0117, 0023, 
+  0267, 0161, 0255, 0324, 0304, 0033, 0341, 0140, 0037, 0063, 0326, 0010, 0367, 0346, 0074, 0315, 
+  0104, 0152, 0054, 0023, 0020, 0056, 0270, 0261, 0173, 0106, 0340, 0126, 0003, 0170, 0271, 0201, 
+  0155, 0352, 0131, 0315, 0302, 0346, 0201, 0126, 0102, 0100, 0370, 0147, 0172, 0047, 0244, 0250, 
+  0170, 0223, 0377, 0172, 0214, 0375, 0011, 0023, 0261, 0344, 0226, 0113, 0326, 0322, 0342, 0262, 
+  0216, 0361, 0177, 0102, 0255, 0376, 0301, 0141, 0116, 0014, 0363, 0172, 0076, 0214, 0020, 0030, 
+  0332, 0245, 0241, 0217, 0063, 0127, 0371, 0010, 0244, 0260, 0230, 0032, 0054, 0121, 0023, 0053, 
+  0130, 0335, 0350, 0137, 0272, 0154, 0140, 0100, 0074, 0236, 0222, 0256, 0224, 0302, 0335, 0043, 
+  0301, 0242, 0105, 0114, 0203, 0052, 0235, 0315, 0320, 0132, 0121, 0102, 0235, 0140, 0041, 0327, 
+  0350, 0105, 0027, 0274, 0234, 0044, 0046, 0217, 0363, 0060, 0337, 0251, 0033, 0340, 0223, 0076, 
+  0133, 0203, 0342, 0372, 0042, 0150, 0257, 0024, 0055, 0316, 0100, 0263, 0036, 0367, 0322, 0312, 
+  0073, 0357, 0112, 0153, 0060, 0152, 0250, 0203, 0163, 0157, 0362, 0171, 0172, 0223, 0063, 0361, 
+  0367, 0065, 0213, 0243, 0146, 0001, 0236, 0047, 0001, 0231, 0342, 0316, 0016, 0331, 0277, 0254, 
+  0271, 0277, 0365, 0176, 0173, 0233, 0262, 0174, 0006, 0071, 0307, 0000, 0162, 0226, 0014, 0255, 
+  0241, 0015, 0323, 0203, 0037, 0063, 0154, 0333, 0200, 0235, 0011, 0264, 0320, 0212, 0075, 0255, 
+  0056, 0354, 0154, 0233, 0347, 0056, 0254, 0273, 0102, 0030, 0307, 0326, 0205, 0135, 0277, 0205, 
+  0163, 0027, 0366, 0324, 0273, 0260, 0076, 0112, 0151, 0233, 0166, 0312, 0135, 0244, 0306, 0104, 
+  0202, 0035, 0053, 0175, 0117, 0114, 0014, 0220, 0100, 0113, 0222, 0314, 0166, 0232, 0275, 0224, 
+  0272, 0301, 0365, 0004, 0032, 0266, 0057, 0247, 0347, 0122, 0271, 0150, 0355, 0033, 0332, 0233, 
+  0301, 0355, 0105, 0350, 0330, 0204, 0334, 0371, 0373, 0224, 0243, 0215, 0254, 0157, 0215, 0170, 
+  0366, 0007, 0312, 0053, 0113, 0332, 0020, 0106, 0374, 0014, 0311, 0237, 0011, 0222, 0117, 0205, 
+  0177, 0074, 0227, 0205, 0213, 0034, 0037, 0025, 0324, 0256, 0161, 0125, 0370, 0014, 0266, 0033, 
+  0003, 0266, 0227, 0114, 0355, 0310, 0301, 0366, 0336, 0100, 0364, 0124, 0120, 0047, 0174, 0215, 
+  0171, 0151, 0213, 0057, 0027, 0076, 0057, 0211, 0342, 0330, 0300, 0363, 0272, 0015, 0234, 0241, 
+  0363, 0251, 0103, 0147, 0046, 0204, 0067, 0325, 0176, 0172, 0167, 0165, 0023, 0000, 0235, 0342, 
+  0147, 0017, 0247, 0040, 0230, 0232, 0201, 0230, 0364, 0117, 0000, 0316, 0330, 0371, 0214, 0235, 
+  0137, 0310, 0175, 0305, 0251, 0343, 0274, 0324, 0333, 0212, 0213, 0373, 0077, 0052, 0334, 0161, 
+  0276, 0323, 0170, 0012, 0056, 0167, 0302, 0067, 0032, 0367, 0350, 0247, 0315, 0271, 0370, 0170, 
+  0063, 0053, 0033, 0236, 0347, 0362, 0143, 0310, 0315, 0175, 0162, 0051, 0116, 0302, 0370, 0144, 
+  0357, 0077, 0116, 0265, 0377, 0242, 0157, 0077, 0256, 0120, 0364, 0013, 0276, 0000, 0231, 0233, 
+  0004, 0115, 0044, 0062, 0102, 0031, 0235, 0357, 0077, 0036, 0305, 0242, 0263, 0126, 0105, 0147, 
+  0227, 0235, 0234, 0004, 0274, 0171, 0071, 0170, 0153, 0114, 0063, 0047, 0115, 0015, 0167, 0313, 
+  0210, 0162, 0133, 0041, 0075, 0245, 0237, 0323, 0314, 0276, 0136, 0315, 0320, 0271, 0247, 0177, 
+  0161, 0232, 0176, 0310, 0341, 0174, 0226, 0120, 0115, 0341, 0235, 0150, 0060, 0261, 0222, 0006, 
+  0127, 0240, 0355, 0166, 0366, 0277, 0207, 0171, 0243, 0036, 0113, 0321, 0171, 0312, 0222, 0201, 
+  0337, 0073, 0356, 0374, 0137, 0175, 0055, 0015, 0154, 0025, 0131, 0230, 0361, 0070, 0373, 0163, 
+  0313, 0257, 0376, 0007, 0112, 0344, 0157, 0105, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0155, 
+  0141, 0164, 0145, 0057, 0000, 0000, 0000, 0000
+} };
+
+static GStaticResource static_resource = { msm_resource_data.data, sizeof (msm_resource_data.data) - 1 /* nul terminator */, NULL, NULL, NULL };
+
+G_MODULE_EXPORT
+GResource *msm_get_resource (void);
+GResource *msm_get_resource (void)
+{
+  return g_static_resource_get_resource (&static_resource);
+}
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GLib Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __G_CONSTRUCTOR_H__
+#define __G_CONSTRUCTOR_H__
+
+/*
+  If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and
+  destructors, in a usable way, including e.g. on library unload. If not you're on
+  your own.
+
+  Some compilers need #pragma to handle this, which does not work with macros,
+  so the way you need to use this is (for constructors):
+
+  #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+  #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(my_constructor)
+  #endif
+  G_DEFINE_CONSTRUCTOR(my_constructor)
+  static void my_constructor(void) {
+   ...
+  }
+
+*/
+
+#ifndef __GTK_DOC_IGNORE__
+
+#if  __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func (void);
+#define G_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func (void);
+
+#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
+/* Visual studio 2008 and later has _Pragma */
+
+/*
+ * Only try to include gslist.h if not already included via glib.h,
+ * so that items using gconstructor.h outside of GLib (such as
+ * GResources) continue to build properly.
+ */
+#ifndef __G_LIB_H__
+#include "gslist.h"
+#endif
+
+#include <stdlib.h>
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* We do some weird things to avoid the constructors being optimized
+ * away on VS2015 if WholeProgramOptimization is enabled. First we
+ * make a reference to the array from the wrapper to make sure its
+ * references. Then we use a pragma to make sure the wrapper function
+ * symbol is always included at the link stage. Also, the symbols
+ * need to be extern (but not dllexport), even though they are not
+ * really used from another object file.
+ */
+
+/* We need to account for differences between the mangling of symbols
+ * for x86 and x64/ARM/ARM64 programs, as symbols on x86 are prefixed
+ * with an underscore but symbols on x64/ARM/ARM64 are not.
+ */
+#ifdef _M_IX86
+#define G_MSVC_SYMBOL_PREFIX "_"
+#else
+#define G_MSVC_SYMBOL_PREFIX ""
+#endif
+
+#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
+#define G_DEFINE_DESTRUCTOR(_func) G_MSVC_DTOR (_func, G_MSVC_SYMBOL_PREFIX)
+
+#define G_MSVC_CTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _wrapper(void) { _func(); g_slist_find (NULL,  _array ## _func); return 0; } \
+  __pragma(comment(linker,"/include:" _sym_prefix # _func "_wrapper")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _wrapper;
+
+#define G_MSVC_DTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _constructor(void) { atexit (_func); g_slist_find (NULL,  _array ## _func); return 0; } \
+   __pragma(comment(linker,"/include:" _sym_prefix # _func "_constructor")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined (_MSC_VER)
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* Pre Visual studio 2008 must use #pragma section */
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _wrapper(void) { _func(); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func ## _wrapper;
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _constructor(void) { atexit (_func); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined(__SUNPRO_C)
+
+/* This is not tested, but i believe it should work, based on:
+ * http://opensource.apple.com/source/OpenSSL098/OpenSSL098-35/src/fips/fips_premain.c
+ */
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  init(_func)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void);
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  fini(_func)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void);
+
+#else
+
+/* constructors not supported for this compiler */
+
+#endif
+
+#endif /* __GTK_DOC_IGNORE__ */
+#endif /* __G_CONSTRUCTOR_H__ */
+
+#ifdef G_HAS_CONSTRUCTORS
+
+#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(msmresource_constructor)
+#endif
+G_DEFINE_CONSTRUCTOR(msmresource_constructor)
+#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(msmresource_destructor)
+#endif
+G_DEFINE_DESTRUCTOR(msmresource_destructor)
+
+#else
+#warning "Constructor not supported on this compiler, linking in resources will not work"
+#endif
+
+static void msmresource_constructor (void)
+{
+  g_static_resource_init (&static_resource);
+}
+
+static void msmresource_destructor (void)
+{
+  g_static_resource_fini (&static_resource);
+}
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/11.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/11.html new file mode 100644 index 00000000..174d418f --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/11.html @@ -0,0 +1,1039 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
#include <config.h>
+
+#include <glib/gi18n.h>
+#include <glibtop/procopenfiles.h>
+#include <sys/stat.h>
+#include <netdb.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include "procman.h"
+#include "openfiles.h"
+#include "proctable.h"
+#include "util.h"
+#include "settings-keys.h"
+
+#ifndef NI_IDN
+#define NI_IDN 0
+#endif
+
+enum
+{
+    COL_FD,
+    COL_TYPE,
+    COL_OBJECT,
+    COL_OPENFILE_STRUCT,
+    NUM_OPENFILES_COL
+};
+
+
+static const char*
+get_type_name(enum glibtop_file_type t)
+{
+    switch(t)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        return _("file");
+    case GLIBTOP_FILE_TYPE_PIPE:
+        return _("pipe");
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+        return _("IPv6 network connection");
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        return _("IPv4 network connection");
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        return _("local socket");
+    default:
+        return _("unknown type");
+    }
+}
+
+
+
+static char *
+friendlier_hostname(const char *addr_str, int port)
+{
+    struct addrinfo hints = { };
+    struct addrinfo *res = NULL;
+    char hostname[NI_MAXHOST];
+    char service[NI_MAXSERV];
+    char port_str[6];
+
+    if (!addr_str[0]) return g_strdup("");
+
+    snprintf(port_str, sizeof port_str, "%d", port);
+
+    hints.ai_family = AF_UNSPEC;
+    hints.ai_socktype = SOCK_STREAM;
+
+    if (getaddrinfo(addr_str, port_str, &hints, &res))
+        goto failsafe;
+
+    if (getnameinfo(res->ai_addr, res->ai_addrlen, hostname,<--- Null pointer dereference
+            sizeof hostname, service, sizeof service, NI_IDN))
+        goto failsafe;
+
+    if (res) freeaddrinfo(res);<--- Assuming that condition 'res' is not redundant
+        return g_strdup_printf("%s, TCP port %d (%s)", hostname, port, service);
+
+  failsafe:
+    if (res) freeaddrinfo(res);
+    return g_strdup_printf("%s, TCP port %d", addr_str, port);
+}
+
+
+
+static void
+add_new_files (gpointer key, gpointer value, gpointer data)
+{
+    glibtop_open_files_entry *openfiles = static_cast<glibtop_open_files_entry*>(value);
+
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreeIter row;
+
+    char *object;
+
+    switch(openfiles->type)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        object = g_strdup(openfiles->info.file.name);
+        break;
+
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        object = friendlier_hostname(openfiles->info.sock.dest_host,
+                         openfiles->info.sock.dest_port);
+        break;
+
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        object = g_strdup(openfiles->info.localsock.name);
+        break;
+
+    default:
+        object = g_strdup("");
+    }
+
+    gtk_list_store_insert (GTK_LIST_STORE (model), &row, 0);
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        COL_FD, openfiles->fd,
+                        COL_TYPE, get_type_name(static_cast<glibtop_file_type>(openfiles->type)),
+                        COL_OBJECT, object,
+#if GLIB_CHECK_VERSION (2, 68, 0)
+                        COL_OPENFILE_STRUCT, g_memdup2(openfiles, sizeof(*openfiles)),
+#else
+                        COL_OPENFILE_STRUCT, g_memdup(openfiles, sizeof(*openfiles)),
+#endif
+                        -1);
+
+    g_free(object);
+}
+
+static GList *old_maps = NULL;
+
+static gboolean
+classify_openfiles (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+    GHashTable *new_maps = static_cast<GHashTable*>(data);
+    GtkTreeIter *old_iter;
+    glibtop_open_files_entry *openfiles;
+    gchar *old_name;
+
+    gtk_tree_model_get (model, iter, 1, &old_name, -1);
+
+    openfiles = static_cast<glibtop_open_files_entry*>(g_hash_table_lookup (new_maps, old_name));
+    if (openfiles) {
+        g_hash_table_remove (new_maps, old_name);
+        g_free (old_name);
+        return FALSE;
+
+    }
+
+    old_iter = gtk_tree_iter_copy (iter);
+    old_maps = g_list_append (old_maps, old_iter);
+    g_free (old_name);
+    return FALSE;
+
+}
+
+
+static gboolean
+compare_open_files(gconstpointer a, gconstpointer b)
+{
+    const glibtop_open_files_entry *o1 = static_cast<const glibtop_open_files_entry *>(a);
+    const glibtop_open_files_entry *o2 = static_cast<const glibtop_open_files_entry *>(b);
+
+    /* Falta manejar los diferentes tipos! */
+    return (o1->fd == o2->fd) && (o1->type == o2->type); /* XXX! */
+}
+
+
+static void
+update_openfiles_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+    GtkTreeModel *model;
+    glibtop_open_files_entry *openfiles;<--- Shadowed declaration
+    glibtop_proc_open_files procmap;
+    GHashTable *new_maps;
+    guint i;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    if (!info)
+        return;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    openfiles = glibtop_get_proc_open_files (&procmap, info->pid);
+
+    if (!openfiles)
+        return;
+
+    new_maps = static_cast<GHashTable *>(g_hash_table_new_full (g_str_hash, compare_open_files,
+                                                                NULL, NULL));
+    for (i=0; i < procmap.number; i++)
+        g_hash_table_insert (new_maps, openfiles + i, openfiles + i);
+
+    gtk_tree_model_foreach (model, classify_openfiles, new_maps);
+
+    g_hash_table_foreach (new_maps, add_new_files, model);
+
+    while (old_maps) {
+        GtkTreeIter *iter = static_cast<GtkTreeIter*>(old_maps->data);
+        glibtop_open_files_entry *openfiles = NULL;<--- Shadow variable
+
+        gtk_tree_model_get (model, iter,
+                            COL_OPENFILE_STRUCT, &openfiles,
+                            -1);
+
+        gtk_list_store_remove (GTK_LIST_STORE (model), iter);
+        gtk_tree_iter_free (iter);
+        g_free (openfiles);
+
+        old_maps = g_list_next (old_maps);
+
+    }
+
+    g_hash_table_destroy (new_maps);
+    g_free (openfiles);
+}
+
+static void
+close_openfiles_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GSettings *settings;
+    guint timer;
+
+    settings = static_cast<GSettings*>(g_object_get_data (G_OBJECT (tree), "settings"));
+    procman_save_tree_state (settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    return ;
+}
+
+
+static GtkWidget *
+create_openfiles_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    const gchar * const titles[] = {
+        /* Translators: "FD" here means "File Descriptor". Please use
+           a very short translation if possible, and at most
+           2-3 characters for it to be able to fit in the UI. */
+        N_("FD"),
+        N_("Type"),
+        N_("Object")
+    };
+
+    model = gtk_list_store_new (NUM_OPENFILES_COL,
+                                G_TYPE_INT,        /* FD */
+                                G_TYPE_STRING,    /* Type */
+                                G_TYPE_STRING,    /* Object */
+                                G_TYPE_POINTER    /* open_files_entry */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_OPENFILES_COL-1; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        switch (i) {
+        case COL_FD:
+            g_object_set(cell, "xalign", 1.0f, NULL);
+            break;
+        }
+
+        column = gtk_tree_view_column_new_with_attributes (_(titles[i]),
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_sort_column_id (column, i);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    procman_get_tree_state (procdata->settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    return tree;
+}
+
+
+static gboolean
+openfiles_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_openfiles_dialog (tree);
+
+    return TRUE;
+}
+
+
+static void
+create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *openfilesdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    openfilesdialog = gtk_dialog_new_with_buttons (_("Open Files"), NULL,
+                                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                   "gtk-close", GTK_RESPONSE_CLOSE,
+                                                   NULL);
+    gtk_window_set_resizable (GTK_WINDOW (openfilesdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (openfilesdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (openfilesdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (openfilesdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Files opened by process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                    GTK_POLICY_AUTOMATIC,
+                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_openfiles_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+    g_object_set_data (G_OBJECT (tree), "settings", procdata->settings);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (openfilesdialog), "response",
+                      G_CALLBACK (close_openfiles_dialog), tree);
+
+    gtk_widget_show_all (openfilesdialog);
+
+    timer = g_timeout_add_seconds (5, openfiles_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_openfiles_dialog (tree);
+
+}
+
+
+void
+create_openfiles_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_openfiles_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/12.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/12.html new file mode 100644 index 00000000..c1c9bcc6 --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/12.html @@ -0,0 +1,385 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
// -*- c++ -*-
+
+#ifndef _PROCMAN_PRETTYTABLE_H_
+#define _PROCMAN_PRETTYTABLE_H_
+
+#include <glib.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <glibmm/refptr.h>
+#include <gdkmm/pixbuf.h>
+#include <giomm/filemonitor.h>
+
+#include <map>
+#include <string>
+
+#ifdef HAVE_WNCK
+extern "C" {
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h>
+}
+#endif
+
+#include "iconthemewrapper.h"
+
+class ProcInfo;
+
+using std::string;
+
+class PrettyTable
+{
+ public:
+    PrettyTable();
+    ~PrettyTable();
+
+    void set_icon(ProcInfo &);
+
+private:
+
+#ifdef HAVE_WNCK
+    static void on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_opened'
+    static void on_application_closed(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_closed'
+
+    void register_application(pid_t pid, Glib::RefPtr<Gdk::Pixbuf> icon);
+    void unregister_application(pid_t pid);
+#endif
+
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_theme(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_default(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_gio(const ProcInfo &);
+#ifdef HAVE_WNCK
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_wnck(const ProcInfo &);
+#endif
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_name(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_for_kernel(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_dummy(const ProcInfo &);
+
+    bool get_default_icon_name(const string &cmd, string &name);
+    void file_monitor_event (Glib::RefPtr<Gio::File>,
+                             Glib::RefPtr<Gio::File>,
+                             Gio::FileMonitorEvent);
+    void init_gio_app_cache ();
+
+    typedef std::map<string, Glib::RefPtr<Gdk::Pixbuf> > IconCache;
+    typedef std::map<pid_t, Glib::RefPtr<Gdk::Pixbuf> > IconsForPID;
+    typedef std::map<string, Glib::RefPtr<Gio::AppInfo> > AppCache;
+    typedef std::map<string, Glib::RefPtr<Gio::FileMonitor> > DesktopDirMonitors;
+
+    IconsForPID apps;
+    IconCache defaults;
+    DesktopDirMonitors monitors;
+    AppCache gio_apps;
+    procman::IconThemeWrapper theme;
+};
+
+#endif /* _PROCMAN_PRETTYTABLE_H_ */
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/13.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/13.html new file mode 100644 index 00000000..b7c3450b --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/13.html @@ -0,0 +1,1417 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
/* Procman - dialogs
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+
+#include <signal.h>
+#include <string.h>
+
+#include "procdialogs.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "procactions.h"
+#include "util.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "procman_gksu.h"
+#include "procman_pkexec.h"
+#include "cgroups.h"
+
+#define GET_WIDGET(x) GTK_WIDGET(gtk_builder_get_object(builder, x))
+
+static GtkWidget *renice_dialog = NULL;
+static GtkWidget *prefs_dialog = NULL;
+static gint new_nice_value = 0;
+
+
+static void
+kill_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    struct KillArgs *kargs = static_cast<KillArgs*>(data);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    if (id == GTK_RESPONSE_OK)
+        kill_process (kargs->procdata, kargs->signal);
+
+    g_free (kargs);
+}
+
+void
+procdialog_create_kill_dialog (ProcData *procdata, int signal)
+{
+    GtkWidget *kill_alert_dialog;
+    gchar *primary, *secondary, *button_text;
+    struct KillArgs *kargs;
+
+    kargs = g_new(KillArgs, 1);
+    kargs->procdata = procdata;
+    kargs->signal = signal;
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if ( selected_count == 1 ) {
+        ProcInfo *selected_process = NULL;
+        // get the last selected row
+        gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &selected_process);
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing single process*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        } else {
+            /*xgettext: primary alert message for ending single process*/
+            primary = g_strdup_printf (_("Are you sure you want to end the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        }
+    } else {
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the %d selected processes?"),
+                                       selected_count);
+        } else {
+            /*xgettext: primary alert message for ending multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to end the %d selected processes?"),
+                                       selected_count);
+
+        }
+    }
+
+    if ( signal == SIGKILL ) {
+        /*xgettext: secondary alert message*/
+        secondary = _("Killing a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be killed.");
+        button_text = ngettext("_Kill Process", "_Kill Processes", selected_count);
+    } else {
+        /*xgettext: secondary alert message*/
+        secondary = _("Ending a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be ended.");
+        button_text = ngettext("_End Process", "_End Processes", selected_count);
+    }
+
+    kill_alert_dialog = gtk_message_dialog_new (GTK_WINDOW (procdata->app),
+                                                static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
+                                                GTK_MESSAGE_WARNING,
+                                                GTK_BUTTONS_NONE,
+                                                "%s",
+                                                primary);
+    g_free (primary);
+
+    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (kill_alert_dialog),
+                                              "%s",
+                                              secondary);
+
+    gtk_dialog_add_buttons (GTK_DIALOG (kill_alert_dialog),
+                            "gtk-cancel", GTK_RESPONSE_CANCEL,
+                            button_text, GTK_RESPONSE_OK,
+                            NULL);
+
+    gtk_dialog_set_default_response (GTK_DIALOG (kill_alert_dialog),
+                                     GTK_RESPONSE_CANCEL);
+
+    g_signal_connect (G_OBJECT (kill_alert_dialog), "response",
+                      G_CALLBACK (kill_dialog_button_pressed), kargs);
+
+    gtk_widget_show_all (kill_alert_dialog);
+}
+
+static void
+renice_scale_changed (GtkAdjustment *adj, gpointer data)
+{
+    GtkWidget *label = GTK_WIDGET (data);
+
+    new_nice_value = int(gtk_adjustment_get_value (adj));
+    gchar* text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (new_nice_value));
+    gtk_label_set_text (GTK_LABEL (label), text);
+    g_free(text);
+
+}
+
+static void
+renice_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (id == 100) {
+        if (new_nice_value == -100)
+            return;
+        renice(procdata, new_nice_value);
+    }
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+    renice_dialog = NULL;
+}
+
+void
+procdialog_create_renice_dialog (ProcData *procdata)
+{
+    ProcInfo  *info;
+    GtkWidget *dialog = NULL;
+    GtkWidget *dialog_vbox;
+    GtkWidget *vbox;
+    GtkWidget *label;
+    GtkWidget *priority_label;
+    GtkWidget *grid;
+    GtkAdjustment *renice_adj;
+    GtkWidget *hscale;
+    GtkWidget *button;
+    GtkWidget *icon;
+    gchar     *text;
+    gchar     *dialog_title;
+
+    if (renice_dialog)
+        return;
+
+    gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &info);
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if (!info)
+        return;
+
+    if ( selected_count == 1 ) {
+        dialog_title = g_strdup_printf (_("Change Priority of Process “%s†(PID: %u)"),
+                                        info->name, info->pid);
+    } else {
+        dialog_title = g_strdup_printf (_("Change Priority of %d Selected Processes"),
+                                        selected_count);
+    }
+
+    dialog = gtk_dialog_new_with_buttons (dialog_title, NULL,
+                                          GTK_DIALOG_DESTROY_WITH_PARENT,
+                                          "gtk-cancel", GTK_RESPONSE_CANCEL,
+                                          NULL);
+    g_free (dialog_title);
+
+    renice_dialog = dialog;
+    gtk_window_set_resizable (GTK_WINDOW (renice_dialog), FALSE);
+    gtk_container_set_border_width (GTK_CONTAINER (renice_dialog), 5);
+
+    button = gtk_button_new_with_mnemonic (_("Change _Priority"));
+    gtk_widget_set_can_default (button, TRUE);
+
+    icon = gtk_image_new_from_icon_name ("gtk-apply", GTK_ICON_SIZE_BUTTON);
+    gtk_button_set_image (GTK_BUTTON (button), icon);
+
+    gtk_dialog_add_action_widget (GTK_DIALOG (renice_dialog), button, 100);
+    gtk_dialog_set_default_response (GTK_DIALOG (renice_dialog), 100);
+    new_nice_value = -100;
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+    gtk_box_set_spacing (GTK_BOX (dialog_vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), vbox, TRUE, TRUE, 0);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+
+    grid = gtk_grid_new ();
+    gtk_grid_set_column_spacing (GTK_GRID(grid), 12);
+    gtk_grid_set_row_spacing (GTK_GRID(grid), 6);
+    gtk_box_pack_start (GTK_BOX (vbox), grid, TRUE, TRUE, 0);
+
+    label = gtk_label_new_with_mnemonic (_("_Nice value:"));
+    gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 2);
+
+    renice_adj = gtk_adjustment_new (info->nice, RENICE_VAL_MIN, RENICE_VAL_MAX, 1, 1, 0);
+    new_nice_value = 0;
+    hscale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, renice_adj);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), hscale);
+    gtk_scale_set_digits (GTK_SCALE (hscale), 0);
+    gtk_widget_set_hexpand (hscale, TRUE);
+    gtk_grid_attach (GTK_GRID (grid), hscale, 1, 0, 1, 1);
+    text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (info->nice));
+    priority_label = gtk_label_new (text);
+    gtk_grid_attach (GTK_GRID (grid), priority_label, 1, 1, 1, 1);
+    g_free(text);
+
+    text = g_strconcat("<small><i><b>", _("Note:"), "</b> ",
+        _("The priority of a process is given by its nice value. A lower nice value corresponds to a higher priority."),
+        "</i></small>", NULL);
+    label = gtk_label_new (_(text));
+    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+    g_free (text);
+
+    g_signal_connect (G_OBJECT (dialog), "response",
+                      G_CALLBACK (renice_dialog_button_pressed), procdata);
+    g_signal_connect (G_OBJECT (renice_adj), "value_changed",
+                      G_CALLBACK (renice_scale_changed), priority_label);
+
+    gtk_widget_show_all (dialog);
+
+
+}
+
+static void
+prefs_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    if (id == GTK_RESPONSE_HELP)
+    {
+        GError* error = 0;
+        if (!g_app_info_launch_default_for_uri("help:mate-system-monitor/mate-system-monitor-prefs", NULL, &error))
+        {
+            g_warning("Could not display preferences help : %s", error->message);
+            g_error_free(error);
+        }
+    }
+    else
+    {
+        gtk_widget_destroy (GTK_WIDGET (dialog));
+        prefs_dialog = NULL;
+    }
+}
+
+
+class SpinButtonUpdater
+{
+public:
+    SpinButtonUpdater(const string& key)
+        : key(key)
+    { }
+
+    static gboolean callback(GtkWidget *widget, GdkEventFocus *event, gpointer data)
+    {
+        SpinButtonUpdater* updater = static_cast<SpinButtonUpdater*>(data);
+        gtk_spin_button_update(GTK_SPIN_BUTTON(widget));
+        updater->update(GTK_SPIN_BUTTON(widget));
+        return FALSE;
+    }
+
+private:
+
+    void update(GtkSpinButton* spin)
+    {
+        int new_value = int(1000 * gtk_spin_button_get_value(spin));
+        g_settings_set_int(ProcData::get_instance()->settings,
+                           this->key.c_str(), new_value);
+
+        procman_debug("set %s to %d", this->key.c_str(), new_value);
+    }
+
+    const string key;
+};
+
+
+static void
+field_toggled (const gchar *child_schema, GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+    GtkTreeIter iter;
+    GtkTreeViewColumn *column;
+    gboolean toggled;
+    GSettings *settings = g_settings_get_child (ProcData::get_instance()->settings, child_schema);
+    gchar *key;
+    int id;
+
+    if (!path)
+        return;
+
+    gtk_tree_model_get_iter (model, &iter, path);
+
+    gtk_tree_model_get (model, &iter, 2, &column, -1);
+    toggled = gtk_cell_renderer_toggle_get_active (cell);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, !toggled, -1);
+    gtk_tree_view_column_set_visible (column, !toggled);
+
+    id = gtk_tree_view_column_get_sort_column_id (column);
+
+    key = g_strdup_printf ("col-%d-visible", id);
+    g_settings_set_boolean (settings, key, !toggled);
+    g_free (key);
+
+    gtk_tree_path_free (path);
+}
+
+static void
+proc_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("proctree", cell, path_str, data);
+}
+
+static void
+disk_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("disktreenew", cell, path_str, data);
+}
+
+static void
+create_field_page(GtkBuilder* builder, GtkWidget *tree, const gchar *widgetname)
+{
+    GtkTreeView *treeview;
+    GList *it, *columns;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;<--- Shadowed declaration
+    GtkCellRenderer *cell;
+    gchar *full_widgetname;
+
+    full_widgetname = g_strdup_printf ("%s_columns", widgetname);
+    treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, full_widgetname));
+    g_free (full_widgetname);
+
+    model = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER);
+
+    gtk_tree_view_set_model (GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(model));
+    g_object_unref (G_OBJECT (model));
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_toggle_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "active", 0,
+                                         NULL);
+
+    if (g_strcmp0 (widgetname, "proctree") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (proc_field_toggled), model);
+    else if (g_strcmp0 (widgetname, "disktreenew") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (disk_field_toggled), model);
+
+    gtk_tree_view_column_set_clickable (column, TRUE);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "text", 1,
+                                         NULL);
+
+    gtk_tree_view_column_set_title (column, "Not Shown");
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    for(it = columns; it; it = it->next)
+    {
+        GtkTreeViewColumn *column = static_cast<GtkTreeViewColumn*>(it->data);<--- Shadow variable
+        GtkTreeIter iter;
+        const gchar *title;
+        gboolean visible;
+        gint column_id;
+
+        title = gtk_tree_view_column_get_title (column);
+        if (!title)
+            title = _("Icon");
+
+        column_id = gtk_tree_view_column_get_sort_column_id(column);
+        if ((column_id == COL_CGROUP) && (!cgroups_enabled()))
+            continue;
+
+        if ((column_id == COL_UNIT ||
+             column_id == COL_SESSION ||
+             column_id == COL_SEAT ||
+             column_id == COL_OWNER)
+#ifdef HAVE_SYSTEMD
+            && !LOGIND_RUNNING()
+#endif
+                )
+            continue;
+
+        visible = gtk_tree_view_column_get_visible (column);
+
+        gtk_list_store_append (model, &iter);
+        gtk_list_store_set (model, &iter, 0, visible, 1, title, 2, column,-1);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procdialog_create_preferences_dialog (ProcData *procdata)
+{
+    typedef SpinButtonUpdater SBU;
+
+    static SBU interval_updater("update-interval");
+    static SBU graph_interval_updater("graph-update-interval");
+    static SBU disks_interval_updater("disks-interval");
+
+    GtkWidget *notebook;
+    GtkAdjustment *adjustment;
+    GtkWidget *spin_button;
+    GtkWidget *check_button;
+    GtkWidget *smooth_button;
+    GtkBuilder *builder;
+    gfloat update;
+
+    if (prefs_dialog)
+        return;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/preferences.ui");
+
+    prefs_dialog = GET_WIDGET("preferences_dialog");
+    notebook = GET_WIDGET("notebook");
+    spin_button = GET_WIDGET("processes_interval_spinner");
+
+    update = (gfloat) procdata->config.update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0,
+                                   MIN_UPDATE_INTERVAL / 1000,
+                                   MAX_UPDATE_INTERVAL / 1000,
+                                   0.25,
+                                   1.0,
+                                   0);
+
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK (SBU::callback), &interval_updater);
+
+    smooth_button = GET_WIDGET("smooth_button");
+    g_settings_bind(procdata->settings, SmoothRefresh::KEY.c_str(), smooth_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    check_button = GET_WIDGET("check_button");
+    g_settings_bind(procdata->settings, "kill-dialog", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    GtkWidget *solaris_button = GET_WIDGET("solaris_button");
+    g_settings_bind(procdata->settings, procman::settings::solaris_mode.c_str(), solaris_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->tree, "proctree");
+
+    update = (gfloat) procdata->config.graph_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0, 0.25,
+                                                      100.0, 0.25, 1.0, 0);
+
+    spin_button = GET_WIDGET("resources_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &graph_interval_updater);
+
+    GtkWidget *bits_button = GET_WIDGET("bits_button");
+    g_settings_bind(procdata->settings, procman::settings::network_in_bits.c_str(), bits_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+
+    update = (gfloat) procdata->config.disks_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new (update / 1000.0, 1.0,
+                                                       100.0, 1.0, 1.0, 0);
+
+    spin_button = GET_WIDGET("devices_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &disks_interval_updater);
+
+    check_button = GET_WIDGET("all_devices_check");
+    g_settings_bind(procdata->settings, "show-all-fs", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->disk_list, "disktreenew");
+
+    gtk_widget_show_all (prefs_dialog);
+    g_signal_connect (G_OBJECT (prefs_dialog), "response",
+                       G_CALLBACK (prefs_dialog_button_pressed), procdata);
+
+    switch (procdata->config.current_tab) {
+    case PROCMAN_TAB_SYSINFO:
+    case PROCMAN_TAB_PROCESSES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
+        break;
+    case PROCMAN_TAB_RESOURCES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 1);
+        break;
+    case PROCMAN_TAB_DISKS:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 2);
+        break;
+    }
+
+    gtk_builder_connect_signals (builder, NULL);
+    g_object_unref (G_OBJECT (builder));
+}
+
+
+static char *
+procman_action_to_command(ProcmanActionType type,
+                          gint pid,
+                          gint extra_value)
+{
+    switch (type) {
+    case PROCMAN_ACTION_KILL:
+           return g_strdup_printf("kill -s %d %d", extra_value, pid);
+    case PROCMAN_ACTION_RENICE:
+        return g_strdup_printf("renice %d %d", extra_value, pid);
+    default:
+        g_assert_not_reached();
+    }
+}
+
+
+/*
+ * type determines whether if dialog is for killing process or renice.
+ * type == PROCMAN_ACTION_KILL,   extra_value -> signal to send
+ * type == PROCMAN_ACTION_RENICE, extra_value -> new priority.
+ */
+gboolean
+procdialog_create_root_password_dialog(ProcmanActionType type,
+                                       ProcData *procdata,
+                                       gint pid,
+                                       gint extra_value)
+{
+    char * command;
+    gboolean ret = FALSE;
+
+    command = procman_action_to_command(type, pid, extra_value);
+
+    procman_debug("Trying to run '%s' as root", command);
+
+    if (procman_has_pkexec())
+        ret = procman_pkexec_create_root_password_dialog(command);
+    else if (procman_has_gksu())
+        ret = procman_gksu_create_root_password_dialog(command);
+
+    g_free(command);
+    return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/14.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/14.html new file mode 100644 index 00000000..3c8a776c --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/14.html @@ -0,0 +1,1109 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
#include <glib/gi18n.h>
+#include <glibtop.h>
+#include <glibtop/close.h>
+#include <glibtop/cpu.h>
+#include <glibtop/sysinfo.h>
+
+#include "procman-app.h"
+#include "procman.h"
+#include "interface.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "argv.h"
+#include "util.h"
+
+static void
+mount_changed(const Glib::RefPtr<Gio::Mount>&)
+{
+    cb_update_disks(ProcData::get_instance());
+}
+
+
+static void
+init_volume_monitor(ProcData *procdata)
+{
+    using namespace Gio;
+    using namespace Glib;
+
+    RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+    monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
+}
+
+static gboolean
+has_key (gchar **keys, const gchar *key)
+{
+    gchar **loop = keys;
+
+    while (*loop) {
+        if (!strcmp (*loop++, key))
+            return TRUE;
+    }
+
+    return FALSE;
+}
+
+static void
+tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_tree = g_settings_get_boolean(settings, key);
+
+    g_object_set(G_OBJECT(procdata->tree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
+    proctable_update (procdata);
+}
+
+
+static void
+network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
+    // force scale to be redrawn
+    procdata->net_graph->clear_background();
+}
+
+static void
+view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.whose_process = g_settings_get_int (settings, key);
+    procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2);
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "kill-dialog")) {
+        procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
+    }
+}
+
+static void
+timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "update-interval")) {
+        procdata->config.update_interval = g_settings_get_int (settings, key);
+        procdata->config.update_interval =
+            MAX (procdata->config.update_interval, 1000);
+
+        procdata->smooth_refresh->reset();
+
+        if(procdata->timeout) {
+            g_source_remove (procdata->timeout);
+            procdata->timeout = g_timeout_add (procdata->config.update_interval,
+                                               cb_timeout,
+                                               procdata);
+        }
+    }
+    else if (g_str_equal (key, "graph-update-interval")){
+        procdata->config.graph_update_interval = g_settings_get_int (settings, key);
+        procdata->config.graph_update_interval =
+            MAX (procdata->config.graph_update_interval,
+                 250);
+        load_graph_change_speed(procdata->cpu_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->mem_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->net_graph,
+                                procdata->config.graph_update_interval);
+    }
+    else if (g_str_equal(key, "disks-interval")) {
+        procdata->config.disks_update_interval = g_settings_get_int (settings, key);
+        procdata->config.disks_update_interval =
+            MAX (procdata->config.disks_update_interval, 1000);
+
+        if(procdata->disk_timeout) {
+            g_source_remove (procdata->disk_timeout);
+            procdata->disk_timeout = \
+                g_timeout_add (procdata->config.disks_update_interval,
+                               cb_update_disks,
+                               procdata);
+        }
+    }
+    else {
+        g_assert_not_reached();
+    }
+}
+
+static void
+color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    gchar *color = g_settings_get_string (settings, key);
+
+    if (g_str_has_prefix (key, "cpu-color")) {
+        for (int i = 0; i < procdata->config.num_cpus; i++) {
+            string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
+            if (cpu_key == key) {
+                gdk_rgba_parse (&procdata->config.cpu_color[i], color);
+                procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
+                break;
+            }
+        }
+    }
+    else if (g_str_equal (key, "mem-color")) {
+        gdk_rgba_parse (&procdata->config.mem_color, color);
+        procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
+    }
+    else if (g_str_equal (key, "swap-color")) {
+        gdk_rgba_parse (&procdata->config.swap_color, color);
+        procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
+    }
+    else if (g_str_equal (key, "net-in-color")) {
+        gdk_rgba_parse (&procdata->config.net_in_color, color);
+        procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
+    }
+    else if (g_str_equal (key, "net-out-color")) {
+        gdk_rgba_parse (&procdata->config.net_out_color, color);
+        procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
+    }
+    else {
+        g_assert_not_reached();
+    }
+    g_free(color);
+}
+
+static void
+show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
+
+    cb_update_disks (data);
+}
+
+static ProcData *
+procman_data_new (GSettings *settings)
+{
+    GSettingsSchema *schema;
+    ProcData *pd;
+    gchar *color;
+    gchar **keys;
+    glibtop_cpu cpu;
+
+    pd = ProcData::get_instance();
+
+    g_settings_get (settings, "window-state", "(iiii)",
+                    &pd->config.width, &pd->config.height,
+                    &pd->config.xpos, &pd->config.ypos);
+
+    pd->config.maximized = g_settings_get_boolean(settings, "maximized");
+
+    pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
+    g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd);
+
+    pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
+    std::string detail_string("changed::" + procman::settings::solaris_mode);
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd);
+
+    pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
+    detail_string = "changed::" + procman::settings::network_in_bits;
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd);
+
+    pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
+    g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd);
+    pd->config.update_interval = g_settings_get_int (settings, "update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.graph_update_interval = g_settings_get_int (settings,
+                                                           "graph-update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",
+                      G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd);
+
+
+    /* show_all_fs */
+    pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
+    g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd);
+
+
+    pd->config.whose_process = g_settings_get_int (settings, "view-as");
+    g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd);
+    pd->config.current_tab = g_settings_get_int (settings, "current-tab");
+
+    glibtop_get_cpu (&cpu);
+    pd->frequency = cpu.frequency;
+    pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
+
+    g_object_get (settings, "settings-schema", &schema, NULL);
+    keys = g_settings_schema_list_keys (schema);
+    g_settings_schema_unref (schema);
+
+    for (int i = 0; i < pd->config.num_cpus; i++) {
+        gchar *key;
+        key = g_strdup_printf ("cpu-color%d", i);
+
+        if (has_key (keys, key))
+            color = g_settings_get_string (settings, key);
+        else
+            color = g_strdup ("#f25915e815e8");
+        detail_string = std::string("changed::") + std::string(key);
+        g_signal_connect (G_OBJECT(settings), detail_string.c_str(),
+                          G_CALLBACK(color_changed_cb), pd);
+        gdk_rgba_parse (&pd->config.cpu_color[i], color);
+        g_free (color);
+        g_free (key);
+    }
+    g_strfreev (keys);
+
+    color = g_settings_get_string (settings, "mem-color");
+    if (!color)
+        color = g_strdup ("#000000ff0082");
+    g_signal_connect (G_OBJECT(settings), "changed::mem-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.mem_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "swap-color");
+    if (!color)
+        color = g_strdup ("#00b6000000ff");
+    g_signal_connect (G_OBJECT(settings), "changed::swap-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.swap_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-in-color");
+    if (!color)
+        color = g_strdup ("#000000f200f2");
+    g_signal_connect (G_OBJECT(settings), "changed::net-in-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_in_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-out-color");
+    if (!color)
+        color = g_strdup ("#00f2000000c1");
+    g_signal_connect (G_OBJECT(settings), "changed::net-out-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_out_color, color);
+    g_free (color);
+
+    /* Sanity checks */
+    GdkDisplay *display;
+    GdkMonitor *monitor;
+    GdkRectangle monitor_geometry;
+
+    display = gdk_display_get_default ();
+    monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
+    if (monitor == NULL) {
+        monitor = gdk_display_get_monitor (display, 0);
+    }
+    gdk_monitor_get_geometry (monitor, &monitor_geometry);
+
+    pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width);
+    pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height);
+    pd->config.update_interval = MAX (pd->config.update_interval, 1000);
+    pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250);
+    pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000);
+    pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2);
+    pd->config.current_tab = CLAMP(pd->config.current_tab,
+                                   PROCMAN_TAB_SYSINFO,
+                                   PROCMAN_TAB_DISKS);
+
+    // delayed initialization as SmoothRefresh() needs ProcData
+    // i.e. we can't call ProcData::get_instance
+    pd->smooth_refresh = new SmoothRefresh(settings);
+
+    pd->terminating = FALSE;
+
+    return pd;
+}
+
+static void
+procman_free_data (ProcData *procdata)
+{
+
+    proctable_free_table (procdata);
+    delete procdata->smooth_refresh;
+}
+
+ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)<--- Member variable 'ProcmanApp::procdata' is not initialized in the constructor.
+{
+    Glib::set_application_name(_("System Monitor"));
+}
+
+Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
+{
+    return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
+}
+
+void ProcmanApp::on_activate()
+{
+    gtk_window_present (GTK_WINDOW (procdata->app));
+}
+
+static void
+set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
+{
+    gtk_notebook_set_current_page(notebook, tab);
+    cb_change_current_page(notebook, tab, procdata);
+}
+
+int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
+{
+    int argc = 0;
+    char** argv = command_line->get_arguments(argc);
+
+    Glib::OptionContext context;
+    context.set_summary(_("A simple process and system monitor."));
+    context.set_ignore_unknown_options(true);
+    procman::OptionGroup option_group;
+    context.set_main_group(option_group);
+
+    try {
+        context.parse(argc, argv);
+    } catch (const Glib::Error& ex) {
+        g_error("Arguments parse error : %s", ex.what().c_str());
+    }
+
+    if (option_group.show_system_tab) {
+        procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_SYSINFO, procdata);
+    } else if (option_group.show_processes_tab) {
+        procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_PROCESSES, procdata);
+    } else if (option_group.show_resources_tab) {
+        procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_RESOURCES, procdata);
+    } else if (option_group.show_file_systems_tab) {
+        procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_DISKS, procdata);
+    }
+
+    on_activate ();
+
+    return 0;
+}
+
+void ProcmanApp::on_startup()
+{
+    Gtk::Application::on_startup();
+
+    GSettings *settings;
+
+    Gtk::Window::set_default_icon_name ("utilities-system-monitor");
+
+    settings = g_settings_new (GSM_GSETTINGS_SCHEMA);
+
+    glibtop_init ();
+
+    procdata = procman_data_new (settings);
+    procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA);
+
+    create_main_window (procdata);
+    init_volume_monitor (procdata);
+
+    Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app));
+    window->show();
+    window->set_name ("mate-system-monitor");
+
+    add_window (*window);
+}
+
+void ProcmanApp::on_shutdown()
+{
+    procman_free_data(procdata);
+    glibtop_close();
+}
+
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/15.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/15.html new file mode 100644 index 00000000..caf6d784 --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/15.html @@ -0,0 +1,671 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+
+#include <locale.h>
+
+#include <gtkmm.h>
+#include <glib/gi18n.h>
+
+#include "procman-app.h"
+#include "procman.h"
+#include "proctable.h"
+
+ProcData::ProcData()<--- Member variable 'ProcData::uimanager' is not initialized in the constructor.<--- Member variable 'ProcData::action_group' is not initialized in the constructor.<--- Member variable 'ProcData::statusbar' is not initialized in the constructor.<--- Member variable 'ProcData::loadavg' is not initialized in the constructor.<--- Member variable 'ProcData::endprocessbutton' is not initialized in the constructor.<--- Member variable 'ProcData::popup_menu' is not initialized in the constructor.<--- Member variable 'ProcData::disk_list' is not initialized in the constructor.<--- Member variable 'ProcData::notebook' is not initialized in the constructor.<--- Member variable 'ProcData::config' is not initialized in the constructor.<--- Member variable 'ProcData::selection' is not initialized in the constructor.<--- Member variable 'ProcData::settings' is not initialized in the constructor.<--- Member variable 'ProcData::app' is not initialized in the constructor.<--- Member variable 'ProcData::menu' is not initialized in the constructor.<--- Member variable 'ProcData::frequency' is not initialized in the constructor.<--- Member variable 'ProcData::smooth_refresh' is not initialized in the constructor.
+    : tree(NULL),
+      cpu_graph(NULL),
+      mem_graph(NULL),
+      net_graph(NULL),
+      selected_process(NULL),
+      timeout(0),
+      disk_timeout(0),
+      cpu_total_time(1),
+      cpu_total_time_last(1)
+{ }
+
+ProcData* ProcData::get_instance()
+{
+    static ProcData instance;
+    return &instance;
+}
+
+gboolean
+procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns, *it;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    sort_col = g_settings_get_int (pt_settings, "sort-col");
+
+    order = static_cast<GtkSortType>(g_settings_get_int (pt_settings, "sort-order"));
+
+    if (sort_col != -1)
+        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
+                                              sort_col,
+                                              order);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        for (it = columns; it; it = it->next)
+        {
+            GtkTreeViewColumn *column;
+            gint width;
+            gboolean visible;
+            int id;
+            gchar *key;
+
+            column = static_cast<GtkTreeViewColumn*>(it->data);
+            id = gtk_tree_view_column_get_sort_column_id (column);
+
+            key = g_strdup_printf ("col-%d-width", id);
+            g_settings_get (pt_settings, key, "i", &width);
+            g_free (key);
+
+            key = g_strdup_printf ("col-%d-visible", id);
+            visible = g_settings_get_boolean (pt_settings, key);
+            g_free (key);
+
+            gtk_tree_view_column_set_visible (column, visible);
+            if (visible) {
+                /* ensure column is really visible */
+                width = MAX(width, 20);
+                gtk_tree_view_column_set_fixed_width(column, width);
+            }
+        }
+
+        GVariant     *value;
+        GVariantIter iter;
+        int          sortIndex;
+
+        GSList *order = NULL;<--- Shadow variable
+
+        value = g_settings_get_value(pt_settings, "columns-order");
+        g_variant_iter_init(&iter, value);
+
+        while (g_variant_iter_loop (&iter, "i", &sortIndex))
+            order = g_slist_append(order, GINT_TO_POINTER(sortIndex));
+
+        proctable_set_columns_order(GTK_TREE_VIEW(tree), order);
+
+        g_variant_unref(value);
+        g_slist_free(order);
+    }
+
+    g_object_unref(pt_settings);
+    pt_settings = NULL;
+
+    g_list_free(columns);
+
+    return TRUE;
+}
+
+void
+procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    if (ProcData::get_instance()->terminating)
+        return;
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    if (gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (model), &sort_col,
+                                              &order)) {
+        g_settings_set_int (pt_settings, "sort-col", sort_col);
+        g_settings_set_int (pt_settings, "sort-order", order);
+    }
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        GSList *order;<--- Shadow variable
+        GSList *order_node;
+        GVariantBuilder *builder;
+        GVariant *order_variant;
+
+        order = proctable_get_columns_order(GTK_TREE_VIEW(tree));
+
+        builder = g_variant_builder_new (G_VARIANT_TYPE ("ai"));
+
+        for (order_node = order; order_node; order_node = order_node->next)
+            g_variant_builder_add(builder, "i", GPOINTER_TO_INT(order_node->data));
+
+        order_variant = g_variant_new("ai", builder);
+        g_settings_set_value(pt_settings, "columns-order", order_variant);
+
+        g_slist_free(order);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procman_save_config (ProcData *data)
+{
+    GSettings *settings = data->settings;
+
+    g_assert(data);
+
+    data->config.maximized = gdk_window_get_state(gtk_widget_get_window (data->app)) & GDK_WINDOW_STATE_MAXIMIZED;
+    if (!data->config.maximized) {
+        // we only want to store/overwrite size and position info with non-maximized state info
+        data->config.width  = gdk_window_get_width (gtk_widget_get_window (data->app));
+        data->config.height = gdk_window_get_height(gtk_widget_get_window (data->app));
+
+        gtk_window_get_position(GTK_WINDOW(data->app), &data->config.xpos, &data->config.ypos);
+
+        g_settings_set (settings, "window-state", "(iiii)",
+                        data->config.width, data->config.height,
+                        data->config.xpos, data->config.ypos);
+    }
+    g_settings_set_boolean (settings, "maximized", data->config.maximized);
+
+    g_settings_set_int (settings, "current-tab", data->config.current_tab);
+}
+
+int
+main (int argc, char *argv[])
+{
+    bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+    textdomain (GETTEXT_PACKAGE);
+    setlocale (LC_ALL, "");
+
+    Glib::RefPtr<ProcmanApp> application = ProcmanApp::create();
+    return application->run (argc, argv);
+}
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/16.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/16.html new file mode 100644 index 00000000..91267585 --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/16.html @@ -0,0 +1,913 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
/* Process properties dialog
+ * Copyright (C) 2010 Krishnan Parthasarathi <krishnan.parthasarathi@gmail.com>
+ *                    Robert Ancell <robert.ancell@canonical.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <glibtop/procmem.h>
+#include <glibtop/procmap.h>
+#include <glibtop/procstate.h>
+
+#include "procman.h"
+#include "procproperties.h"
+#include "proctable.h"
+#include "util.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
+enum
+{
+    COL_PROP = 0,
+    COL_VAL,
+    NUM_COLS,
+};
+
+typedef struct _proc_arg {
+    const gchar *prop;
+    gchar *val;
+} proc_arg;
+
+static void
+get_process_memory_writable (ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info (ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+static gchar*
+format_memsize(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
+}
+
+static gchar*
+format_size(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size(size);
+}
+
+static void
+fill_proc_properties (GtkWidget *tree, ProcInfo *info)
+{
+    guint i;
+    GtkListStore *store;
+
+    if (!info)
+        return;
+
+    get_process_memory_info(info);
+
+    proc_arg proc_props[] = {
+        { N_("Process Name"), g_strdup_printf("%s", info->name)},
+        { N_("User"), g_strdup_printf("%s (%d)", info->user.c_str(), info->uid)},
+        { N_("Status"), g_strdup(format_process_state(info->status))},
+        { N_("Memory"), format_memsize(info->mem)},
+        { N_("Virtual Memory"), format_memsize(info->vmsize)},
+        { N_("Resident Memory"), format_memsize(info->memres)},
+        { N_("Writable Memory"), format_memsize(info->memwritable)},
+        { N_("Shared Memory"), format_memsize(info->memshared)},
+#ifdef HAVE_WNCK
+        { N_("X Server Memory"), format_memsize(info->memxserver)},
+#endif
+        { N_("Disk Read Total"), format_size(info->disk_read_bytes_total)},
+        { N_("Disk Write Total"), format_size(info->disk_write_bytes_total)},
+        { N_("CPU"), g_strdup_printf("%d%%", info->pcpu)},
+        { N_("CPU Time"), procman::format_duration_for_display(100 * info->cpu_time / ProcData::get_instance()->frequency) },
+        { N_("Started"), procman_format_date_for_display(info->start_time) },
+        { N_("Nice"), g_strdup_printf("%d", info->nice)},
+        { N_("Priority"), g_strdup_printf("%s", procman::get_nice_level(info->nice)) },
+        { N_("ID"), g_strdup_printf("%d", info->pid)},
+        { N_("Security Context"), info->security_context ? g_strdup_printf("%s", info->security_context) : g_strdup(_("N/A"))},
+        { N_("Command Line"), g_strdup_printf("%s", info->arguments)},
+        { N_("Waiting Channel"), g_strdup_printf("%s", info->wchan)},
+        { N_("Control Group"), info->cgroup_name ? g_strdup_printf("%s", info->cgroup_name) : g_strdup(_("N/A"))},
+        { NULL, NULL}
+    };
+
+    store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
+    for (i = 0; proc_props[i].prop; i++) {
+        GtkTreeIter iter;
+
+        if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL(store), &iter, NULL, i)) {
+            gtk_list_store_append(store, &iter);
+            gtk_list_store_set(store, &iter, COL_PROP, _(proc_props[i].prop), -1);
+        }
+
+        gtk_list_store_set(store, &iter, COL_VAL, g_strstrip(proc_props[i].val), -1);
+        g_free(proc_props[i].val);
+    }
+}
+
+static void
+update_procproperties_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    fill_proc_properties(tree, info);
+}
+
+static void
+close_procprop_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    guint timer;
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static GtkWidget *
+create_procproperties_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    model = gtk_list_store_new (NUM_COLS,
+                                G_TYPE_STRING,	/* Property */
+                                G_TYPE_STRING	/* Value */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_COLS; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        column = gtk_tree_view_column_new_with_attributes (NULL,
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tree), FALSE);
+    fill_proc_properties(tree, procdata->selected_process);
+
+    return tree;
+}
+
+static gboolean
+procprop_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_procproperties_dialog (tree);
+
+    return TRUE;
+}
+
+static void
+create_single_procproperties_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                     GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *procpropdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    procpropdialog = gtk_dialog_new_with_buttons (_("Process Properties"), NULL,
+                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                  "gtk-close", GTK_RESPONSE_CLOSE,
+                                                  NULL);
+    gtk_window_set_resizable (GTK_WINDOW (procpropdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (procpropdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (procpropdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (procpropdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("Properties of process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_procproperties_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (procpropdialog), "response",
+                      G_CALLBACK (close_procprop_dialog), tree);
+
+    gtk_widget_show_all (procpropdialog);
+
+    timer = g_timeout_add_seconds (5, procprop_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_procproperties_dialog (tree);
+}
+
+void
+create_procproperties_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_procproperties_dialog,
+                                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/17.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/17.html new file mode 100644 index 00000000..3ce08395 --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/17.html @@ -0,0 +1,2635 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
/* Procman tree view and process updating
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <cairo-gobject.h>
+#include <string.h>
+#include <math.h>
+#include <glib/gi18n.h>
+#include <glib/gprintf.h>
+#include <glibtop.h>
+#include <glibtop/loadavg.h>
+#include <glibtop/proclist.h>
+#include <glibtop/procio.h>
+#include <glibtop/procstate.h>
+#include <glibtop/procmem.h>
+#include <glibtop/procmap.h>
+#include <glibtop/proctime.h>
+#include <glibtop/procuid.h>
+#include <glibtop/procargs.h>
+#include <glibtop/prockernel.h>
+#include <glibtop/mem.h>
+#include <glibtop/swap.h>
+#include <sys/stat.h>
+#include <pwd.h>
+#include <time.h>
+
+#include <set>
+#include <list>
+
+#ifdef HAVE_SYSTEMD
+#include <systemd/sd-login.h>
+#endif
+
+#include "procman.h"
+#include "selection.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "util.h"
+#include "interface.h"
+#include "selinux.h"
+#include "cgroups.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
+ProcInfo::UserMap ProcInfo::users;
+ProcInfo::List ProcInfo::all;
+std::map<pid_t, guint64> ProcInfo::cpu_times;
+
+
+ProcInfo* ProcInfo::find(pid_t pid)
+{
+    Iterator it(ProcInfo::all.find(pid));
+    return (it == ProcInfo::all.end() ? NULL : it->second);
+}
+
+void
+get_last_selected (GtkTreeModel *model, GtkTreePath *path,
+           GtkTreeIter *iter, gpointer data)
+{
+    ProcInfo **info = static_cast<ProcInfo**>(data);
+
+    gtk_tree_model_get (model, iter, COL_POINTER, info, -1);
+}
+
+static void
+cb_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "proctree");
+}
+
+static void
+cb_sort_changed (GtkTreeSortable *model, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state (procdata->settings,
+                             GTK_WIDGET (procdata->tree),
+                             "proctree");
+}
+
+
+static GtkTreeViewColumn*
+my_gtk_tree_view_get_column_with_sort_column_id(GtkTreeView *treeview, int id)
+{
+    GList *columns, *it;
+    GtkTreeViewColumn *col = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(it = columns; it; it = it->next)
+    {
+        if(gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(it->data)) == id)
+        {
+            col = static_cast<GtkTreeViewColumn*>(it->data);
+            break;
+        }
+    }
+
+    g_list_free(columns);
+
+    return col;
+}
+
+
+void
+proctable_set_columns_order(GtkTreeView *treeview, GSList *order)
+{
+    GtkTreeViewColumn* last = NULL;
+    GSList *it;
+
+    for(it = order; it; it = it->next)
+    {
+        int id;
+        GtkTreeViewColumn *cur;
+
+        id = GPOINTER_TO_INT(it->data);
+
+        cur = my_gtk_tree_view_get_column_with_sort_column_id(treeview, id);
+
+        if(cur && cur != last)
+        {
+            gtk_tree_view_move_column_after(treeview, cur, last);
+            last = cur;
+        }
+    }
+}
+
+
+GSList*
+proctable_get_columns_order(GtkTreeView *treeview)
+{
+    GList *columns, *col;
+    GSList *order = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(col = columns; col; col = col->next)
+    {
+        int id;
+
+        id = gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(col->data));
+        order = g_slist_prepend(order, GINT_TO_POINTER(id));
+    }
+
+    g_list_free(columns);
+
+    order = g_slist_reverse(order);
+
+    return order;
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "proctree");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_proctable_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+static gboolean
+search_equal_func(GtkTreeModel *model,
+                  gint column,
+                  const gchar *key,
+                  GtkTreeIter *iter,
+                  gpointer search_data)
+{
+    char* name;
+    char* user;
+    gboolean found;
+
+    gtk_tree_model_get(model, iter,
+                       COL_NAME, &name,
+                       COL_USER, &user,
+                       -1);
+
+    found = !((name && strcasestr(name, key))
+              || (user && strcasestr(user, key)));
+
+    g_free(name);
+    g_free(user);
+
+    return found;
+}
+
+
+
+GtkWidget *
+proctable_new (ProcData * const procdata)
+{
+    GtkWidget *proctree;
+    GtkTreeStore *model;
+    GtkTreeSelection *selection;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell_renderer;
+
+    const gchar *titles[] = {
+        N_("Process Name"),
+        N_("User"),
+        N_("Status"),
+        N_("Virtual Memory"),
+        N_("Resident Memory"),
+        N_("Writable Memory"),
+        N_("Shared Memory"),
+        N_("X Server Memory"),
+        /* xgettext:no-c-format */ N_("% CPU"),
+        N_("CPU Time"),
+        N_("Started"),
+        N_("Nice"),
+        N_("ID"),
+        N_("Security Context"),
+        N_("Command Line"),
+        N_("Memory"),
+        /* xgettext: combined noun, the function the process is waiting in, see wchan ps(1) */
+        N_("Waiting Channel"),
+        N_("Control Group"),
+        N_("Unit"),
+        N_("Session"),
+        /* TRANSLATORS: Seat = i.e. the physical seat the session of the process belongs to, only
+	for multi-seat environments. See http://en.wikipedia.org/wiki/Multiseat_configuration */
+        N_("Seat"),
+        N_("Owner"),
+        N_("Disk Read Total"),
+        N_("Disk Write Total"),
+        N_("Disk Read"),
+        N_("Disk Write"),
+        N_("Priority"),
+        NULL,
+        "POINTER"
+    };
+
+    gint i;
+
+    model = gtk_tree_store_new (NUM_COLUMNS,
+                                G_TYPE_STRING,              /* Process Name */
+                                G_TYPE_STRING,              /* User         */
+                                G_TYPE_UINT,                /* Status       */
+                                G_TYPE_ULONG,               /* VM Size      */
+                                G_TYPE_ULONG,               /* Resident Memory */
+                                G_TYPE_ULONG,               /* Writable Memory */
+                                G_TYPE_ULONG,               /* Shared Memory */
+                                G_TYPE_ULONG,               /* X Server Memory */
+                                G_TYPE_UINT,                /* % CPU        */
+                                G_TYPE_UINT64,              /* CPU time     */
+                                G_TYPE_ULONG,               /* Started      */
+                                G_TYPE_INT,                 /* Nice         */
+                                G_TYPE_UINT,                /* ID           */
+                                G_TYPE_STRING,              /* Security Context */
+                                G_TYPE_STRING,              /* Arguments    */
+                                G_TYPE_ULONG,               /* Memory       */
+                                G_TYPE_STRING,              /* wchan        */
+                                G_TYPE_STRING,              /* Cgroup       */
+                                G_TYPE_STRING,              /* Unit         */
+                                G_TYPE_STRING,              /* Session      */
+                                G_TYPE_STRING,              /* Seat         */
+                                G_TYPE_STRING,              /* Owner        */
+                                G_TYPE_UINT64,              /* Disk read total */
+                                G_TYPE_UINT64,              /* Disk write total*/
+                                G_TYPE_UINT64,              /* Disk read    */
+                                G_TYPE_UINT64,              /* Disk write   */
+                                G_TYPE_STRING,              /* Priority     */
+                                CAIRO_GOBJECT_TYPE_SURFACE, /* Icon         */
+                                G_TYPE_POINTER,             /* ProcInfo     */
+                                G_TYPE_STRING               /* Sexy tooltip */
+        );
+
+    proctree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (proctree), COL_TOOLTIP);
+    g_object_set(G_OBJECT(proctree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+    gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (proctree),
+                                         search_equal_func,
+                                         NULL,
+                                         NULL);
+    g_object_unref (G_OBJECT (model));
+
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree));
+    gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+
+    column = gtk_tree_view_column_new ();
+
+    cell_renderer = gtk_cell_renderer_pixbuf_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "surface", COL_SURFACE,
+                                         NULL);
+
+    cell_renderer = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "text", COL_NAME,
+                                         NULL);
+    gtk_tree_view_column_set_title (column, _(titles[0]));
+    gtk_tree_view_column_set_sort_column_id (column, COL_NAME);
+    gtk_tree_view_column_set_resizable (column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+    gtk_tree_view_column_set_min_width (column, 20);
+    gtk_tree_view_column_set_reorderable (column, TRUE);
+    g_signal_connect(G_OBJECT(column), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (proctree), column);
+    gtk_tree_view_set_expander_column (GTK_TREE_VIEW (proctree), column);
+
+
+    for (i = COL_USER; i <= COL_PRIORITY; i++) {
+
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+#ifndef HAVE_WNCK
+        if (i == COL_MEMXSERVER) {
+          continue;
+        }
+#endif
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(proctree), col);
+
+        // type
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_CPU_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::duration_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_START_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::time_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_STATUS:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::status_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::io_rate_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_PRIORITY:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::priority_cell_data_func,
+                                                        GUINT_TO_POINTER(COL_NICE),
+                                                        NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+        }
+
+        // sorting
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+            case COL_CPU:
+            case COL_CPU_TIME:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_START_TIME:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::number_compare_func, GUINT_TO_POINTER(i),
+                                                NULL);
+                break;
+            case COL_PRIORITY:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::priority_compare_func,
+                                                GUINT_TO_POINTER(COL_NICE), NULL);
+                break;
+            default:
+                break;
+        }
+
+        // xalign
+        switch(i)
+        {
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMWRITABLE:
+            case COL_MEMSHARED:
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_CPU:
+            case COL_NICE:
+            case COL_PID:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_CPU_TIME:
+            case COL_MEM:
+                g_object_set(G_OBJECT(cell), "xalign", 1.0f, NULL);
+                break;
+        }
+
+        // sizing
+        switch (i) {
+            case COL_ARGS:
+                gtk_tree_view_column_set_min_width(col, 150);
+                break;
+            default:
+                gtk_tree_view_column_set_min_width(col, 20);
+                break;
+        }
+    }
+
+    procdata->tree = proctree;
+
+    procman_get_tree_state (procdata->settings, proctree, "proctree");
+
+    /* Override column settings by hiding this column if it's meaningless: */
+    if (!can_show_security_context_column ()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id (GTK_TREE_VIEW (proctree), COL_SECURITYCONTEXT);
+        gtk_tree_view_column_set_visible (column, FALSE);
+    }
+
+    if (!cgroups_enabled()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), COL_CGROUP);
+        gtk_tree_view_column_set_visible(column, FALSE);
+    }
+
+#ifdef HAVE_SYSTEMD
+    if (!LOGIND_RUNNING())
+#endif
+    {
+        for (i = COL_UNIT; i <= COL_OWNER; i++) {
+            column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), i);
+            gtk_tree_view_column_set_visible(column, FALSE);
+        }
+    }
+
+    g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree))),
+                      "changed",
+                      G_CALLBACK (cb_row_selected), procdata);
+    g_signal_connect (G_OBJECT (proctree), "popup_menu",
+                      G_CALLBACK (cb_tree_popup_menu), procdata);
+    g_signal_connect (G_OBJECT (proctree), "button_press_event",
+                      G_CALLBACK (cb_tree_button_pressed), procdata);
+
+    g_signal_connect (G_OBJECT(proctree), "columns-changed",
+                      G_CALLBACK(cb_columns_changed), procdata);
+
+    g_signal_connect (G_OBJECT (model), "sort-column-changed",
+                      G_CALLBACK (cb_sort_changed), procdata);
+
+    return proctree;
+}
+
+
+ProcInfo::~ProcInfo()
+{
+    g_free(this->name);
+    g_free(this->tooltip);
+    g_free(this->arguments);
+    g_free(this->security_context);
+    g_free(this->cgroup_name);
+    g_free(this->unit);
+    g_free(this->session);
+    g_free(this->seat);
+    cairo_surface_destroy(this->surface);
+}
+
+
+static void
+get_process_name (ProcInfo *info,
+                  const gchar *cmd, const GStrv args)
+{
+    if (args) {
+        // look for /usr/bin/very_long_name
+        // and also /usr/bin/interpreter /usr/.../very_long_name
+        // which may have use prctl to alter 'cmd' name
+        for (int i = 0; i != 2 && args[i]; ++i) {
+            char* basename;
+            basename = g_path_get_basename(args[i]);
+
+            if (g_str_has_prefix(basename, cmd)) {
+                info->name = basename;
+                return;
+            }
+
+            g_free(basename);
+        }
+    }
+
+    info->name = g_strdup (cmd);
+}
+
+std::string
+ProcInfo::lookup_user(guint uid)
+{
+    typedef std::pair<ProcInfo::UserMap::iterator, bool> Pair;
+    ProcInfo::UserMap::value_type hint(uid, "");
+    Pair p(ProcInfo::users.insert(hint));
+
+    // procman_debug("User lookup for uid %u: %s", uid, (p.second ? "MISS" : "HIT"));
+
+    if (p.second) {
+        struct passwd* pwd;
+        pwd = getpwuid(uid);
+
+        if (pwd && pwd->pw_name)
+            p.first->second = pwd->pw_name;
+        else {
+            char username[16];
+            g_sprintf(username, "%u", uid);
+            p.first->second = username;
+        }
+    }
+
+    return p.first->second;
+}
+
+void
+ProcInfo::set_user(guint uid)
+{
+    if (G_LIKELY(this->uid == uid))
+        return;
+
+    this->uid = uid;
+    this->user = lookup_user(uid);
+}
+
+static void get_process_memory_writable(ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info(ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+
+static void
+update_info_mutable_cols(ProcInfo *info)
+{
+    ProcData * const procdata = ProcData::get_instance();
+    GtkTreeModel *model;
+    model = gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->tree));
+
+    using procman::tree_store_update;
+
+    tree_store_update(model, &info->node, COL_STATUS, info->status);
+    tree_store_update(model, &info->node, COL_USER, info->user.c_str());
+    tree_store_update(model, &info->node, COL_VMSIZE, info->vmsize);
+    tree_store_update(model, &info->node, COL_MEMRES, info->memres);
+    tree_store_update(model, &info->node, COL_MEMWRITABLE, info->memwritable);
+    tree_store_update(model, &info->node, COL_MEMSHARED, info->memshared);
+#ifdef HAVE_WNCK
+    tree_store_update(model, &info->node, COL_MEMXSERVER, info->memxserver);
+#endif
+    tree_store_update(model, &info->node, COL_CPU, info->pcpu);
+    tree_store_update(model, &info->node, COL_CPU_TIME, info->cpu_time);
+    tree_store_update(model, &info->node, COL_DISK_READ_TOTAL, info->disk_read_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_TOTAL, info->disk_write_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_READ_CURRENT, info->disk_read_bytes_current);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_CURRENT, info->disk_write_bytes_current);
+    tree_store_update(model, &info->node, COL_START_TIME, info->start_time);
+    tree_store_update(model, &info->node, COL_NICE, info->nice);
+    tree_store_update(model, &info->node, COL_MEM, info->mem);
+    tree_store_update(model, &info->node, COL_WCHAN, info->wchan);
+    tree_store_update(model, &info->node, COL_CGROUP, info->cgroup_name);
+    tree_store_update(model, &info->node, COL_UNIT, info->unit);
+    tree_store_update(model, &info->node, COL_SESSION, info->session);
+    tree_store_update(model, &info->node, COL_SEAT, info->seat);
+    tree_store_update(model, &info->node, COL_OWNER, info->owner.c_str());
+}
+
+
+
+static void
+insert_info_to_tree (ProcInfo *info, ProcData *procdata, bool forced = false)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    if (procdata->config.show_tree) {
+
+        ProcInfo *parent = 0;
+
+        if (not forced)
+            parent = ProcInfo::find(info->ppid);
+
+        if (parent) {
+            GtkTreePath *parent_node = gtk_tree_model_get_path(model, &parent->node);
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, &parent->node, 0);
+
+            if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(procdata->tree), parent_node)
+#ifdef __linux__
+                // on linuxes we don't want to expand kthreadd by default (always has pid 2)
+                && (parent->pid != 2)
+#endif
+            )
+                gtk_tree_view_expand_row(GTK_TREE_VIEW(procdata->tree), parent_node, FALSE);
+            gtk_tree_path_free(parent_node);
+        } else
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, NULL, 0);
+    }
+    else
+        gtk_tree_store_insert (GTK_TREE_STORE (model), &info->node, NULL, 0);
+
+    gtk_tree_store_set (GTK_TREE_STORE (model), &info->node,
+                        COL_POINTER, info,
+                        COL_NAME, info->name,
+                        COL_ARGS, info->arguments,
+                        COL_TOOLTIP, info->tooltip,
+                        COL_PID, info->pid,
+                        COL_SECURITYCONTEXT, info->security_context,
+                        -1);
+
+    procdata->pretty_table.set_icon(*info);
+
+    procman_debug("inserted %d%s", info->pid, (forced ? " (forced)" : ""));
+}
+
+
+/* Removing a node with children - make sure the children are queued
+** to be readded.
+*/
+template<typename List>
+static void
+remove_info_from_tree (ProcData *procdata, GtkTreeModel *model,
+                       ProcInfo *current, List &orphans, unsigned lvl = 0)
+{
+    GtkTreeIter child_node;
+
+    if (std::find(orphans.begin(), orphans.end(), current) != orphans.end()) {
+        procman_debug("[%u] %d already removed from tree", lvl, int(current->pid));
+        return;
+    }
+
+    procman_debug("[%u] pid %d, %d children", lvl, int(current->pid),
+                  gtk_tree_model_iter_n_children(model, &current->node));
+
+    // it is not possible to iterate&erase over a treeview so instead we
+    // just pop one child after another and recursively remove it and
+    // its children
+
+    while (gtk_tree_model_iter_children(model, &child_node, &current->node)) {
+        ProcInfo *child = 0;
+        gtk_tree_model_get(model, &child_node, COL_POINTER, &child, -1);
+        remove_info_from_tree(procdata, model, child, orphans, lvl + 1);
+    }
+
+    g_assert(not gtk_tree_model_iter_has_child(model, &current->node));
+
+    if (procdata->selected_process == current)
+        procdata->selected_process = NULL;
+
+    orphans.push_back(current);
+    gtk_tree_store_remove(GTK_TREE_STORE(model), &current->node);
+    procman::poison(current->node, 0x69);
+}
+
+static void
+get_process_systemd_info(ProcInfo *info)
+{
+#ifdef HAVE_SYSTEMD
+    uid_t uid;
+
+    if (!LOGIND_RUNNING())
+        return;
+
+    free(info->unit);
+    info->unit = NULL;
+    sd_pid_get_unit(info->pid, &info->unit);
+
+    free(info->session);
+    info->session = NULL;
+    sd_pid_get_session(info->pid, &info->session);
+
+    free(info->seat);
+    info->seat = NULL;
+
+    if (info->session != NULL)
+        sd_session_get_seat(info->session, &info->seat);
+
+    if (sd_pid_get_owner_uid(info->pid, &uid) >= 0)
+        info->owner = info->lookup_user(uid);
+    else
+        info->owner = "";
+#endif
+}
+
+static void
+update_info (ProcData *procdata, ProcInfo *info)
+{
+    glibtop_proc_state procstate;
+    glibtop_proc_uid procuid;
+    glibtop_proc_time proctime;
+    glibtop_proc_kernel prockernel;
+    glibtop_proc_io procio;
+
+    glibtop_get_proc_kernel(&prockernel, info->pid);
+    g_strlcpy(info->wchan, prockernel.wchan, sizeof info->wchan);
+
+    glibtop_get_proc_state (&procstate, info->pid);
+    info->status = procstate.state;
+
+    glibtop_get_proc_uid (&procuid, info->pid);
+    glibtop_get_proc_time (&proctime, info->pid);
+    glibtop_get_proc_io (&procio, info->pid);
+
+    get_process_memory_info(info);
+
+    info->set_user(procstate.uid);
+
+    // if the cpu time has increased reset the status to running
+    // regardless of kernel state (https://bugzilla.gnome.org/606579)
+    guint64 difference = proctime.rtime - info->cpu_time;
+    if (difference > 0)
+        info->status = GLIBTOP_PROCESS_RUNNING;
+    info->pcpu = difference * 100 / procdata->cpu_total_time;
+    info->pcpu = MIN(info->pcpu, 100);
+
+    if (not procdata->config.solaris_mode)
+      info->pcpu *= procdata->config.num_cpus;
+
+    ProcInfo::cpu_times[info->pid] = info->cpu_time = proctime.rtime;
+    info->nice = procuid.nice;
+
+    gdouble update_interval_seconds = procdata->config.update_interval / 1000.0;
+    difference = procio.disk_wbytes - info->disk_write_bytes_total;
+    info->disk_write_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+    difference = procio.disk_rbytes - info->disk_read_bytes_total;
+    info->disk_read_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+
+    info->disk_write_bytes_total = procio.disk_wbytes;
+    info->disk_read_bytes_total = procio.disk_rbytes;
+
+    // set the ppid only if one can exist
+    // i.e. pid=0 can never have a parent
+    if (info->pid > 0) {
+        info->ppid = procuid.ppid;
+    }
+
+    g_assert(info->pid != info->ppid);
+    g_assert(info->ppid != -1 || info->pid == 0);
+
+    /* get cgroup data */
+    get_process_cgroup_info(info);
+
+    get_process_systemd_info(info);
+}
+
+
+ProcInfo::ProcInfo(pid_t pid)
+    : node(),
+      surface(),
+      tooltip(NULL),
+      name(NULL),
+      arguments(NULL),
+      security_context(NULL),
+      pid(pid),
+      ppid(-1),
+      uid(-1)
+{
+    ProcInfo * const info = this;
+    glibtop_proc_state procstate;
+    glibtop_proc_time proctime;
+    glibtop_proc_args procargs;
+    gchar** arguments;<--- Shadow variable
+
+    glibtop_get_proc_state (&procstate, pid);
+    glibtop_get_proc_time (&proctime, pid);
+    arguments = glibtop_get_proc_argv (&procargs, pid, 0);
+
+    /* FIXME : wrong. name and arguments may change with exec* */
+    get_process_name (info, procstate.cmd, static_cast<const GStrv>(arguments));
+
+    std::string tooltip = make_string(g_strjoinv(" ", arguments));<--- Shadow variable
+    if (tooltip.empty())
+        tooltip = procstate.cmd;
+
+    info->tooltip = g_markup_escape_text(tooltip.c_str(), -1);
+
+    info->arguments = g_strescape(tooltip.c_str(), "\\\"");
+    g_strfreev(arguments);
+
+    guint64 cpu_time = proctime.rtime;
+    std::map<pid_t, guint64>::iterator it(ProcInfo::cpu_times.find(pid));
+    if (it != ProcInfo::cpu_times.end())
+    {
+        if (proctime.rtime >= it->second)
+          cpu_time = it->second;
+    }
+    info->cpu_time = cpu_time;
+    info->start_time = proctime.start_time;
+
+    get_process_selinux_context (info);
+    info->cgroup_name = NULL;
+    get_process_cgroup_info(info);
+
+    info->unit = info->session = info->seat = NULL;
+    get_process_systemd_info(info);
+}
+
+static void
+refresh_list (ProcData *procdata, const pid_t* pid_list, const guint n)
+{
+    typedef std::list<ProcInfo*> ProcList;
+    ProcList addition;
+
+    GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+    guint i;
+
+    // Add or update processes in the process list
+    for(i = 0; i < n; ++i) {
+        ProcInfo *info = ProcInfo::find(pid_list[i]);
+
+        if (!info) {
+            info = new ProcInfo(pid_list[i]);
+            ProcInfo::all[info->pid] = info;
+            addition.push_back(info);
+        }
+
+        update_info (procdata, info);
+    }
+
+
+    // Remove dead processes from the process list and from the
+    // tree. children are queued to be readded at the right place
+    // in the tree.
+
+    const std::set<pid_t> pids(pid_list, pid_list + n);
+
+    ProcInfo::Iterator it(ProcInfo::begin());<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration
+
+    while (it != ProcInfo::end()) {
+        ProcInfo * const info = it->second;
+        ProcInfo::Iterator next(it);
+        ++next;
+
+        if (pids.find(info->pid) == pids.end()) {
+            procman_debug("ripping %d", info->pid);
+            remove_info_from_tree(procdata, model, info, addition);
+            addition.remove(info);
+            ProcInfo::all.erase(it);
+            delete info;
+        }
+
+        it = next;
+    }
+
+    // INVARIANT
+    // pid_list == ProcInfo::all + addition
+
+
+    if (procdata->config.show_tree) {
+
+        // insert process in the tree. walk through the addition list
+        // (new process + process that have a new parent). This loop
+        // handles the dependencies because we cannot insert a process
+        // until its parent is in the tree.
+
+        std::set<pid_t> in_tree(pids);
+
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            in_tree.erase((*it)->pid);
+
+
+        while (not addition.empty()) {
+            procman_debug("looking for %d parents", int(addition.size()));
+            ProcList::iterator it(addition.begin());<--- Shadow variable
+
+            while (it != addition.end()) {
+                procman_debug("looking for %d's parent with ppid %d",
+                              int((*it)->pid), int((*it)->ppid));
+
+
+                // inserts the process in the treeview if :
+                // - it has no parent (ppid = -1),
+                //   ie it is for example the [kernel] on FreeBSD
+                // - it is init
+                // - its parent is already in tree
+                // - its parent is unreachable
+                //
+                // rounds == 2 means that addition contains processes with
+                // unreachable parents
+                //
+                // FIXME: this is broken if the unreachable parent becomes active
+                // i.e. it gets active or changes ower
+                // so we just clear the tree on __each__ update
+                // see proctable_update_list (ProcData * const procdata)
+
+
+                if ((*it)->ppid <= 0 or in_tree.find((*it)->ppid) != in_tree.end()) {
+                    insert_info_to_tree(*it, procdata);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ProcInfo *parent = ProcInfo::find((*it)->ppid);
+                // if the parent is unreachable
+                if (not parent) {
+                    // or std::find(addition.begin(), addition.end(), parent) == addition.end()) {
+                    insert_info_to_tree(*it, procdata, true);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ++it;
+            }
+        }
+    }
+    else {
+        // don't care of the tree
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            insert_info_to_tree(*it, procdata);
+    }
+
+
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)<--- Shadow variable
+        update_info_mutable_cols(it->second);
+}
+
+
+static void
+proctable_update_list (ProcData * const procdata)
+{
+    pid_t* pid_list;
+    glibtop_proclist proclist;
+    glibtop_cpu cpu;
+    gint which, arg;
+    procman::SelectionMemento selection;
+
+    switch (procdata->config.whose_process) {
+        case ALL_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL;
+            arg = 0;
+            break;
+
+        case ACTIVE_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL | GLIBTOP_EXCLUDE_IDLE;
+            arg = 0;
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+
+        default:
+            which = GLIBTOP_KERN_PROC_UID;
+            arg = getuid ();
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+    }
+
+    pid_list = glibtop_get_proclist (&proclist, which, arg);
+
+    /* FIXME: total cpu time elapsed should be calculated on an individual basis here
+    ** should probably have a total_time_last gint in the ProcInfo structure */
+    glibtop_get_cpu (&cpu);
+    procdata->cpu_total_time = MAX(cpu.total - procdata->cpu_total_time_last, 1);
+    procdata->cpu_total_time_last = cpu.total;
+
+    // FIXME: not sure if glibtop always returns a sorted list of pid
+    // but it is important otherwise refresh_list won't find the parent
+    std::sort(pid_list, pid_list + proclist.number);
+
+    refresh_list (procdata, pid_list, proclist.number);
+
+    selection.restore(procdata->tree);
+
+    g_free (pid_list);
+
+    /* proclist.number == g_list_length(procdata->info) == g_hash_table_size(procdata->pids) */
+}
+
+
+void
+proctable_update (ProcData * const procdata)
+{
+    char* string;
+
+    string = make_loadavg_string();
+    gtk_label_set_text (GTK_LABEL(procdata->loadavg), string);
+    g_free (string);
+
+    proctable_update_list (procdata);
+}
+
+
+void
+proctable_free_table (ProcData * const procdata)
+{
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)
+        delete it->second;
+
+    ProcInfo::all.clear();
+}
+
+
+void
+proctable_clear_tree (ProcData * const procdata)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    gtk_tree_store_clear (GTK_TREE_STORE (model));
+
+    proctable_free_table (procdata);
+
+    update_sensitivity(procdata);
+}
+
+
+char*
+make_loadavg_string(void)
+{
+    glibtop_loadavg buf;
+
+    glibtop_get_loadavg(&buf);
+
+    return g_strdup_printf(
+        _("Load averages for the last 1, 5, 15 minutes: "
+          "%0.2f, %0.2f, %0.2f"),
+        buf.loadavg[0],
+        buf.loadavg[1],
+        buf.loadavg[2]);
+}
+
+
+
+void
+ProcInfo::set_icon(Glib::RefPtr<Gdk::Pixbuf> icon)
+{
+  this->surface = gdk_cairo_surface_create_from_pixbuf (icon->gobj(), 0, NULL);
+
+  GtkTreeModel *model;
+  model = gtk_tree_view_get_model(GTK_TREE_VIEW(ProcData::get_instance()->tree));
+  gtk_tree_store_set(GTK_TREE_STORE(model), &this->node,
+                     COL_SURFACE, this->surface,
+                    -1);
+}
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/18.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/18.html new file mode 100644 index 00000000..4e691255 --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/18.html @@ -0,0 +1,405 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
#include <config.h>
+
+#include <glib.h>
+
+#include "selinux.h"
+#include "procman.h"
+#include "util.h"
+
+
+static int (*getpidcon)(pid_t, char**);
+static void (*freecon)(char*);
+static int (*is_selinux_enabled)(void);
+
+static gboolean has_selinux;
+
+static gboolean load_selinux(void)
+{
+    return load_symbols("libselinux.so.1",
+                        "getpidcon", &getpidcon,
+                        "freecon", &freecon,
+                        "is_selinux_enabled", &is_selinux_enabled,
+                        NULL);
+}
+
+
+
+void
+get_process_selinux_context (ProcInfo *info)
+{
+    char *con;
+
+    if (has_selinux && !getpidcon (info->pid, &con)) {
+        info->security_context = g_strdup (con);
+        freecon (con);
+    }
+}
+
+
+
+gboolean
+can_show_security_context_column (void)
+{
+    if (!(has_selinux = load_selinux()))
+        return FALSE;
+
+    switch (is_selinux_enabled()) {
+        case 1:
+            /* We're running on an SELinux kernel */
+            return TRUE;
+
+        case -1:
+            /* Error; hide the security context column */
+
+        case 0:
+            /* We're not running on an SELinux kernel:
+               hide the security context column */
+
+        default:
+            g_warning("SELinux was found but is not enabled.\n");
+            return FALSE;
+    }
+}
+
+
+
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/19.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/19.html new file mode 100644 index 00000000..913bbae3 --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/19.html @@ -0,0 +1,2359 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
#include <config.h>
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <glibmm.h>
+#include <glib/gi18n.h>
+
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+
+#include <glibtop/fsusage.h>
+#include <glibtop/mountlist.h>
+#include <glibtop/mem.h>
+#include <glibtop/sysinfo.h>
+
+#include <unistd.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#include <math.h>
+#include <errno.h>
+
+#include <exception>
+#include <string>
+#include <vector>
+#include <fstream>
+#include <sstream>
+#include <sys/utsname.h>
+
+#include "sysinfo.h"
+#include "procman.h"
+#include "util.h"
+
+
+using std::string;
+using std::vector;
+
+
+namespace {
+
+    class SysInfo
+    {
+    public:
+        string hostname;
+        string distro_name;
+        string distro_release;
+        string kernel;
+        string mate_version;
+        guint64 memory_bytes;
+        guint64 free_space_bytes;
+
+        string graphics;
+        string processors;
+
+        SysInfo()
+        {
+            this->load_processors_info();
+            this->load_graphics_info();
+            this->load_memory_info();
+            this->load_disk_info();
+            this->load_uname_info();
+            this->load_mate_version();
+        }
+
+        virtual ~SysInfo()
+        { }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Virtual function in base class
+        {
+            g_object_set(G_OBJECT(name),
+                        "label",
+                        ("<big><big><b>" + this->distro_name + "</b></big></big>").c_str(),
+                        NULL);
+
+            char* markup;
+#ifdef __linux__
+            if (this->distro_release != "")
+            {
+                /* Translators: The first string parameter is release version (codename),
+                 * the second one is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("Release %s %s"),
+                                         this->distro_release.c_str(),
+                                         SysInfo::get_os_type().c_str());
+            }
+            else
+            {
+                /* Translators: The string parameter is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("%s Version"),
+                                         SysInfo::get_os_type().c_str());
+            }
+#else
+            /* Translators: The string parameter is release version (codename) */
+            markup = g_strdup_printf(_("Release %s"),
+                                     this->distro_release.c_str());
+#endif
+
+            g_object_set(G_OBJECT(release),
+                         "label",
+                         markup,
+                         NULL);
+
+            g_free(markup);
+        }
+
+        static string release()
+        {
+            return uname().release;
+        }
+
+        static string system()
+        {
+            return uname().sysname;
+        }
+
+    private:
+
+        void load_memory_info()
+        {
+            glibtop_mem mem;
+
+            glibtop_get_mem(&mem);
+            this->memory_bytes = mem.total;
+        }
+
+        static string get_os_type ()<--- Unused private function: 'SysInfo::get_os_type'
+        {
+            int bits;
+
+            if (GLIB_SIZEOF_VOID_P == 8)
+                bits = 64;
+            else
+                bits = 32;
+
+            /* translators: This is the type of architecture, for example:
+             * "64-bit" or "32-bit" */
+            char* bytes = g_strdup_printf (_("%d-bit"), bits);
+            string retval(bytes);
+            g_free(bytes);
+            return retval;
+        }
+
+        typedef struct
+        {
+            const char* regex;
+            const char* replacement;
+        } ReplaceStrings;
+
+        static char* remove_duplicate_whitespace (const char* old)
+        {
+            char* result;
+            GRegex* re;
+            GError* error = NULL;
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+
+            re = g_regex_new ("[ \t\n\r]+", G_REGEX_MULTILINE, flags, &error);
+            if (re == NULL) {
+                g_warning ("Error building regex: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+            result = g_regex_replace (re, old, -1, 0, " ", flags, &error);
+            g_regex_unref (re);
+            if (result == NULL) {
+                g_warning ("Error replacing string: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+
+            return result;
+        }
+
+        static char* prettify_info (const char *info)
+        {
+            char* pretty;
+            const GRegexCompileFlags cflags = static_cast<GRegexCompileFlags>(0);
+            const GRegexMatchFlags mflags = static_cast<GRegexMatchFlags>(0);
+
+            static const ReplaceStrings rs[] = {
+                { "Intel[(]R[)]", "Intel\302\256"},
+                { "Core[(]TM[)]", "Core\342\204\242"},
+                { "Atom[(]TM[)]", "Atom\342\204\242"},
+            };
+
+            pretty = g_markup_escape_text (info, -1);
+
+            for (uint i = 0; i < G_N_ELEMENTS (rs); i++) {
+                GError* error;
+                GRegex* re;
+                char* result;
+
+                error = NULL;
+
+                re = g_regex_new (rs[i].regex, cflags, mflags, &error);
+                if (re == NULL) {
+                    g_warning ("Error building regex: %s", error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                result = g_regex_replace_literal (re, pretty, -1, 0,
+                                             rs[i].replacement, mflags, &error);
+
+                g_regex_unref (re);
+
+                if (error != NULL) {
+                    g_warning ("Error replacing %s: %s", rs[i].regex, error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                g_free (pretty);
+                pretty = result;
+            }
+
+            return pretty;
+        }
+
+        static char* get_renderer_from_helper (gboolean discrete_gpu)
+        {
+            int status;
+            const char *argv[] = { LIBEXECDIR "/mate-session-check-accelerated", NULL };
+            g_auto(GStrv) envp = NULL;
+            g_autofree char *renderer = NULL;
+            g_autoptr(GError) error = NULL;
+
+            if (discrete_gpu)
+            {
+                envp = g_get_environ ();
+                envp = g_environ_setenv (envp, "DRI_PRIME", "1", TRUE);
+            }
+
+            if (!g_spawn_sync (NULL, (char **) argv, envp, G_SPAWN_DEFAULT, NULL, NULL, &renderer, NULL, &status, &error))
+            {
+                g_debug ("Failed to get %s GPU: %s",
+                         discrete_gpu ? "discrete" : "integrated",
+                         error->message);
+                return NULL;
+            }
+
+            if (!g_spawn_check_exit_status (status, NULL))
+                return NULL;
+
+            if (renderer == NULL || *renderer == '\0')
+                return NULL;
+
+            return prettify_info (renderer);
+        }
+
+
+        void load_graphics_info()
+        {
+            g_autofree char *renderer = NULL;
+
+            try
+            {
+                g_autoptr(GDBusProxy) session_proxy = NULL;
+                g_autoptr(GVariant) renderer_variant = NULL;
+                g_autoptr(GError) error = NULL;
+
+                session_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                               G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL,
+                                                               "org.gnome.SessionManager",
+                                                               "/org/gnome/SessionManager",
+                                                               "org.gnome.SessionManager",
+                                                               NULL, &error);
+                if (error != NULL)
+                {
+                    throw std::runtime_error ("Unable to connect to create a proxy for org.gnome.SessionManager");
+                }
+
+                renderer_variant = g_dbus_proxy_get_cached_property (session_proxy, "Renderer");
+                if (!renderer_variant)
+                {
+                    throw std::runtime_error ("Unable to retrieve org.gnome.SessionManager.Renderer property.");
+                }
+
+                renderer = prettify_info (g_variant_get_string (renderer_variant, NULL));
+            }
+            catch (std::exception& e)
+            {
+                g_warning ("%s", e.what());
+            }
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (FALSE);
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (TRUE);
+
+            if (renderer)
+            {
+                this->graphics = g_strdup (renderer);
+            }
+            else
+            {
+                this->graphics = _("Unknown");
+            }
+        }
+
+        void load_processors_info()
+        {
+            const glibtop_sysinfo *info = glibtop_get_sysinfo();
+
+            GHashTable* counts;
+            GString* cpu;
+            GHashTableIter iter;
+            gpointer key, value;
+
+            counts = g_hash_table_new (g_str_hash, g_str_equal);
+
+            /* count duplicates */
+            for (uint i = 0; i != info->ncpu; ++i) {
+                const char* const keys[] = { "model name", "cpu", "Processor" };
+                char* model;
+                int* count;
+
+                model = NULL;
+
+                for (int j = 0; model == NULL && j != G_N_ELEMENTS (keys); ++j) {
+                    model = static_cast<char*>(g_hash_table_lookup (info->cpuinfo[i].values,
+                                                 keys[j]));
+                }
+
+                if (model == NULL)
+                    continue;
+
+                count = static_cast<int*>(g_hash_table_lookup (counts, model));
+                if (count == NULL)
+                    g_hash_table_insert (counts, model, GINT_TO_POINTER (1));
+                else
+                    g_hash_table_replace (counts, model, GINT_TO_POINTER (GPOINTER_TO_INT (count) + 1));
+            }
+
+            cpu = g_string_new (NULL);
+            g_hash_table_iter_init (&iter, counts);
+            while (g_hash_table_iter_next (&iter, &key, &value)) {
+                char* stripped;
+                int   count;
+
+                count = GPOINTER_TO_INT (value);
+                stripped = remove_duplicate_whitespace ((const char *)key);
+                if (count > 1)
+                    g_string_append_printf (cpu, "%s \303\227 %d ", stripped, count);
+                else
+                    g_string_append_printf (cpu, "%s ", stripped);
+                g_free (stripped);
+            }
+
+            g_hash_table_destroy (counts);
+            this->processors = string(prettify_info (cpu->str));
+            g_string_free (cpu, TRUE);
+        }
+
+        void load_disk_info()
+        {
+            GHashTable *devices;
+            glibtop_mountentry *entries;
+            glibtop_mountlist mountlist;
+
+            entries = glibtop_get_mountlist(&mountlist, 0);
+            devices = g_hash_table_new(g_str_hash, g_str_equal);
+            this->free_space_bytes = 0;
+
+            for (guint i = 0; i != mountlist.number; ++i) {
+                if ((string(entries[i].mountdir).compare("/") == 0) && \
+                    (string(entries[i].type).compare("zfs") == 0)) {
+                    // Root filesystem is ZFS based: Calculate usage based on "/".
+                    glibtop_fsusage usage;
+                    glibtop_get_fsusage(&usage, "/");
+                    this->free_space_bytes = usage.bavail * usage.block_size;
+                    break;
+                }
+
+                if (string(entries[i].devname).find("/dev/") != 0)
+                    continue;
+
+                if (string(entries[i].mountdir).find("/media/") == 0)
+                    continue;
+
+                /* avoid adding a device more than once such as for btrfs filesystem */
+                if (g_hash_table_contains (devices, entries[i].devname))
+                    continue;
+                else
+                    g_hash_table_insert (devices, entries[i].devname, entries[i].mountdir);
+
+                glibtop_fsusage usage;
+                glibtop_get_fsusage(&usage, entries[i].mountdir);
+                this->free_space_bytes += usage.bavail * usage.block_size;
+            }
+
+            g_hash_table_destroy (devices);
+            g_free(entries);
+        }
+
+        static const struct utsname & uname()
+        {
+            static struct utsname name;
+
+            if (!name.sysname[0]) {
+                ::uname(&name);
+            }
+
+            return name;
+        }
+
+        void load_uname_info()
+        {
+            this->hostname = uname().nodename;
+#if defined(__linux__)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().machine;
+#elif defined(__sun) && defined(__SVR4)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().version + ' ' + uname().machine;
+#else
+            this->kernel = string(uname().version) + ' ' + uname().machine;
+#endif
+        }
+
+
+        void load_mate_version()
+        {
+            xmlDocPtr document;
+            xmlXPathContextPtr context;
+            const string nodes[3] = { "string(/mate-version/platform)",
+                                      "string(/mate-version/minor)",
+                                      "string(/mate-version/micro)" };
+            string values[3];
+
+            if (not (document = xmlParseFile(DATADIR "/mate-about/mate-version.xml")))
+                return;
+
+            if (not (context = xmlXPathNewContext(document)))
+                return;
+
+            for (size_t i = 0; i != 3; ++i)
+            {
+                xmlXPathObjectPtr xpath;
+                xpath = xmlXPathEvalExpression(BAD_CAST nodes[i].c_str(), context);
+
+                if (xpath and xpath->type == XPATH_STRING)
+                    values[i] = reinterpret_cast<const char*>(xpath->stringval);
+
+                xmlXPathFreeObject(xpath);
+            }
+
+            xmlXPathFreeContext(context);
+            xmlFreeDoc(document);
+
+            if (!values[0].empty() && !values[1].empty() && !values[2].empty())
+                this->mate_version = values[0] + '.' + values[1] + '.' + values[2];
+        }
+    };
+
+    class FreeBSDSysInfo
+        : public SysInfo
+    {
+    public:
+	FreeBSDSysInfo()
+        {
+            this->load_freebsd_info();
+        }
+
+    private:
+        void load_freebsd_info()
+        {
+            this->distro_name = "FreeBSD";
+            this->distro_release = release();
+        }
+    };
+
+    class SolarisSysInfo
+        : public SysInfo
+    {
+    public:
+        SolarisSysInfo()
+        {
+            this->load_solaris_info();
+        }
+
+    private:
+        void load_solaris_info()
+        {
+            std::ifstream input("/etc/release");
+
+            if (input) {
+                std::string s;
+                std::getline(input, s);
+                std::size_t found = s.find("OpenIndiana ");
+                if (found!=std::string::npos) {
+                    this->distro_name = "OpenIndiana";
+                    this->distro_release = s.substr(found + strlen("OpenIndiana "));
+                } else if (!s.empty()) {
+                    this->distro_release = s;
+                }
+            }
+
+            if (this->distro_release.empty()) {
+                this->distro_name = "Solaris";
+            }
+        }
+    };
+
+
+    class LSBSysInfo
+        : public SysInfo
+    {
+    public:
+        LSBSysInfo()<--- Member variable 'LSBSysInfo::lsb_fd' is not initialized in the constructor.<--- Member variable 'LSBSysInfo::name' is not initialized in the constructor.<--- Member variable 'LSBSysInfo::release' is not initialized in the constructor.
+            : re(Glib::Regex::create("^.+?:\\s*(.+)\\s*$"))
+        {
+            // start();
+        }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Function in derived class
+        {
+            this->name = name;
+            this->release = release;
+
+            this->start();
+        }
+
+
+    private:
+
+        sigc::connection child_watch;
+        int lsb_fd;
+        GtkWidget* name;
+        GtkWidget* release;<--- Shadowed declaration<--- Shadowed declaration
+
+        void strip_description(string &s) const
+        {
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+            GMatchInfo* info = 0;
+
+           if (g_regex_match(this->re->gobj(), s.c_str(), flags, &info)) {
+               s = make_string(g_match_info_fetch(info, 1));
+               g_match_info_free(info);
+           }
+        }
+
+        std::istream& get_value(std::istream &is, string &s) const
+        {
+            if (std::getline(is, s))
+                this->strip_description(s);
+            return is;
+        }
+
+
+        void read_lsb(Glib::Pid pid, int status)
+        {
+            this->child_watch.disconnect();
+
+            if (!WIFEXITED(status) or WEXITSTATUS(status) != 0) {
+                g_error("Child %d failed with status %d", int(pid), status);
+                return;
+            }
+
+            Glib::RefPtr<Glib::IOChannel> channel = Glib::IOChannel::create_from_fd(this->lsb_fd);
+            Glib::ustring content;
+
+            while (channel->read_to_end(content) == Glib::IO_STATUS_AGAIN)
+                ;
+
+            channel->close();
+            Glib::spawn_close_pid(pid);
+
+            procman_debug("lsb_release output = '%s'", content.c_str());
+
+            string release, codename;<--- Shadow variable
+            std::istringstream input(content);
+
+            this->get_value(input, this->distro_name)
+                and this->get_value(input, release)
+                and this->get_value(input, codename);
+
+            this->distro_release = release;
+            if (codename != "" && codename != "n/a")
+                this->distro_release += " (" + codename + ')';
+
+            this->SysInfo::set_distro_labels(this->name, this->release);
+        }
+
+
+        void start()
+        {
+            std::vector<string> argv(2);
+            argv[0] = "lsb_release";
+            argv[1] = "-irc";
+
+            Glib::SpawnFlags flags = Glib::SPAWN_DO_NOT_REAP_CHILD
+                | Glib::SPAWN_SEARCH_PATH
+                | Glib::SPAWN_STDERR_TO_DEV_NULL;
+
+            Glib::Pid child;
+
+            try {
+                Glib::spawn_async_with_pipes("/", // wd
+                                             argv,
+                                             flags,
+                                             sigc::slot<void>(), // child setup
+                                             &child,
+                                             0, // stdin
+                                             &this->lsb_fd); // stdout
+            } catch (Glib::SpawnError &e) {
+                g_error("g_spawn_async_with_pipes error: %s", e.what().c_str());
+                return;
+            }
+
+            sigc::slot<void,GPid, int> slot = sigc::mem_fun(this, &LSBSysInfo::read_lsb);
+            this->child_watch = Glib::signal_child_watch().connect(slot, child);
+        }
+
+
+        void sync_lsb_release()<--- Unused private function: 'LSBSysInfo::sync_lsb_release'
+        {
+            char *out= 0;
+            GError *error = 0;
+            int status;
+
+            if (g_spawn_command_line_sync("lsb_release -irc",
+                                          &out,
+                                          0,
+                                          &status,
+                                          &error)) {
+                string release, codename;<--- Shadow variable
+                if (!error and WIFEXITED(status) and WEXITSTATUS(status) == 0) {
+                    std::istringstream input(out);
+                    this->get_value(input, this->distro_name)
+                        and this->get_value(input, release)
+                        and this->get_value(input, codename);
+                    this->distro_release = release;
+                if (codename != "" && codename != "n/a")
+                    this->distro_release += " (" + codename + ')';
+                }
+            }
+
+            if (error)
+                g_error_free(error);
+
+            g_free(out);
+        }
+
+    private:
+        Glib::RefPtr<Glib::Regex> re;
+    };
+
+
+    class NetBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        NetBSDSysInfo()
+        {
+            this->load_netbsd_info();
+        }
+
+    private:
+        void load_netbsd_info()
+        {
+            this->distro_name = "NetBSD";
+
+            std::ifstream input("/etc/release");
+
+            if (input)
+                std::getline(input, this->distro_release);
+        }
+    };
+
+
+    class GenericSysInfo
+        : public SysInfo
+    {
+    public:
+        GenericSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            std::ifstream input("/etc/os-release");
+
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int start;
+                    std::getline(input, s);
+                    if (s.find("NAME=") == 0) {
+                        start = strlen("NAME=");
+                        if ((s.at(start) == '\"') && (s.at(s.size() - 1) == '\"')) {
+                            this->distro_name = s.substr(start + 1, s.size() - start - 2);
+                        } else {
+                            this->distro_name = s.substr(start);
+                        }
+                    } else if (s.find("VERSION=") == 0) {
+                        start = strlen("VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    } else if (s.find("# VERSION=") == 0) {
+                        start = strlen("# VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    }
+                }
+                input.close();
+                input.clear();
+            }
+            if (this->distro_release.empty()) {
+                input.open("/etc/debian_version");
+                if (input) {
+                    getline(input, this->distro_release);
+                }
+            }
+        }
+    };
+
+    class MintSysInfo
+        : public SysInfo
+    {
+    public:
+        MintSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            this->distro_name = "Linux Mint";
+            std::ifstream input("/etc/linuxmint/info");
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int len;
+                    std::getline(input, s);
+                    if (s.find("DESCRIPTION=") == 0) {
+                        len = strlen("DESCRIPTION=");
+                        // also strip the surrounding quotes
+                       this->distro_release = s.substr(len + 1, s.size() - len - 2);
+                   }
+                }
+            }
+        }
+    };
+
+    class OpenBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        OpenBSDSysInfo()
+        {
+            this->load_openbsd_info();
+        }
+
+    private:
+        void load_openbsd_info()
+        {
+            this->distro_name = "OpenBSD";
+            this->distro_release = this->kernel;
+
+            std::ifstream input("/etc/motd");
+
+            if (input)
+                std::getline(input, this->kernel);
+        }
+    };
+
+    SysInfo* get_sysinfo()
+    {
+        if (g_file_test ("/etc/linuxmint/info", G_FILE_TEST_EXISTS)) {
+            return new MintSysInfo;
+        }
+        else if (g_file_test ("/etc/os-release", G_FILE_TEST_EXISTS)) {
+            return new GenericSysInfo;
+        }
+        else if (char *p = g_find_program_in_path("lsb_release")) {
+            g_free(p);
+            return new LSBSysInfo;
+        }
+        else if (SysInfo::system() == "FreeBSD") {
+            return new FreeBSDSysInfo;
+        }
+        else if (SysInfo::system() == "SunOS") {
+            return new SolarisSysInfo;
+        }
+        else if (SysInfo::system() == "NetBSD") {
+            return new NetBSDSysInfo;
+        }
+        else if (SysInfo::system() == "OpenBSD") {
+            return new OpenBSDSysInfo;
+        }
+
+        return new SysInfo;
+    }
+}
+
+
+#define X_PAD  0
+#define Y_PAD  0
+#define LOGO_W 92
+#define LOGO_H 351
+#define RADIUS 5
+
+static gboolean sysinfo_logo_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    GtkStyle *style;
+    cairo_t *cr;
+    cairo_pattern_t *cp;
+
+    cr = gdk_cairo_create(gtk_widget_get_window(widget));
+
+    gtk_widget_get_allocation (widget, &allocation);
+    cairo_translate(cr, allocation.x, allocation.y);
+
+    cairo_move_to(cr, X_PAD + RADIUS, Y_PAD);
+    cairo_line_to(cr, X_PAD + LOGO_W - RADIUS, Y_PAD);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + RADIUS, RADIUS, -0.5 * M_PI, 0);
+    cairo_line_to(cr, X_PAD + LOGO_W, Y_PAD + LOGO_H - RADIUS);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0, 0.5 * M_PI);
+    cairo_line_to(cr, X_PAD + RADIUS, Y_PAD + LOGO_H);
+    cairo_arc(cr, X_PAD + RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0.5 * M_PI, -1.0 * M_PI);
+    cairo_line_to(cr, X_PAD, Y_PAD + RADIUS);
+    cairo_arc(cr,  X_PAD + RADIUS, Y_PAD + RADIUS, RADIUS, -1.0 * M_PI, -0.5 * M_PI);
+
+    cp = cairo_pattern_create_linear(0, Y_PAD, 0, Y_PAD + LOGO_H);
+    style = gtk_widget_get_style (widget);
+    cairo_pattern_add_color_stop_rgba(cp, 0.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      1.0);
+    cairo_pattern_add_color_stop_rgba(cp, 1.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      0.0);
+    cairo_set_source(cr, cp);
+    cairo_fill(cr);
+
+    cairo_pattern_destroy(cp);
+    cairo_destroy(cr);
+
+    return FALSE;
+}
+
+static GtkWidget*
+add_section(GtkBox *vbox , const char * title, int num_row, int num_col, GtkWidget **out_frame)
+{
+    GtkWidget *table;
+
+    GtkWidget *frame = gtk_frame_new(title);
+    gtk_frame_set_label_align(GTK_FRAME(frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
+
+    table = gtk_grid_new();
+    gtk_grid_set_row_spacing(GTK_GRID(table), 6);
+    gtk_grid_set_column_spacing(GTK_GRID(table), 6);
+    gtk_widget_set_margin_start (GTK_WIDGET(table), 12);
+    gtk_container_set_border_width(GTK_CONTAINER(table), 6);
+    gtk_container_add(GTK_CONTAINER(frame), table);
+
+    if(out_frame)
+        *out_frame = frame;
+
+    return table;
+}
+
+
+static GtkWidget*
+add_row(GtkGrid * table, const char * label, const char * value, int row)
+{
+    GtkWidget *header = gtk_label_new(NULL);
+    gtk_label_set_markup(GTK_LABEL(header), label);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        table, header,
+        0, row, 1, 1);
+
+    GtkWidget *label_widget = gtk_label_new(value);
+    gtk_label_set_selectable(GTK_LABEL(label_widget), TRUE);
+    gtk_widget_set_can_focus(label_widget, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (label_widget), 0.0);
+    gtk_grid_attach(
+        table, label_widget,
+        1, row, 1, 1);
+
+    return label_widget;
+}
+
+
+static GtkWidget *
+procman_create_sysinfo_view(void)
+{
+    GtkWidget *hbox;
+    GtkWidget *vbox;
+
+    SysInfo *data = get_sysinfo();;
+
+    GtkWidget * logo;
+
+    GtkWidget *distro_frame;
+    GtkWidget *distro_release_label;
+    GtkWidget *distro_table;
+
+    GtkWidget *hardware_table;
+    GtkWidget *disk_space_table;
+
+    GtkWidget *header;
+
+    gchar *markup;
+
+    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);
+
+    /* left-side logo */
+    if (g_file_test (DATADIR "/pixmaps/mate-system-monitor/distribution/side.png", G_FILE_TEST_EXISTS)) {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/distribution/side.png");
+    }
+    else {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/side.png");
+    }
+    gtk_widget_set_valign (logo, GTK_ALIGN_START);
+    gtk_widget_set_margin_start (logo, 5);
+    gtk_widget_set_margin_end (logo, 5);
+    gtk_widget_set_margin_top (logo, 12);
+    gtk_widget_set_margin_bottom (logo, 12);
+    gtk_box_pack_start(GTK_BOX(hbox), logo, FALSE, FALSE, 0);
+
+    g_signal_connect(G_OBJECT(logo), "draw", G_CALLBACK(sysinfo_logo_draw), NULL);
+
+    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
+    gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
+
+    // hostname
+
+    markup = g_strdup_printf("<big><big><b><u>%s</u></b></big></big>",
+                             data->hostname.c_str());
+    GtkWidget *hostname_frame = gtk_frame_new(markup);
+    g_free(markup);
+    gtk_frame_set_label_align(GTK_FRAME(hostname_frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(hostname_frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(hostname_frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), hostname_frame, FALSE, FALSE, 0);
+
+
+    /* distro section */
+
+    unsigned table_size = 2;
+    if (data->mate_version != "")
+        table_size++;
+    distro_table = add_section(GTK_BOX(vbox), "???", table_size, 1, &distro_frame);
+
+    unsigned table_count = 0;
+
+    distro_release_label = gtk_label_new("???");
+    gtk_label_set_selectable(GTK_LABEL(distro_release_label), TRUE);
+    gtk_widget_set_can_focus(distro_release_label, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (distro_release_label), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), distro_release_label,
+        0, table_count, 1, 1);
+    table_count++;
+    data->set_distro_labels(gtk_frame_get_label_widget(GTK_FRAME(distro_frame)), distro_release_label);
+
+    markup = g_strdup_printf(_("Kernel %s"), data->kernel.c_str());
+    header = gtk_label_new(markup);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    g_free(markup);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), header,
+        0, table_count, 1, 1);
+    table_count++;
+
+    if (data->mate_version != "")
+    {
+        markup = g_strdup_printf(_("MATE %s"), data->mate_version.c_str());
+        header = gtk_label_new(markup);
+        gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+        gtk_widget_set_can_focus(header, FALSE);
+        g_free(markup);
+        gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+        gtk_grid_attach(
+            GTK_GRID(distro_table), header,
+            0, table_count, 1, 1);
+        table_count++;<--- Variable 'table_count' is assigned a value that is never used.
+    }
+
+    /* hardware section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("Hardware"));
+    hardware_table = add_section(GTK_BOX(vbox), markup, 1, 3, NULL);
+    g_free(markup);
+
+    markup = g_format_size_full(data->memory_bytes, G_FORMAT_SIZE_IEC_UNITS);
+    add_row(GTK_GRID(hardware_table), _("Memory:"), markup, 0);
+    g_free(markup);
+
+    add_row(GTK_GRID(hardware_table), _("Processor:"),
+            data->processors.c_str(), 1);
+    add_row(GTK_GRID(hardware_table), _("Graphics:"),
+            data->graphics.c_str(), 2);
+
+    /* disk space section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("System Status"));
+    disk_space_table = add_section(GTK_BOX(vbox), markup, 1, 2, NULL);
+    g_free(markup);
+
+    markup = g_format_size(data->free_space_bytes);
+    add_row(GTK_GRID(disk_space_table), _("Available disk space:"), markup, 0);
+    g_free(markup);
+
+    return hbox;
+}
+
+
+
+namespace procman
+{
+    void build_sysinfo_ui()
+    {
+        static GtkWidget* ui;
+
+        if (!ui) {
+            ProcData* procdata = ProcData::get_instance();
+            ui = procman_create_sysinfo_view();
+            GtkBox* box = GTK_BOX(gtk_notebook_get_nth_page(GTK_NOTEBOOK(procdata->notebook),
+                                                            PROCMAN_TAB_SYSINFO));
+            gtk_box_pack_start(box, ui, TRUE, TRUE, 0);
+            gtk_widget_show_all(ui);
+        }
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/2.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/2.html new file mode 100644 index 00000000..0154b48f --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/2.html @@ -0,0 +1,489 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
#ifndef _PROCMAN_LOAD_GRAPH_H_
+#define _PROCMAN_LOAD_GRAPH_H_
+
+#include <glib.h>
+#include <glibtop/cpu.h>
+
+enum
+{
+    LOAD_GRAPH_CPU,
+    LOAD_GRAPH_MEM,
+    LOAD_GRAPH_NET
+};
+
+enum {
+    CPU_TOTAL,
+    CPU_USED,
+    N_CPU_STATES
+};
+
+struct LoadGraphLabels
+{
+    GtkWidget *cpu[GLIBTOP_NCPU];
+    GtkWidget *memory;
+    GtkWidget *swap;
+    GtkWidget *net_in;
+    GtkWidget *net_in_total;
+    GtkWidget *net_out;
+    GtkWidget *net_out_total;
+};
+
+struct LoadGraph {
+
+    static const unsigned NUM_POINTS = 60 + 2;
+    static const unsigned GRAPH_MIN_HEIGHT = 40;
+
+    LoadGraph(guint type);
+    ~LoadGraph();
+
+    unsigned num_bars() const;
+    void clear_background();
+
+    double fontsize;
+    double rmargin;
+    double indent;
+
+    guint n;
+    gint type;
+    guint speed;
+    guint draw_width, draw_height;
+    guint render_counter;
+    guint frames_per_unit;
+    guint graph_dely;
+    guint real_draw_height;
+    double graph_delx;
+    guint graph_buffer_offset;
+
+    std::vector<GdkRGBA> colors;
+
+    std::vector<float> data_block;
+    gfloat* data[NUM_POINTS];
+
+    GtkWidget *main_widget;
+    GtkWidget *disp;
+
+    cairo_pattern_t *background;
+
+    guint timer_index;
+
+    gboolean draw;
+
+    LoadGraphLabels labels;
+    GtkWidget *mem_color_picker;
+    GtkWidget *swap_color_picker;
+
+    /* union { */
+        struct {
+            guint now; /* 0 -> current, 1 -> last
+                    now ^ 1 each time */
+            /* times[now], times[now ^ 1] is last */
+            guint64 times[2][GLIBTOP_NCPU][N_CPU_STATES];
+        } cpu;
+
+        struct {
+            guint64 last_in, last_out;
+#if GLIB_CHECK_VERSION(2,61,2)
+            gint64 time;
+#else
+            GTimeVal time;
+#endif
+            guint64 max;
+            unsigned values[NUM_POINTS];
+            size_t cur;
+        } net;
+    /* }; */
+};
+
+/* Force a drawing update */
+void
+load_graph_queue_draw (LoadGraph *g);
+
+/* Start load graph. */
+void
+load_graph_start (LoadGraph *g);
+
+/* Stop load graph. */
+void
+load_graph_stop (LoadGraph *g);
+
+/* Change load graph speed and restart it if it has been previously started */
+void
+load_graph_change_speed (LoadGraph *g,
+                         guint new_speed);
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+#endif /* _PROCMAN_LOAD_GRAPH_H_ */
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/3.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/3.html new file mode 100644 index 00000000..e0d59e5d --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/3.html @@ -0,0 +1,645 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
#include <config.h>
+
+#include <cstring>
+#include <glib/gi18n.h>
+
+#include "cgroups.h"
+#include "util.h"
+
+gboolean
+cgroups_enabled(void)
+{
+    static gboolean initialized = FALSE;
+    static gboolean has_cgroups;
+
+    if (!initialized) {
+        initialized = TRUE;
+        has_cgroups = g_file_test("/proc/cgroups", G_FILE_TEST_EXISTS);
+    }
+
+    return has_cgroups;
+}
+
+static void
+append_cgroup_name(char *line, gchar **current_cgroup_name)
+{
+    gchar *controller, *path, *tmp, *path_plus_space;
+    int paren_offset, off, tmp_size;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return;
+
+    *(path - 1) = '\0';
+    g_strdelimit(controller, ",", '/');
+
+    if ((std::strcmp(path, "/") == 0) || (std::strncmp(controller, "name=", 5) == 0))
+        return;
+
+    if (*current_cgroup_name == NULL) {
+        *current_cgroup_name = g_strdup_printf("%s (%s)", path, controller);
+        return;
+    }
+
+    /* add a space to the end of the path string */
+    path_plus_space = g_strdup_printf("%s ", path);
+
+    if ((tmp = g_strstr_len(*current_cgroup_name, -1, path_plus_space))) {
+        tmp_size = strlen(*current_cgroup_name) + strlen(controller) + 1;
+        paren_offset = g_strstr_len(tmp + strlen(path), -1, ")") - *current_cgroup_name;
+        *(*current_cgroup_name + paren_offset) = '\0';
+        tmp = (gchar *)g_strnfill(tmp_size, '\0');
+        off = g_strlcat(tmp, *current_cgroup_name, tmp_size);
+        *(tmp + off) = '/';
+        off++;
+        off += g_strlcat(tmp + off, controller, tmp_size);
+        *(tmp + off) = ')';
+        off++;
+        g_strlcat(tmp + off, *current_cgroup_name + paren_offset + 1, tmp_size);
+    } else
+        tmp = g_strdup_printf("%s, %s(%s)", *current_cgroup_name, path_plus_space, controller);
+
+    g_free(path_plus_space);
+    g_free(*current_cgroup_name);
+    *current_cgroup_name = tmp;
+}
+
+static int
+check_cgroup_changed(gchar *line, gchar *current_cgroup_set)
+{
+    /* check if line is contained in current_cgroup_set */
+    gchar *controller, *path, *tmp, *found, *close_paren, *open_paren;
+    int ret = 0;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return 1;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return 1;
+
+    *(path - 1) = '\0';
+
+    if (std::strncmp(controller, "name=", 5) == 0)
+        goto out;
+
+    /* if there are multiple controllers just report string has changed */
+    if (g_strstr_len(controller, -1, ",")) {
+        ret = 1;
+        goto out;
+    }
+
+    if (!current_cgroup_set) {
+        if (std::strcmp(path, "/") != 0)
+            ret = 1;
+        goto out;
+    }
+
+    /* special case for root cgroup */
+    tmp = current_cgroup_set;
+    if (std::strcmp(path, "/") == 0) {
+        while ((found = g_strstr_len(tmp, -1, controller))) {
+            close_paren = g_strstr_len(found, -1, ")");
+            open_paren = g_strstr_len(found, -1, "(");
+            if (close_paren) {
+                if (!open_paren || (close_paren < open_paren)) {
+                    ret = 1;
+                    goto out;
+                }
+            }
+            tmp = found + strlen(controller);
+        }
+        goto out;
+    }
+
+    tmp = current_cgroup_set;
+    while ((found = g_strstr_len(tmp, -1, path))) {
+            found = found + strlen(path);
+            close_paren = g_strstr_len(found, -1, ")");
+            if (*found == ' ') {
+                if (g_strstr_len(found + 1, close_paren - found, controller))
+                    goto out;
+            }
+            tmp = close_paren + 1;
+    }
+    ret = 1;
+out:
+    *(path - 1) = ':';
+    return ret;
+}
+
+void
+get_process_cgroup_info(ProcInfo *info)
+{
+    gchar *path;
+    gchar *cgroup_name = NULL;
+    int cgroups_changed = 0;
+    gchar *text;
+    char **lines;
+    int i;
+
+    if (!cgroups_enabled())
+        return;
+
+    /* read out of /proc/pid/cgroup */
+    path = g_strdup_printf("/proc/%d/cgroup", info->pid);
+    if (!path)
+        return;
+    if(!g_file_get_contents(path, &text, NULL, NULL))
+        goto out;
+    lines = g_strsplit(text, "\n", -1);
+    g_free(text);
+    if (!lines)
+        goto out;
+
+    for (i = 0; lines[i] != NULL; i++) {
+        if (lines[i][0] == '\0')
+            continue;
+        if (check_cgroup_changed(lines[i], info->cgroup_name)) {
+            cgroups_changed = 1;
+            break;
+        }
+    }
+
+    if (cgroups_changed) {
+        for (i = 0; lines[i] != NULL; i++) {
+            if (lines[i][0] == '\0')
+                continue;
+            append_cgroup_name(lines[i], &cgroup_name);
+        }
+        if (info->cgroup_name)
+            g_free(info->cgroup_name);
+        if (!cgroup_name)
+            info->cgroup_name = g_strdup("");
+        else
+            info->cgroup_name = cgroup_name;
+    }
+
+    g_strfreev(lines);
+out:
+    g_free(path);
+}
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/4.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/4.html new file mode 100644 index 00000000..cc9dbf88 --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/4.html @@ -0,0 +1,1277 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
#include <config.h>
+
+#ifdef __linux__
+#include <mntent.h>
+#endif // __linux__
+
+#include <giomm.h>
+#include <giomm/themedicon.h>
+#include <gtk/gtk.h>
+#include <glibtop/mountlist.h>
+#include <glibtop/fsusage.h>
+#include <glib/gi18n.h>
+
+#include "procman.h"
+#include "disks.h"
+#include "util.h"
+#include "interface.h"
+#include "iconthemewrapper.h"
+
+namespace
+{
+  const unsigned DISK_ICON_SIZE = 24;
+}
+
+enum DiskColumns
+{
+    /* string columns* */
+    DISK_DEVICE,
+    DISK_DIR,
+    DISK_TYPE,
+    DISK_SUBVOLUME,
+    DISK_TOTAL,
+    DISK_FREE,
+    DISK_AVAIL,
+    /* USED has to be the last column */
+    DISK_USED,
+    // then unvisible columns
+    /* Surface column */
+    DISK_ICON,
+    /* numeric columns */
+    DISK_USED_PERCENTAGE,
+    DISK_N_COLUMNS
+};
+
+
+
+static void
+fsusage_stats(const glibtop_fsusage *buf,
+              guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
+              gint *percentage)
+{
+    guint64 total = buf->blocks * buf->block_size;
+
+    if (!total) {
+        /* not a real device */
+        *btotal = *bfree = *bavail = *bused = 0ULL;
+        *percentage = 0;
+    } else {
+        int percent;
+        *btotal = total;
+        *bfree = buf->bfree * buf->block_size;
+        *bavail = buf->bavail * buf->block_size;
+        *bused = *btotal - *bfree;
+        /* percent = 100.0f * *bused / *btotal; */
+        percent = 100 * *bused / (*bused + *bavail);
+        *percentage = CLAMP(percent, 0, 100);
+    }
+}
+
+
+namespace
+{
+    string get_icon_for_path(const std::string& path)
+    {
+        using namespace Glib;
+        using namespace Gio;
+
+        // FIXME: I don't know whether i should use Volume or Mount or UnixMount
+        // all i need an icon name.
+        RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+        std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
+
+        for (size_t i = 0; i != mounts.size(); ++i) {
+            if (mounts[i]->get_name() != path)
+                continue;
+
+            RefPtr<Icon> icon = mounts[i]->get_icon();
+            RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
+
+            if (themed_icon) {
+                char* name = 0;
+                // FIXME: not wrapped yet
+                g_object_get(G_OBJECT(themed_icon->gobj()), "name", &name, NULL);
+                return make_string(name);
+            }
+        }
+
+        return "";
+    }
+}
+
+
+static Glib::RefPtr<Gdk::Pixbuf>
+get_icon_for_device(const char *mountpoint)
+{
+    procman::IconThemeWrapper icon_theme;
+    string icon_name = get_icon_for_path(mountpoint);
+    if (icon_name == "")
+        // FIXME: defaults to a safe value
+        icon_name = "drive-harddisk"; // get_icon_for_path("/");
+    return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
+}
+
+
+static gboolean
+find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
+                   GtkTreeIter *result)
+{
+    GtkTreeIter iter;
+    gboolean found = FALSE;
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        do {
+            char *dir;
+
+            gtk_tree_model_get(model, &iter,
+                               DISK_DIR, &dir,
+                               -1);
+
+            if (dir && !strcmp(dir, mountpoint)) {
+                *result = iter;
+                found = TRUE;
+            }
+
+            g_free(dir);
+
+        } while (!found && gtk_tree_model_iter_next(model, &iter));
+    }
+
+    return found;
+}
+
+
+
+static void
+remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
+{
+    GtkTreeIter iter;
+
+    if (!gtk_tree_model_get_iter_first(model, &iter))
+        return;
+
+    while (true) {
+        char *dir;
+        guint i;
+        gboolean found = FALSE;
+
+        gtk_tree_model_get(model, &iter,
+                           DISK_DIR, &dir,
+                           -1);
+
+        for (i = 0; i != n; ++i) {
+            if (!strcmp(dir, entries[i].mountdir)) {
+                found = TRUE;
+                break;
+            }
+        }
+
+        g_free(dir);
+
+        if (!found) {
+            if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                break;
+            else
+                continue;
+        }
+
+        if (!gtk_tree_model_iter_next(model, &iter))
+            break;
+    }
+}
+
+#ifdef __linux__
+static char *
+get_mount_opt(const glibtop_mountentry *entry, const char* opt)
+{
+    char *opt_value = NULL;
+    const struct mntent *mnt;
+    FILE *fp;
+
+    if (!(fp = setmntent(MOUNTED, "r"))) {
+        goto out;
+    }
+
+    while ((mnt = getmntent(fp))) {
+        if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
+            (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
+            char *res;
+
+            res = hasmntopt(mnt, "subvol");<--- res is assigned
+            if ((res = hasmntopt(mnt, "subvol")) != NULL) {<--- res is overwritten
+                char **strs = g_strsplit_set(res, "=", 2);
+
+                if (g_strv_length(strs) == 2) {
+                    char *value = strs[1];
+                    if (g_strcmp0 (value,"/root") == 0)
+                       opt_value = g_strdup("/");
+                    else
+                        opt_value = g_strdup(strs[1]);
+                    g_strfreev(strs);
+                }
+            }
+            break;
+        }
+    }
+
+    endmntent(fp);
+
+  out:
+     return opt_value;
+}
+#endif // __linux__
+
+
+static void
+add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
+{
+    Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+    cairo_surface_t *surface;
+    GtkTreeIter iter;
+    glibtop_fsusage usage;
+    guint64 bused, bfree, bavail, btotal;
+    gint percentage;
+#ifdef __linux__
+    char *subvol = NULL;
+#endif // __linux__
+
+    glibtop_get_fsusage(&usage, entry->mountdir);
+
+    if (not show_all_fs and usage.blocks == 0) {
+        if (find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+            gtk_list_store_remove(list, &iter);
+        return;
+    }
+
+    fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
+#ifdef __linux__
+    subvol = get_mount_opt(entry, "subvol");
+#endif // __linux__
+    pixbuf = get_icon_for_device(entry->mountdir);
+    surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL);
+
+    /* if we can find a row with the same mountpoint, we get it but we
+       still need to update all the fields.
+       This makes selection persistent.
+    */
+    if (!find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+        gtk_list_store_append(list, &iter);
+
+    gtk_list_store_set(list, &iter,
+                       DISK_ICON, surface,
+                       DISK_DEVICE, entry->devname,
+                       DISK_DIR, entry->mountdir,
+                       DISK_TYPE, entry->type,
+#ifdef __linux__
+
+                       DISK_SUBVOLUME, subvol != NULL ? subvol : "",
+#else
+                       DISK_SUBVOLUME, "",
+#endif // __linux__
+                       DISK_USED_PERCENTAGE, percentage,
+                       DISK_TOTAL, btotal,
+                       DISK_FREE, bfree,
+                       DISK_AVAIL, bavail,
+                       DISK_USED, bused,
+                       -1);
+#ifdef __linux__
+    g_free (subvol);
+#endif // __linux__
+}
+
+
+
+int
+cb_update_disks(gpointer data)
+{
+    ProcData *const procdata = static_cast<ProcData*>(data);
+
+    GtkListStore *list;
+    glibtop_mountentry * entries;
+    glibtop_mountlist mountlist;
+    guint i;
+
+    list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)));
+
+    entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
+
+    remove_old_disks(GTK_TREE_MODEL(list), entries, mountlist.number);
+
+    for (i = 0; i < mountlist.number; i++)
+        add_disk(list, &entries[i], procdata->config.show_all_fs);
+
+    g_free(entries);
+
+    return TRUE;
+}
+
+
+static void
+cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "disktreenew");
+}
+
+
+static void
+open_dir(GtkTreeView       *tree_view,
+         GtkTreePath       *path,
+         GtkTreeViewColumn *column,
+         gpointer           user_data)
+{
+    GtkTreeIter iter;
+    GtkTreeModel *model;
+    char *dir, *url;
+
+    model = gtk_tree_view_get_model(tree_view);
+
+    if (!gtk_tree_model_get_iter(model, &iter, path)) {
+        char *p;
+        p = gtk_tree_path_to_string(path);
+        g_warning("Cannot get iter for path '%s'\n", p);
+        g_free(p);
+        return;
+    }
+
+    gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
+
+    url = g_strdup_printf("file://%s", dir);
+
+    GError* error = 0;
+    if (!g_app_info_launch_default_for_uri(url, NULL, &error)) {
+        g_warning("Cannot open '%s' : %s\n", url, error->message);
+        g_error_free(error);
+    }
+
+    g_free(url);
+    g_free(dir);
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "disktreenew");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+void
+create_disk_view(ProcData *procdata, GtkBuilder *builder)
+{
+    GtkWidget *scrolled;
+    GtkWidget *disk_tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *col;
+    GtkCellRenderer *cell;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Device"),
+        N_("Directory"),
+        N_("Type"),
+        N_("SubVolume"),
+        N_("Total"),
+        N_("Free"),
+        N_("Available"),
+        N_("Used")
+    };
+
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"));
+
+    model = gtk_list_store_new(DISK_N_COLUMNS,             /* n columns */
+                               G_TYPE_STRING,              /* DISK_DEVICE */
+                               G_TYPE_STRING,              /* DISK_DIR */
+                               G_TYPE_STRING,              /* DISK_TYPE */
+                               G_TYPE_STRING,              /* DISK_SUBVOLUME */
+                               G_TYPE_UINT64,              /* DISK_TOTAL */
+                               G_TYPE_UINT64,              /* DISK_FREE */
+                               G_TYPE_UINT64,              /* DISK_AVAIL */
+                               G_TYPE_UINT64,              /* DISK_USED */
+                               CAIRO_GOBJECT_TYPE_SURFACE, /* DISK_ICON */
+                               G_TYPE_INT);                /* DISK_USED_PERCENTAGE */
+
+    disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL);
+    procdata->disk_list = disk_tree;
+    gtk_container_add(GTK_CONTAINER(scrolled), disk_tree);
+    g_object_unref(G_OBJECT(model));
+
+    /* icon + device */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
+                                        NULL);
+
+    cell = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
+                                        NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 30);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* sizes - used */
+
+    for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_min_width (col, 30);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+        switch (i) {
+            case DISK_TOTAL:
+            case DISK_FREE:
+            case DISK_AVAIL:
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+        default:
+            gtk_tree_view_column_set_attributes(col, cell,
+                                                "text", i,
+                                                NULL);
+            break;
+        }
+    }
+
+    /* used + percentage */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_text_new();
+    g_object_set(cell, "xalign", 1.0f, NULL);
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_cell_data_func(col, cell,
+                                            &procman::storage_size_cell_data_func,
+                                            GUINT_TO_POINTER(DISK_USED),
+                                            NULL);
+
+    cell = gtk_cell_renderer_progress_new();
+    gtk_tree_view_column_pack_start(col, cell, TRUE);
+    gtk_tree_view_column_set_attributes(col, cell, "value",
+                                        DISK_USED_PERCENTAGE, NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_USED]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 150);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* numeric sort */
+
+    procman_get_tree_state(procdata->settings, disk_tree,
+                   "disktreenew");
+
+    g_signal_connect (G_OBJECT(disk_tree), "columns-changed",
+                      G_CALLBACK(cb_disk_columns_changed), procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/5.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/5.html new file mode 100644 index 00000000..17de817b --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/5.html @@ -0,0 +1,2141 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
+852
+853
+854
+855
+856
+857
+858
+859
+860
+861
+862
+863
+864
+865
+866
+867
+868
+869
+870
+871
+872
+873
+874
+875
+876
+877
+878
+879
+880
+881
+882
+883
+884
+885
+886
+887
+888
+889
+890
+891
+892
+893
+894
+895
+896
+897
+898
+899
+900
+901
+902
+903
+904
+905
+906
+907
+908
+909
+910
+911
+912
+913
+914
+915
+916
+917
+918
+919
+920
+921
+922
+923
+924
+925
+926
+927
+928
+929
+930
+931
+932
+933
+934
+935
+936
+937
+938
+939
+940
+941
+942
+943
+944
+945
+946
/*
+ * Mate system monitor color pickers
+ * Copyright (C) 2007 Karl Lattimer <karl@qdh.org.uk>
+ * Copyright (C) 2012-2021 MATE Developers
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with the software; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <gdk/gdkkeysyms.h>
+#include <math.h>
+#include <cairo.h>
+#include <librsvg/rsvg.h>
+
+#include "gsm_color_button.h"
+
+typedef struct {
+    GtkWidget *cc_dialog;		/* Color chooser dialog */
+
+    gchar *title;            /* Title for the color selection window */
+
+    GdkRGBA color;
+
+    gdouble fraction;        /* Only used by GSMCP_TYPE_PIE */
+    guint type;
+    cairo_surface_t *image_buffer;
+    gdouble highlight;
+    gboolean button_down;
+    gboolean in_button;
+} GSMColorButtonPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GSMColorButton, gsm_color_button, GTK_TYPE_DRAWING_AREA)
+
+/* Properties */
+enum
+{
+    PROP_0,
+    PROP_PERCENTAGE,
+    PROP_TITLE,
+    PROP_COLOR,
+    PROP_TYPE
+};
+
+/* Signals */
+enum
+{
+    COLOR_SET,
+    LAST_SIGNAL
+};
+
+#define GSMCP_MIN_WIDTH 15
+#define GSMCP_MIN_HEIGHT 15
+
+static void gsm_color_button_finalize (GObject * object);
+static void gsm_color_button_set_property (GObject * object, guint param_id,
+                                           const GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_get_property (GObject * object, guint param_id,
+                                           GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_realize (GtkWidget * widget);
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width);
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height);
+static void gsm_color_button_size_allocate (GtkWidget * widget,
+                                            GtkAllocation * allocation);
+static void gsm_color_button_unrealize (GtkWidget * widget);
+static void gsm_color_button_state_changed (GtkWidget * widget,
+                                            GtkStateType previous_state);
+static void gsm_color_button_style_set (GtkWidget * widget,
+                                        GtkStyle * previous_style);
+static gint gsm_color_button_pressed (GtkWidget * widget,
+                                      GdkEventButton * event);
+static gint gsm_color_button_released (GtkWidget * widget,
+                                       GdkEventButton * event);
+static gboolean gsm_color_button_enter_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+static gboolean gsm_color_button_leave_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+/* source side drag signals */
+static void gsm_color_button_drag_begin (GtkWidget * widget,
+                                         GdkDragContext * context,
+                                         gpointer data);
+static void gsm_color_button_drag_data_get (GtkWidget * widget,
+                                            GdkDragContext * context,
+                                            GtkSelectionData * selection_data,
+                                            guint info, guint time,
+                                            GSMColorButton * color_button);
+
+/* target side drag signals */
+static void gsm_color_button_drag_data_received (GtkWidget * widget,
+                                                 GdkDragContext * context,
+                                                 gint x,
+                                                 gint y,
+                                                 GtkSelectionData *
+                                                 selection_data, guint info,
+                                                 guint32 time,
+                                                 GSMColorButton *
+                                                 color_button);
+
+static guint color_button_signals[LAST_SIGNAL] = { 0 };
+
+static const GtkTargetEntry drop_types[] = { {"application/x-color", 0, 0} };
+
+static void
+gsm_color_button_class_init (GSMColorButtonClass * klass)
+{
+    GObjectClass *gobject_class;
+    GtkWidgetClass *widget_class;
+
+    gobject_class = G_OBJECT_CLASS (klass);
+    widget_class = GTK_WIDGET_CLASS (klass);
+
+    gobject_class->get_property = gsm_color_button_get_property;
+    gobject_class->set_property = gsm_color_button_set_property;
+    gobject_class->finalize = gsm_color_button_finalize;
+    widget_class->state_changed = gsm_color_button_state_changed;
+    widget_class->get_preferred_width = gsm_color_button_get_preferred_width;
+    widget_class->get_preferred_height = gsm_color_button_get_preferred_height;
+    widget_class->size_allocate = gsm_color_button_size_allocate;
+    widget_class->realize = gsm_color_button_realize;
+    widget_class->unrealize = gsm_color_button_unrealize;
+    widget_class->style_set = gsm_color_button_style_set;
+    widget_class->button_release_event = gsm_color_button_released;
+    widget_class->button_press_event = gsm_color_button_pressed;
+    widget_class->enter_notify_event = gsm_color_button_enter_notify;
+    widget_class->leave_notify_event = gsm_color_button_leave_notify;
+
+    klass->color_set = NULL;
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_PERCENTAGE,
+                                     g_param_spec_double ("fraction",
+                                                          _("Fraction"),
+                                     // TRANSLATORS: description of the pie color picker's (mem, swap) filled percentage property
+                                                          _("Percentage full for pie color pickers"),
+                                                          0, 1, 0.5,
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TITLE,
+                                     g_param_spec_string ("title",
+                                                          _("Title"),
+                                                          _("The title of the color selection dialog"),
+                                                          _("Pick a Color"),
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_COLOR,
+                                     g_param_spec_boxed ("color",
+                                                         _("Current Color"),
+                                                         _("The selected color"),
+                                                         GDK_TYPE_RGBA,
+                                                         G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TYPE,
+                                     g_param_spec_uint ("type", _("Type"),
+                                                        _("Type of color picker"),
+                                                        0, 4, 0,
+                                                        G_PARAM_READWRITE));
+
+    color_button_signals[COLOR_SET] = g_signal_new ("color_set",
+                                                    G_TYPE_FROM_CLASS
+                                                    (gobject_class),
+                                                    G_SIGNAL_RUN_FIRST,
+                                                    G_STRUCT_OFFSET
+                                                    (GSMColorButtonClass,
+                                                    color_set), NULL, NULL,
+                                                    g_cclosure_marshal_VOID__VOID,
+                                                    G_TYPE_NONE, 0);
+
+}
+
+static cairo_surface_t *
+fill_image_buffer_from_file (cairo_t *cr, const char *filePath)
+{
+    GError *error = NULL;
+    RsvgHandle *handle;
+    cairo_surface_t *tmp_surface;
+    cairo_t *tmp_cr;
+
+    handle = rsvg_handle_new_from_file (filePath, &error);
+
+    if (handle == NULL) {
+        g_warning("rsvg_handle_new_from_file(\"%s\") failed: %s",
+              filePath, (error ? error->message : "unknown error"));
+    if (error)
+          g_error_free(error);
+    return NULL;
+    }
+
+    tmp_surface = cairo_surface_create_similar (cairo_get_target (cr),
+                                                CAIRO_CONTENT_COLOR_ALPHA,
+                                                32, 32);
+    tmp_cr = cairo_create (tmp_surface);
+    rsvg_handle_render_cairo (handle, tmp_cr);
+    cairo_destroy (tmp_cr);
+    g_object_unref (handle);
+    return tmp_surface;
+}
+
+static void
+render (GtkWidget * widget)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GdkRGBA *color;
+    GdkRGBA tmp_color = priv->color;
+    color = &tmp_color;
+    cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
+    cairo_path_t *path = NULL;
+    gint width, height;
+    gdouble radius, arc_start, arc_end;
+    gdouble highlight_factor;
+
+    if (priv->highlight > 0) {
+        highlight_factor = 0.125 * priv->highlight;
+
+    if (color->red + highlight_factor > 1.0)
+        color->red = 1.0;
+    else
+        color->red = color->red + highlight_factor;
+
+    if (color->blue + highlight_factor > 1.0)
+        color->blue = 1.0;
+    else
+      color->blue = color->blue + highlight_factor;
+
+    if (color->green + highlight_factor > 1.0)
+        color->green = 1.0;
+    else
+        color->green = color->green + highlight_factor;
+    }
+    gdk_cairo_set_source_rgba (cr, color);
+
+    width = gdk_window_get_width(gtk_widget_get_window(widget));
+    height = gdk_window_get_height(gtk_widget_get_window(widget));
+
+    switch (priv->type)
+        {
+        case GSMCP_TYPE_CPU:
+            //gtk_widget_set_size_request (widget, GSMCP_MIN_WIDTH, GSMCP_MIN_HEIGHT);
+            cairo_paint (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1);
+            cairo_stroke (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.4);
+            cairo_rectangle (cr, 1.5, 1.5, width - 3, height - 3);
+            cairo_stroke (cr);
+            break;
+        case GSMCP_TYPE_PIE:
+            if (width < 32)        // 32px minimum size
+                gtk_widget_set_size_request (widget, 32, 32);
+            if (width < height)
+                radius = width / 2;
+            else
+                radius = height / 2;
+
+            arc_start = -G_PI_2 + 2 * G_PI * priv->fraction;
+            arc_end = -G_PI_2;
+
+            cairo_set_line_width (cr, 1);
+
+            // Draw external stroke and fill
+            if (priv->fraction < 0.01) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_end);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    arc_end, arc_start);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_start);
+            }
+            cairo_fill_preserve (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.7);
+            cairo_stroke (cr);
+
+            // Draw internal highlight
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.45);
+            cairo_set_line_width (cr, 1);
+
+            if (priv->fraction < 0.03) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_end - (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    arc_end - (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+            }
+            cairo_stroke (cr);
+
+            // Draw external shape
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.2);
+            cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 1.25, 0,
+                G_PI * 2);
+            cairo_stroke (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_IN:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                    fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/download.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 8.5, 1.5);
+            cairo_line_to (cr, 23.5, 1.5);
+            cairo_line_to (cr, 23.5, 11.5);
+            cairo_line_to (cr, 29.5, 11.5);
+            cairo_line_to (cr, 16.5, 27.5);
+            cairo_line_to (cr, 15.5, 27.5);
+            cairo_line_to (cr, 2.5, 11.5);
+            cairo_line_to (cr, 8.5, 11.5);
+            cairo_line_to (cr, 8.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_OUT:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/upload.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 16.5, 1.5);
+            cairo_line_to (cr, 29.5, 17.5);
+            cairo_line_to (cr, 23.5, 17.5);
+            cairo_line_to (cr, 23.5, 27.5);
+            cairo_line_to (cr, 8.5, 27.5);
+            cairo_line_to (cr, 8.5, 17.5);
+            cairo_line_to (cr, 2.5, 17.5);
+            cairo_line_to (cr, 15.5, 1.5);
+            cairo_line_to (cr, 16.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        }
+    cairo_destroy (cr);
+}
+
+/* Handle exposure events for the color picker's drawing area */
+static gboolean draw (GtkWidget * widget, cairo_t * cr, gpointer data)
+{
+    render (GTK_WIDGET (data));
+
+    return FALSE;
+}
+
+static void
+gsm_color_button_realize (GtkWidget * widget)
+{
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->realize (widget);
+    render (widget);
+}
+
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width)
+{
+    g_return_if_fail (widget != NULL && minimum_width != NULL && natural_width != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_width = GSMCP_MIN_WIDTH;
+    *natural_width = GSMCP_MIN_WIDTH;
+}
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height)
+{
+    g_return_if_fail (widget != NULL && minimum_height != NULL && natural_height != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_height = GSMCP_MIN_HEIGHT;
+    *natural_height = GSMCP_MIN_HEIGHT;
+}
+
+static void
+gsm_color_button_size_allocate (GtkWidget * widget,
+                                GtkAllocation * allocation)
+{
+    g_return_if_fail (widget != NULL || allocation != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    gtk_widget_set_allocation (widget, allocation);
+
+    if (gtk_widget_get_realized (widget))
+    {
+        gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y,
+                                allocation->width, allocation->height);
+    }
+}
+
+static void
+gsm_color_button_unrealize (GtkWidget * widget)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->unrealize (widget);
+}
+
+static void
+gsm_color_button_style_set (GtkWidget * widget, GtkStyle * previous_style)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->style_set (widget,
+                                                                 previous_style);
+
+}
+
+static void
+gsm_color_button_state_changed (GtkWidget * widget,
+                                GtkStateType previous_state)
+{
+}
+
+static void
+gsm_color_button_drag_data_received (GtkWidget * widget,
+                                     GdkDragContext * context,
+                                     gint x,
+                                     gint y,
+                                     GtkSelectionData * selection_data,
+                                     guint info,
+                                     guint32 time,
+                                     GSMColorButton * color_button)
+{
+    gint length;
+    guint16 *dropped;
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    length = gtk_selection_data_get_length (selection_data);
+
+    if (length < 0)
+        return;
+
+    /* We accept drops with the wrong format, since the KDE color
+     * chooser incorrectly drops application/x-color with format 8.
+     */
+    if (length != 8)
+    {
+        g_warning (_("Received invalid color data\n"));
+        return;
+    }
+
+    dropped = (guint16 *) gtk_selection_data_get_data (selection_data);
+
+    priv->color.red =   ((double) dropped[0]) / 65535.0;
+    priv->color.green = ((double) dropped[1]) / 65535.0;
+    priv->color.blue =  ((double) dropped[2]) / 65535.0;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+    g_object_freeze_notify (G_OBJECT (color_button));
+    g_object_notify (G_OBJECT (color_button), "color");
+    g_object_thaw_notify (G_OBJECT (color_button));
+}
+
+static void
+set_color_icon (GdkDragContext * context, GdkRGBA * color)
+{
+    GdkPixbuf *pixbuf;
+    guint32 pixel;
+
+    pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 48, 32);
+
+    pixel = ((guint32)(color->red * 0xff) << 24) |
+            ((guint32)(color->green * 0xff) << 16) |
+            ((guint32)(color->blue * 0xff) << 8);
+
+    gdk_pixbuf_fill (pixbuf, pixel);
+
+    gtk_drag_set_icon_pixbuf (context, pixbuf, -2, -2);
+    g_object_unref (pixbuf);
+}
+
+static void
+gsm_color_button_drag_begin (GtkWidget * widget,
+                             GdkDragContext * context, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = data;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    set_color_icon (context, &priv->color);
+}
+
+static void
+gsm_color_button_drag_data_get (GtkWidget * widget,
+                                GdkDragContext * context,
+                                GtkSelectionData * selection_data,
+                                guint info,
+                                guint time, GSMColorButton * color_button)
+{
+    guint16 dropped[4];
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    dropped[0] = (guint16) (65535.0 * priv->color.red);
+    dropped[1] = (guint16) (65535.0 * priv->color.green);
+    dropped[2] = (guint16) (65535.0 * priv->color.blue);
+    dropped[3] = 65535;        // This widget doesn't care about alpha
+
+    gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data),
+                            16, (guchar *) dropped, 8);
+}
+
+static void
+gsm_color_button_init (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = 0;
+    priv->color.green = 0;
+    priv->color.blue = 0;
+    priv->fraction = 0.5;
+    priv->type = GSMCP_TYPE_CPU;
+    priv->image_buffer = NULL;
+    priv->title = g_strdup (_("Pick a Color"));     /* default title */
+    priv->in_button = FALSE;
+    priv->button_down = FALSE;
+
+    gtk_drag_dest_set (GTK_WIDGET (color_button),
+                       GTK_DEST_DEFAULT_MOTION |
+                       GTK_DEST_DEFAULT_HIGHLIGHT |
+                       GTK_DEST_DEFAULT_DROP, drop_types, 1, GDK_ACTION_COPY);
+    gtk_drag_source_set (GTK_WIDGET (color_button),
+                         GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
+                         drop_types, 1, GDK_ACTION_COPY);
+    g_signal_connect (color_button, "drag_begin",
+                      G_CALLBACK (gsm_color_button_drag_begin), color_button);
+    g_signal_connect (color_button, "drag_data_received",
+                      G_CALLBACK (gsm_color_button_drag_data_received),
+                      color_button);
+    g_signal_connect (color_button, "drag_data_get",
+                      G_CALLBACK (gsm_color_button_drag_data_get),
+                      color_button);
+
+    gtk_widget_add_events (GTK_WIDGET(color_button), GDK_ENTER_NOTIFY_MASK
+                              | GDK_LEAVE_NOTIFY_MASK);
+
+    gtk_widget_set_tooltip_text (GTK_WIDGET(color_button), _("Click to set graph colors"));
+
+    g_signal_connect (color_button, "draw", G_CALLBACK (draw), color_button);
+}
+
+static void
+gsm_color_button_finalize (GObject * object)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    if (priv->cc_dialog != NULL)
+        gtk_widget_destroy (priv->cc_dialog);
+    priv->cc_dialog = NULL;
+
+    g_free (priv->title);
+    priv->title = NULL;
+
+    cairo_surface_destroy (priv->image_buffer);
+    priv->image_buffer = NULL;
+
+    G_OBJECT_CLASS (gsm_color_button_parent_class)->finalize (object);
+}
+
+GtkWidget *
+gsm_color_button_new (const GdkRGBA * color, guint type)
+{
+    return g_object_new (GSM_TYPE_COLOR_BUTTON, "color", color, "type", type,
+                         NULL);
+}
+
+static void
+dialog_response (GtkWidget * widget, GtkResponseType response, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GtkColorChooser *color_chooser;
+
+    if (response == GTK_RESPONSE_OK) {
+        color_chooser = GTK_COLOR_CHOOSER (priv->cc_dialog);
+
+        gtk_color_chooser_get_rgba (color_chooser, &priv->color);
+
+        gtk_widget_hide (priv->cc_dialog);
+
+        gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+        g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+        g_object_freeze_notify (G_OBJECT (color_button));
+        g_object_notify (G_OBJECT (color_button), "color");
+        g_object_thaw_notify (G_OBJECT (color_button));
+    }
+    else  /* (response == GTK_RESPONSE_CANCEL) */
+        gtk_widget_hide (priv->cc_dialog);
+}
+
+static gboolean
+dialog_destroy (GtkWidget * widget, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->cc_dialog = NULL;
+
+    return FALSE;
+}
+
+static gint
+gsm_color_button_clicked (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    /* if dialog already exists, make sure it's shown and raised */
+    if (!priv->cc_dialog)
+    {
+        /* Create the dialog and connects its buttons */
+        GtkWidget *cc_dialog;
+        GtkWidget *parent;
+
+        parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));
+        if (!gtk_widget_is_toplevel (parent))
+            parent = NULL;
+
+        cc_dialog = gtk_color_chooser_dialog_new (priv->title, GTK_WINDOW (parent));
+
+        gtk_window_set_modal (GTK_WINDOW (cc_dialog), TRUE);
+
+        g_signal_connect (cc_dialog, "response",
+                          G_CALLBACK (dialog_response), color_button);
+
+        g_signal_connect (cc_dialog, "destroy",
+                          G_CALLBACK (dialog_destroy), color_button);
+
+        priv->cc_dialog = cc_dialog;
+    }
+
+    gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (priv->cc_dialog),
+                                &priv->color);
+
+    gtk_window_present (GTK_WINDOW (priv->cc_dialog));
+
+    return 0;
+}
+
+static gint
+gsm_color_button_pressed (GtkWidget * widget, GdkEventButton * event)
+{
+    if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) )
+    {
+	GSMColorButtonPrivate *priv;
+        GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+	priv = gsm_color_button_get_instance_private (color_button);
+	priv->button_down = TRUE;
+    }
+  return 0;
+}
+
+static gint
+gsm_color_button_released (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    if (priv->button_down && priv->in_button)
+        gsm_color_button_clicked (widget, event);
+    priv->button_down = FALSE;
+    return 0;
+}
+
+static gboolean
+gsm_color_button_enter_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 1.0;
+    priv->in_button = TRUE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+static gboolean
+gsm_color_button_leave_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 0;
+    priv->in_button = FALSE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+guint
+gsm_color_button_get_cbtype (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->type;
+}
+
+void
+gsm_color_button_set_cbtype (GSMColorButton * color_button, guint type)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->type = type;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "type");
+}
+
+gdouble
+gsm_color_button_get_fraction (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->fraction;
+}
+
+void
+gsm_color_button_set_fraction (GSMColorButton * color_button,
+                               gdouble fraction)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->fraction = fraction;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "fraction");
+}
+
+void
+gsm_color_button_get_color (GSMColorButton * color_button, GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    color->red = priv->color.red;
+    color->green = priv->color.green;
+    color->blue = priv->color.blue;
+    color->alpha = priv->color.alpha;
+}
+
+void
+gsm_color_button_set_color (GSMColorButton * color_button,
+                            const GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    g_return_if_fail (color != NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = color->red;
+    priv->color.green = color->green;
+    priv->color.blue = color->blue;
+    priv->color.alpha = color->alpha;
+
+    gtk_widget_queue_draw (GTK_WIDGET (color_button));
+
+    g_object_notify (G_OBJECT (color_button), "color");
+}
+
+void
+gsm_color_button_set_title (GSMColorButton * color_button,
+                            const gchar * title)
+{
+    gchar *old_title;
+    GSMColorButtonPrivate *priv;
+
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    old_title = priv->title;
+    priv->title = g_strdup (title);
+    g_free (old_title);
+
+    if (priv->cc_dialog)
+        gtk_window_set_title (GTK_WINDOW (priv->cc_dialog),
+                              priv->title);
+
+    g_object_notify (G_OBJECT (color_button), "title");
+}
+
+const gchar* gsm_color_button_get_title(GSMColorButton* color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail(GSM_IS_COLOR_BUTTON(color_button), NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->title;
+}
+
+static void
+gsm_color_button_set_property (GObject * object,
+                               guint param_id,
+                               const GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            gsm_color_button_set_fraction (color_button,
+                                           g_value_get_double (value));
+            break;
+        case PROP_TITLE:
+            gsm_color_button_set_title (color_button, g_value_get_string (value));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_set_color (color_button, g_value_get_boxed (value));
+            break;
+        case PROP_TYPE:
+            gsm_color_button_set_cbtype (color_button, g_value_get_uint (value));
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+static void
+gsm_color_button_get_property (GObject * object,
+                               guint param_id,
+                               GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+    GdkRGBA color;
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            g_value_set_double (value,
+                                gsm_color_button_get_fraction (color_button));
+            break;
+        case PROP_TITLE:
+            g_value_set_string (value, gsm_color_button_get_title (color_button));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_get_color (color_button, &color);
+                                        g_value_set_boxed (value, &color);
+            break;
+        case PROP_TYPE:
+            g_value_set_uint (value, gsm_color_button_get_cbtype (color_button));
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/6.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/6.html new file mode 100644 index 00000000..f73c90ba --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/6.html @@ -0,0 +1,1599 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
/* Procman - main window
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <gdk/gdkkeysyms.h>
+#include <math.h>
+
+#include "procman.h"
+#include "callbacks.h"
+#include "interface.h"
+#include "proctable.h"
+#include "procactions.h"
+#include "load-graph.h"
+#include "util.h"
+#include "disks.h"
+#include "sysinfo.h"
+#include "gsm_color_button.h"
+
+static void    cb_toggle_tree (GtkAction *action, gpointer data);
+static void    cb_proc_goto_tab (gint tab);
+
+static const GtkActionEntry menu_entries[] =
+{
+    // xgettext: noun, top level menu.
+    // "File" did not make sense for system-monitor
+    { "Monitor", NULL, N_("_Monitor") },
+    { "Edit", NULL, N_("_Edit") },
+    { "View", NULL, N_("_View") },
+    { "Help", NULL, N_("_Help") },
+
+    { "Lsof", "edit-find", N_("Search for _Open Files"), "<control>O",
+      N_("Search for open files"), G_CALLBACK(cb_show_lsof) },
+    { "Quit", "application-exit", N_("_Quit"), "<control>Q",
+      N_("Quit the program"), G_CALLBACK (cb_app_exit) },
+
+
+    { "StopProcess", NULL, N_("_Stop Process"), "<control>S",
+      N_("Stop process"), G_CALLBACK(cb_kill_sigstop) },
+    { "ContProcess", NULL, N_("_Continue Process"), "<control>C",
+      N_("Continue process if stopped"), G_CALLBACK(cb_kill_sigcont) },
+
+    { "EndProcess", NULL, N_("_End Process"), "<control>E",
+      N_("Force process to finish normally"), G_CALLBACK (cb_end_process) },
+    { "KillProcess", NULL, N_("_Kill Process"), "<control>K",
+      N_("Force process to finish immediately"), G_CALLBACK (cb_kill_process) },
+    { "ChangePriority", NULL, N_("_Change Priority"), NULL,
+      N_("Change the order of priority of process"), NULL },
+    { "Preferences", "preferences-desktop", N_("_Preferences"), NULL,
+      N_("Configure the application"), G_CALLBACK (cb_edit_preferences) },
+
+    { "Refresh", "view-refresh", N_("_Refresh"), "<control>R",
+      N_("Refresh the process list"), G_CALLBACK(cb_user_refresh) },
+
+    { "MemoryMaps", NULL, N_("_Memory Maps"), "<control>M",
+      N_("Open the memory maps associated with a process"), G_CALLBACK (cb_show_memory_maps) },
+    // Translators: this means 'Files that are open' (open is no verb here
+    { "OpenFiles", NULL, N_("Open _Files"), "<control>F",
+      N_("View the files opened by a process"), G_CALLBACK (cb_show_open_files) },
+    { "ProcessProperties", NULL, N_("_Properties"), NULL,
+      N_("View additional information about a process"), G_CALLBACK (cb_show_process_properties) },
+
+
+    { "HelpContents", "help-browser", N_("_Contents"), "F1",
+      N_("Open the manual"), G_CALLBACK (cb_help_contents) },
+    { "About", "help-about", N_("_About"), NULL,
+      N_("About this application"), G_CALLBACK (cb_about) }
+};
+
+static const GtkToggleActionEntry toggle_menu_entries[] =
+{
+    { "ShowDependencies", NULL, N_("_Dependencies"), "<control>D",
+      N_("Show parent/child relationship between processes"),
+      G_CALLBACK (cb_toggle_tree), TRUE },
+};
+
+
+static const GtkRadioActionEntry radio_menu_entries[] =
+{
+  { "ShowActiveProcesses", NULL, N_("_Active Processes"), NULL,
+    N_("Show active processes"), ACTIVE_PROCESSES },
+  { "ShowAllProcesses", NULL, N_("A_ll Processes"), NULL,
+    N_("Show all processes"), ALL_PROCESSES },
+  { "ShowMyProcesses", NULL, N_("M_y Processes"), NULL,
+    N_("Show only user-owned processes"), MY_PROCESSES }
+};
+
+static const GtkRadioActionEntry priority_menu_entries[] =
+{
+    { "VeryHigh", NULL, N_("Very High"), NULL,
+      N_("Set process priority to very high"), VERY_HIGH_PRIORITY },
+    { "High", NULL, N_("High"), NULL,
+      N_("Set process priority to high"), HIGH_PRIORITY },
+    { "Normal", NULL, N_("Normal"), NULL,
+      N_("Set process priority to normal"), NORMAL_PRIORITY },
+    { "Low", NULL, N_("Low"), NULL,
+      N_("Set process priority to low"), LOW_PRIORITY },
+    { "VeryLow", NULL, N_("Very Low"), NULL,
+      N_("Set process priority to very low"), VERY_LOW_PRIORITY },
+    { "Custom", NULL, N_("Custom"), NULL,
+      N_("Set process priority manually"), CUSTOM_PRIORITY }
+};
+
+
+static const char ui_info[] =
+    "  <menubar name=\"MenuBar\">"
+    "    <menu name=\"MonitorMenu\" action=\"Monitor\">"
+    "      <menuitem name=\"MonitorLsofMenu\" action=\"Lsof\" />"
+    "      <menuitem name=\"MonitorQuitMenu\" action=\"Quit\" />"
+    "    </menu>"
+    "    <menu name=\"EditMenu\" action=\"Edit\">"
+    "      <menuitem name=\"EditStopProcessMenu\" action=\"StopProcess\" />"
+    "      <menuitem name=\"EditContProcessMenu\" action=\"ContProcess\" />"
+    "      <separator />"
+    "      <menuitem name=\"EditEndProcessMenu\" action=\"EndProcess\" />"
+    "      <menuitem name=\"EditKillProcessMenu\" action=\"KillProcess\" />"
+    "      <separator />"
+    "      <menu name=\"EditChangePriorityMenu\" action=\"ChangePriority\" >"
+    "        <menuitem action=\"VeryHigh\" />"
+    "        <menuitem action=\"High\" />"
+    "        <menuitem action=\"Normal\" />"
+    "        <menuitem action=\"Low\" />"
+    "        <menuitem action=\"VeryLow\" />"
+    "        <separator />"
+    "        <menuitem action=\"Custom\"/>"
+    "      </menu>"
+    "      <separator />"
+    "      <menuitem name=\"EditPreferencesMenu\" action=\"Preferences\" />"
+    "    </menu>"
+    "    <menu name=\"ViewMenu\" action=\"View\">"
+    "      <menuitem name=\"ViewActiveProcesses\" action=\"ShowActiveProcesses\" />"
+    "      <menuitem name=\"ViewAllProcesses\" action=\"ShowAllProcesses\" />"
+    "      <menuitem name=\"ViewMyProcesses\" action=\"ShowMyProcesses\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewDependenciesMenu\" action=\"ShowDependencies\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewMemoryMapsMenu\" action=\"MemoryMaps\" />"
+    "      <menuitem name=\"ViewOpenFilesMenu\" action=\"OpenFiles\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewProcessPropertiesMenu\" action=\"ProcessProperties\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewRefresh\" action=\"Refresh\" />"
+    "    </menu>"
+    "    <menu name=\"HelpMenu\" action=\"Help\">"
+    "      <menuitem name=\"HelpContentsMenu\" action=\"HelpContents\" />"
+    "      <menuitem name=\"HelpAboutMenu\" action=\"About\" />"
+    "    </menu>"
+    "  </menubar>"
+    "  <popup name=\"PopupMenu\" action=\"Popup\">"
+    "    <menuitem action=\"StopProcess\" />"
+    "    <menuitem action=\"ContProcess\" />"
+    "    <separator />"
+    "    <menuitem action=\"EndProcess\" />"
+    "    <menuitem action=\"KillProcess\" />"
+    "    <separator />"
+    "    <menu name=\"ChangePriorityMenu\" action=\"ChangePriority\" >"
+    "      <menuitem action=\"VeryHigh\" />"
+    "      <menuitem action=\"High\" />"
+    "      <menuitem action=\"Normal\" />"
+    "      <menuitem action=\"Low\" />"
+    "      <menuitem action=\"VeryLow\" />"
+    "      <separator />"
+    "      <menuitem action=\"Custom\"/>"
+    "    </menu>"
+    "    <separator />"
+    "    <menuitem action=\"MemoryMaps\" />"
+    "    <menuitem action=\"OpenFiles\" />"
+    "    <separator />"
+    "    <menuitem action=\"ProcessProperties\" />"
+
+    "  </popup>";
+
+
+static void
+create_proc_view(ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *proctree;
+    GtkWidget *scrolled;
+    char* string;
+
+    /* create the processes tab */
+    string = make_loadavg_string ();
+    procdata->loadavg = GTK_WIDGET (gtk_builder_get_object (builder, "load_avg_label"));
+    gtk_label_set_text (GTK_LABEL (procdata->loadavg), string);
+    g_free (string);
+
+    proctree = proctable_new (procdata);
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "processes_scrolled"));
+
+    gtk_container_add (GTK_CONTAINER (scrolled), proctree);
+
+    procdata->endprocessbutton = GTK_WIDGET (gtk_builder_get_object (builder, "endprocessbutton"));
+    g_signal_connect (G_OBJECT (procdata->endprocessbutton), "clicked",
+                      G_CALLBACK (cb_end_process_button_pressed), procdata);
+
+    /* create popup_menu for the processes tab */
+    procdata->popup_menu = gtk_ui_manager_get_widget (procdata->uimanager, "/PopupMenu");
+}
+
+
+GtkWidget *
+make_title_label (const char *text)
+{
+    GtkWidget *label;
+    char *full;
+
+    full = g_strdup_printf ("<span weight=\"bold\">%s</span>", text);
+    label = gtk_label_new (full);
+    g_free (full);
+
+    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+
+    return label;
+}
+
+
+static void
+create_sys_view (ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *cpu_graph_box, *mem_graph_box, *net_graph_box;
+    GtkWidget *label,*cpu_label;
+    GtkWidget *table;
+    GtkWidget *color_picker;
+    GtkWidget *picker_alignment;
+    LoadGraph *cpu_graph, *mem_graph, *net_graph;
+
+    gint i;
+    gchar *title_text;
+    gchar *label_text;
+    gchar *title_template;
+
+    // Translators: color picker title, %s is CPU, Memory, Swap, Receiving, Sending
+    title_template = g_strdup(_("Pick a Color for '%s'"));
+
+    /* The CPU BOX */
+
+    cpu_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_graph_box"));
+
+    cpu_graph = new LoadGraph(LOAD_GRAPH_CPU);
+    gtk_box_pack_start (GTK_BOX (cpu_graph_box),
+                        load_graph_get_widget(cpu_graph),
+                        TRUE,
+                        TRUE,
+                         0);
+
+    GtkWidget* flowbox = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_flow_box"));
+    gtk_box_reorder_child (GTK_BOX (cpu_graph_box), flowbox, 1);
+    for (i=0;i<procdata->config.num_cpus; i++) {
+        GtkWidget *temp_hbox;
+
+        temp_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
+        gtk_container_add (GTK_CONTAINER (flowbox), temp_hbox);
+
+        color_picker = gsm_color_button_new (&cpu_graph->colors.at(i), GSMCP_TYPE_CPU);
+        g_signal_connect (G_OBJECT (color_picker), "color_set",
+                          G_CALLBACK (cb_cpu_color_changed), GINT_TO_POINTER (i));
+        gtk_box_pack_start (GTK_BOX (temp_hbox), color_picker, FALSE, TRUE, 0);
+        gtk_widget_set_size_request(GTK_WIDGET(color_picker), 32, -1);
+        if(procdata->config.num_cpus == 1) {
+            label_text = g_strdup (_("CPU"));
+        } else {
+            label_text = g_strdup_printf (_("CPU%d"), i+1);
+        }
+        title_text = g_strdup_printf(title_template, label_text);
+        label = gtk_label_new (label_text);
+        gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+        g_free(title_text);
+        gtk_box_pack_start (GTK_BOX (temp_hbox), label, FALSE, FALSE, 6);
+        g_free (label_text);
+
+        cpu_label = gtk_label_new (NULL);
+        gtk_label_set_width_chars (GTK_LABEL (cpu_label), 7);
+        gtk_label_set_xalign (GTK_LABEL (cpu_label), 0.0);
+
+        gtk_box_pack_start (GTK_BOX (temp_hbox), cpu_label, TRUE, TRUE, 0);
+        load_graph_get_labels(cpu_graph)->cpu[i] = cpu_label;
+
+    }
+
+    procdata->cpu_graph = cpu_graph;
+
+    /** The memory box */
+    mem_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "mem_graph_box"));
+
+    mem_graph = new LoadGraph(LOAD_GRAPH_MEM);
+    gtk_box_pack_start (GTK_BOX (mem_graph_box),
+                        load_graph_get_widget(mem_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "mem_table"));
+
+    color_picker = load_graph_get_mem_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_mem_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Memory"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 0, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->memory;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 1, 1, 1, 1);
+
+    color_picker = load_graph_get_swap_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_swap_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Swap"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 2, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->swap;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 3, 1, 1, 1);
+
+    procdata->mem_graph = mem_graph;
+
+    /* The net box */
+    net_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "net_graph_box"));
+
+    net_graph = new LoadGraph(LOAD_GRAPH_NET);
+    gtk_box_pack_start (GTK_BOX (net_graph_box),
+                        load_graph_get_widget(net_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "net_table"));
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(0), GSMCP_TYPE_NETWORK_IN);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_in_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Receiving"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "receiving_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_in;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_in_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 1, 1, 1);
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(1), GSMCP_TYPE_NETWORK_OUT);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_out_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Sending"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "sending_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_out;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_out_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 1, 1, 1);
+
+    procdata->net_graph = net_graph;
+    g_free(title_template);
+}
+
+static void
+menu_item_select_cb (GtkMenuItem *proxy,
+                     ProcData *procdata)
+{
+    GtkAction *action;
+    char *message;
+
+    action = gtk_activatable_get_related_action (GTK_ACTIVATABLE(proxy));
+    g_assert(action);
+
+    g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
+    if (message)
+    {
+        gtk_statusbar_push (GTK_STATUSBAR (procdata->statusbar),
+                    procdata->tip_message_cid, message);
+        g_free (message);
+    }
+}
+
+static void
+menu_item_deselect_cb (GtkMenuItem *proxy,
+                       ProcData *procdata)
+{
+    gtk_statusbar_pop (GTK_STATUSBAR (procdata->statusbar),
+               procdata->tip_message_cid);
+}
+
+static void
+connect_proxy_cb (GtkUIManager *manager,
+                  GtkAction *action,
+                  GtkWidget *proxy,
+                  ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_connect (proxy, "select",
+                          G_CALLBACK (menu_item_select_cb), procdata);
+        g_signal_connect (proxy, "deselect",
+                          G_CALLBACK (menu_item_deselect_cb), procdata);
+    }
+}
+
+static void
+disconnect_proxy_cb (GtkUIManager *manager,
+                     GtkAction *action,
+                     GtkWidget *proxy,
+                     ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_select_cb)), procdata);
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_deselect_cb)), procdata);
+    }
+}
+
+void
+create_main_window (ProcData *procdata)
+{
+    gint i;
+    gint width, height, xpos, ypos;
+    GtkWidget *app;
+    GtkAction *action;
+    GtkWidget *menubar;
+    GtkWidget *main_box;
+    GtkWidget *notebook;
+    GtkBuilder *builder;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/interface.ui");
+
+    app = GTK_WIDGET (gtk_builder_get_object (builder, "main_window"));
+    main_box = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
+
+    GdkScreen* screen = gtk_widget_get_screen(app);
+    /* use visual, if available */
+    GdkVisual* visual = gdk_screen_get_rgba_visual(screen);
+    if (visual)
+        gtk_widget_set_visual(app, visual);
+
+    width = procdata->config.width;
+    height = procdata->config.height;
+    xpos = procdata->config.xpos;
+    ypos = procdata->config.ypos;
+    gtk_window_set_default_size (GTK_WINDOW (app), width, height);
+    gtk_window_move(GTK_WINDOW (app), xpos, ypos);
+
+    if (procdata->config.maximized) {
+        gtk_window_maximize(GTK_WINDOW(app));
+    }
+
+    /* create the menubar */
+    procdata->uimanager = gtk_ui_manager_new ();
+
+    /* show tooltips in the statusbar */
+    g_signal_connect (procdata->uimanager, "connect_proxy",
+                      G_CALLBACK (connect_proxy_cb), procdata);
+    g_signal_connect (procdata->uimanager, "disconnect_proxy",
+                      G_CALLBACK (disconnect_proxy_cb), procdata);
+
+    gtk_window_add_accel_group (GTK_WINDOW (app),
+                                gtk_ui_manager_get_accel_group (procdata->uimanager));
+
+    if (!gtk_ui_manager_add_ui_from_string (procdata->uimanager,
+                                            ui_info,
+                                            -1,
+                                            NULL)) {
+        g_error("building menus failed");
+    }
+
+    procdata->action_group = gtk_action_group_new ("ProcmanActions");
+    gtk_action_group_set_translation_domain (procdata->action_group, NULL);
+    gtk_action_group_add_actions (procdata->action_group,
+                                  menu_entries,
+                                  G_N_ELEMENTS (menu_entries),
+                                  procdata);
+    gtk_action_group_add_toggle_actions (procdata->action_group,
+                                         toggle_menu_entries,
+                                         G_N_ELEMENTS (toggle_menu_entries),
+                                         procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                        radio_menu_entries,
+                        G_N_ELEMENTS (radio_menu_entries),
+                        procdata->config.whose_process,
+                        G_CALLBACK(cb_radio_processes),
+                        procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                                        priority_menu_entries,
+                                        G_N_ELEMENTS (priority_menu_entries),
+                                        NORMAL_PRIORITY,
+                                        G_CALLBACK(cb_renice),
+                                        procdata);
+
+    gtk_ui_manager_insert_action_group (procdata->uimanager,
+                                        procdata->action_group,
+                                        0);
+
+    menubar = gtk_ui_manager_get_widget (procdata->uimanager, "/MenuBar");
+    gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0);
+    gtk_box_reorder_child (GTK_BOX (main_box), menubar, 0);
+
+    /* create the main notebook */
+    procdata->notebook = notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
+
+    create_proc_view(procdata, builder);
+    create_sys_view (procdata, builder);
+    create_disk_view (procdata, builder);
+
+    g_signal_connect (G_OBJECT (notebook), "switch-page",
+              G_CALLBACK (cb_switch_page), procdata);
+    g_signal_connect (G_OBJECT (notebook), "change-current-page",
+              G_CALLBACK (cb_change_current_page), procdata);
+
+    gtk_widget_show_all(notebook); // need to make page switch work
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab);
+    cb_change_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab, procdata);
+    g_signal_connect (G_OBJECT (app), "delete_event",
+                      G_CALLBACK (cb_app_delete),
+                      procdata);
+
+    GtkAccelGroup *accel_group;
+    GClosure *goto_tab_closure[4];
+    accel_group = gtk_accel_group_new ();
+    gtk_window_add_accel_group (GTK_WINDOW(app), accel_group);
+    for (i = 0; i < 4; ++i) {
+        goto_tab_closure[i] = g_cclosure_new_swap (G_CALLBACK (cb_proc_goto_tab),
+                                                   GINT_TO_POINTER (i), NULL);
+        gtk_accel_group_connect (accel_group, '0'+(i+1),
+                                 GDK_MOD1_MASK, GTK_ACCEL_VISIBLE,
+                                 goto_tab_closure[i]);
+    }
+
+    /* create the statusbar */
+    procdata->statusbar = GTK_WIDGET (gtk_builder_get_object (builder, "statusbar"));
+    procdata->tip_message_cid = gtk_statusbar_get_context_id
+        (GTK_STATUSBAR (procdata->statusbar), "tip_message");
+
+    action = gtk_action_group_get_action (procdata->action_group, "ShowDependencies");
+    gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+                      procdata->config.show_tree);
+
+    gtk_builder_connect_signals (builder, NULL);
+
+    gtk_widget_show_all(app);
+    procdata->app = app;
+
+    g_object_unref (G_OBJECT (builder));
+}
+
+void
+do_popup_menu (ProcData *procdata, GdkEventButton *event)
+{
+    gtk_menu_popup_at_pointer (GTK_MENU (procdata->popup_menu), NULL);
+}
+
+void
+update_sensitivity(ProcData *data)
+{
+    const char * const selected_actions[] = { "StopProcess",
+                                              "ContProcess",
+                                              "EndProcess",
+                                              "KillProcess",
+                                              "ChangePriority",
+                                              "MemoryMaps",
+                                              "OpenFiles",
+                                              "ProcessProperties" };
+
+    const char * const processes_actions[] = { "ShowActiveProcesses",
+                                               "ShowAllProcesses",
+                                               "ShowMyProcesses",
+                                               "ShowDependencies",
+                                               "Refresh"
+    };
+
+    size_t i;
+    gboolean processes_sensitivity, selected_sensitivity;
+    GtkAction *action;
+
+    processes_sensitivity = (data->config.current_tab == PROCMAN_TAB_PROCESSES);
+    selected_sensitivity = (processes_sensitivity && data->selection && gtk_tree_selection_count_selected_rows (data->selection) > 0);
+
+    if(data->endprocessbutton) {
+        /* avoid error on startup if endprocessbutton
+           has not been built yet */
+        gtk_widget_set_sensitive(data->endprocessbutton, selected_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(processes_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             processes_actions[i]);
+        gtk_action_set_sensitive(action, processes_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(selected_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             selected_actions[i]);
+        gtk_action_set_sensitive(action, selected_sensitivity);
+    }
+}
+
+void
+block_priority_changed_handlers(ProcData *data, bool block)
+{
+    gint i;
+    if (block) {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_block_by_func(action, (gpointer)cb_renice, data);
+        }
+    } else {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_unblock_by_func(action, (gpointer)cb_renice, data);
+        }
+    }
+}
+
+static void
+cb_toggle_tree (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GSettings *settings = procdata->settings;
+    gboolean show;
+
+    show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+    if (show == procdata->config.show_tree)
+        return;
+
+    g_settings_set_boolean (settings, "show-tree", show);
+}
+
+static void
+cb_proc_goto_tab (gint tab)
+{
+    ProcData *data = ProcData::get_instance ();
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (data->notebook), tab);
+}
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/7.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/7.html new file mode 100644 index 00000000..8b385037 --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/7.html @@ -0,0 +1,1939 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
#include <config.h>
+
+#include <gdkmm/pixbuf.h>
+
+#include <stdio.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <signal.h>
+#include <dirent.h>
+#include <string.h>
+#include <time.h>
+
+#include <glib/gi18n.h>
+
+#include <glibtop.h>
+#include <glibtop/cpu.h>
+#include <glibtop/mem.h>
+#include <glibtop/swap.h>
+#include <glibtop/netload.h>
+#include <glibtop/netlist.h>
+#include <math.h>
+
+#include <algorithm>
+
+#include "procman.h"
+#include "load-graph.h"
+#include "util.h"
+#include "gsm_color_button.h"
+
+void LoadGraph::clear_background()
+{
+    if (background) {
+        cairo_pattern_destroy (background);
+        this->background = NULL;
+    }
+}
+
+
+unsigned LoadGraph::num_bars() const
+{
+    unsigned n;<--- Shadow variable
+
+    // keep 100 % num_bars == 0
+    switch (static_cast<int>(this->draw_height / (fontsize + 14)))
+    {
+    case 0:
+    case 1:
+        n = 1;
+        break;
+    case 2:
+    case 3:
+        n = 2;
+        break;
+    case 4:
+        n = 4;
+        break;
+    default:
+        n = 5;
+    }
+
+    return n;
+}
+
+
+
+#define FRAME_WIDTH 4
+static void draw_background(LoadGraph *graph) {
+    GtkAllocation allocation;
+    cairo_t *cr;
+    guint i;<--- Shadowed declaration
+    unsigned num_bars;
+    g_autofree gchar *caption;
+    PangoLayout* layout;
+    PangoFontDescription* font_desc;
+    PangoRectangle extents;
+    cairo_surface_t *surface;
+    GdkRGBA fg, bg;
+
+    num_bars = graph->num_bars();
+    graph->graph_dely = (graph->draw_height - 15) / num_bars; /* round to int to avoid AA blur */
+    graph->real_draw_height = graph->graph_dely * num_bars;
+    graph->graph_delx = (graph->draw_width - 2.0 - graph->rmargin - graph->indent) / (LoadGraph::NUM_POINTS - 3);
+    graph->graph_buffer_offset = (int) (1.5 * graph->graph_delx) + FRAME_WIDTH ;
+
+    gtk_widget_get_allocation (graph->disp, &allocation);
+    surface = gdk_window_create_similar_surface (gtk_widget_get_window (graph->disp), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height);
+    cr = cairo_create (surface);
+
+    GtkStyleContext *context = gtk_widget_get_style_context (ProcData::get_instance()->notebook);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get_background_color (context, gtk_style_context_get_state (context), &bg);
+    gtk_style_context_get_color (context, gtk_style_context_get_state (context), &fg);
+    gtk_style_context_restore (context);
+
+    // set the background color
+    gdk_cairo_set_source_rgba (cr, &bg);
+    cairo_paint (cr);
+
+    layout = pango_cairo_create_layout (cr);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get (context,
+                           gtk_style_context_get_state (context),
+                           GTK_STYLE_PROPERTY_FONT,
+                           &font_desc, NULL);
+    gtk_style_context_restore (context);
+    pango_font_description_set_size (font_desc, 0.8 * graph->fontsize * PANGO_SCALE);
+    pango_layout_set_font_description (layout, font_desc);
+    pango_font_description_free (font_desc);
+
+    /* draw frame */
+    cairo_translate (cr, FRAME_WIDTH, FRAME_WIDTH);
+
+    /* Draw background rectangle */
+    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+    cairo_rectangle (cr, graph->rmargin + graph->indent, 0,
+                     graph->draw_width - graph->rmargin - graph->indent, graph->real_draw_height);
+    cairo_fill(cr);
+
+    cairo_set_line_width (cr, 1.0);
+    cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    for (i = 0; i <= num_bars; ++i) {
+        double y;
+
+        if (i == 0)
+            y = 0.5 + graph->fontsize / 2.0;
+        else if (i == num_bars)
+            y = i * graph->graph_dely + 0.5;
+        else
+            y = i * graph->graph_dely + graph->fontsize / 2.0;
+
+        gdk_cairo_set_source_rgba (cr, &fg);
+        if (graph->type == LOAD_GRAPH_NET) {
+            // operation orders matters so it's 0 if i == num_bars
+            guint64 rate = graph->net.max - (i * graph->net.max / num_bars);
+            caption = g_format_size_full (network_in_bits ? rate*8 : rate, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        } else {
+            // operation orders matters so it's 0 if i == num_bars
+            caption = g_strdup_printf("%d%%", 100 - i * (100 / num_bars));
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        }
+
+        if (i==0 || i==num_bars)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, graph->rmargin + graph->indent - 3, i * graph->graph_dely + 0.5);
+        cairo_line_to (cr, graph->draw_width - 0.5, i * graph->graph_dely + 0.5);
+        cairo_stroke (cr);
+    }
+
+    const unsigned total_seconds = graph->speed * (LoadGraph::NUM_POINTS - 2) / 1000;
+
+    for (unsigned int i = 0; i < 7; i++) {<--- Shadow variable
+        double x = (i) * (graph->draw_width - graph->rmargin - graph->indent) / 6;
+        if (i==0 || i==6)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, 0.5);
+        cairo_line_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, graph->real_draw_height + 4.5);
+        cairo_stroke(cr);
+        unsigned seconds = total_seconds - i * total_seconds / 6;
+        const char* format;
+        if (i == 0)
+            format = dngettext(GETTEXT_PACKAGE, "%u second", "%u seconds", seconds);
+        else
+            format = "%u";
+        caption = g_strdup_printf(format, seconds);
+        pango_layout_set_text (layout, caption, -1);
+        pango_layout_get_extents (layout, NULL, &extents);
+        cairo_move_to (cr, ((ceil(x) + 0.5) + graph->rmargin + graph->indent) - (1.0 * extents.width / PANGO_SCALE/2), graph->draw_height - 1.0 * extents.height / PANGO_SCALE);
+        gdk_cairo_set_source_rgba (cr, &fg);
+        pango_cairo_show_layout (cr, layout);
+    }
+    g_object_unref(layout);
+    cairo_stroke (cr);
+    cairo_destroy (cr);
+    graph->background = cairo_pattern_create_for_surface (surface);
+    cairo_surface_destroy (surface);
+}
+
+/* Redraws the backing buffer for the load graph and updates the window */
+void
+load_graph_queue_draw (LoadGraph *graph)
+{
+    /* repaint */
+    gtk_widget_queue_draw (graph->disp);
+}
+
+static int load_graph_update (gpointer user_data); // predeclare load_graph_update so we can compile ;)
+
+static gboolean
+load_graph_configure (GtkWidget *widget,
+                      GdkEventConfigure *event,
+                      gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    gtk_widget_get_allocation (widget, &allocation);
+    graph->draw_width = allocation.width - 2 * FRAME_WIDTH;
+    graph->draw_height = allocation.height - 2 * FRAME_WIDTH;
+
+    graph->clear_background();
+
+    load_graph_queue_draw (graph);
+
+    return TRUE;
+}
+
+static gboolean load_graph_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+    GdkWindow *window;
+
+    guint i, j;
+    gdouble sample_width, x_offset;
+
+    window = gtk_widget_get_window (graph->disp);
+
+    /* Number of pixels wide for one graph point */
+    sample_width = (float)(graph->draw_width - graph->rmargin - graph->indent) / (float)LoadGraph::NUM_POINTS;
+    /* General offset */
+    x_offset = graph->draw_width - graph->rmargin + (sample_width*2);
+
+    /* Subframe offset */
+    x_offset += graph->rmargin - ((sample_width / graph->frames_per_unit) * graph->render_counter);
+
+    /* draw the graph */
+    cairo_t* cr;
+
+    cr = gdk_cairo_create (window);
+
+    if (graph->background == NULL) {
+        draw_background(graph);
+    }
+    cairo_set_source (cr, graph->background);
+    cairo_paint (cr);
+
+    cairo_set_line_width (cr, 1);
+    cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+    cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+    cairo_rectangle (cr, graph->rmargin + graph->indent + FRAME_WIDTH + 1, FRAME_WIDTH - 1,
+             graph->draw_width - graph->rmargin - graph->indent - 1, graph->real_draw_height + FRAME_WIDTH - 1);
+    cairo_clip(cr);
+
+    for (j = 0; j < graph->n; ++j) {
+        cairo_move_to (cr, x_offset, (1.0f - graph->data[0][j]) * graph->real_draw_height);
+        gdk_cairo_set_source_rgba (cr, &(graph->colors [j]));
+
+        for (i = 1; i < LoadGraph::NUM_POINTS; ++i) {
+            if (graph->data[i][j] == -1.0f)
+                continue;
+            cairo_curve_to (cr,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i-1][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - (i * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f);
+        }
+        cairo_stroke (cr);
+
+    }
+
+    cairo_destroy (cr);
+
+    return TRUE;
+}
+
+static void
+get_load (LoadGraph *graph)
+{
+    guint i;
+    glibtop_cpu cpu;
+
+    glibtop_get_cpu (&cpu);
+
+#undef NOW
+#undef LAST
+#define NOW  (graph->cpu.times[graph->cpu.now])
+#define LAST (graph->cpu.times[graph->cpu.now ^ 1])
+
+    if (graph->n == 1) {
+        NOW[0][CPU_TOTAL] = cpu.total;
+        NOW[0][CPU_USED] = cpu.user + cpu.nice + cpu.sys;
+    } else {
+        for (i = 0; i < graph->n; i++) {
+            NOW[i][CPU_TOTAL] = cpu.xcpu_total[i];
+            NOW[i][CPU_USED] = cpu.xcpu_user[i] + cpu.xcpu_nice[i]
+                + cpu.xcpu_sys[i];
+        }
+    }
+
+    // on the first call, LAST is 0
+    // which means data is set to the average load since boot
+    // that value has no meaning, we just want all the
+    // graphs to be aligned, so the CPU graph needs to start
+    // immediately
+
+    for (i = 0; i < graph->n; i++) {
+        float load;
+        float total, used;
+        gchar *text;
+
+        total = NOW[i][CPU_TOTAL] - LAST[i][CPU_TOTAL];
+        used  = NOW[i][CPU_USED]  - LAST[i][CPU_USED];
+
+        load = used / MAX(total, 1.0f);
+        graph->data[0][i] = load;
+
+        /* Update label */
+        text = g_strdup_printf("%.1f%%", load * 100.0f);
+        gtk_label_set_text(GTK_LABEL(graph->labels.cpu[i]), text);
+        g_free(text);
+    }
+
+    graph->cpu.now ^= 1;
+
+#undef NOW
+#undef LAST
+}
+
+
+namespace
+{
+
+    void set_memory_label_and_picker(GtkLabel* label, GSMColorButton* picker,
+                                   guint64 used, guint64 total, double percent)
+    {
+        char* used_text;
+        char* total_text;
+        char* text;
+
+        used_text = g_format_size_full(used, G_FORMAT_SIZE_IEC_UNITS);
+        total_text = g_format_size_full(total, G_FORMAT_SIZE_IEC_UNITS);
+        if (total == 0) {
+            text = g_strdup(_("not available"));
+        } else {
+            // xgettext: 540MiB (53 %) of 1.0 GiB
+            text = g_strdup_printf(_("%s (%.1f%%) of %s"), used_text, 100.0 * percent, total_text);
+        }
+        gtk_label_set_text(label, text);
+        g_free(used_text);
+        g_free(total_text);
+        g_free(text);
+
+        if (picker)
+            gsm_color_button_set_fraction(picker, percent);
+    }
+}
+
+static void
+get_memory (LoadGraph *graph)
+{
+    float mempercent, swappercent;
+
+    glibtop_mem mem;
+    glibtop_swap swap;
+
+    glibtop_get_mem (&mem);
+    glibtop_get_swap (&swap);
+
+    /* There's no swap on LiveCD : 0.0f is better than NaN :) */
+    swappercent = (swap.total ? (float)swap.used / (float)swap.total : 0.0f);
+    mempercent  = (float)mem.user  / (float)mem.total;
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.memory),
+                                GSM_COLOR_BUTTON(graph->mem_color_picker),
+                                mem.user, mem.total, mempercent);
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.swap),
+                                GSM_COLOR_BUTTON(graph->swap_color_picker),
+                                swap.used, swap.total, swappercent);
+
+    graph->data[0][0] = mempercent;
+    graph->data[0][1] = swappercent;
+}
+
+/* Nice Numbers for Graph Labels after Paul Heckbert
+   nicenum: find a "nice" number approximately equal to x.
+   Round the number if round=1, take ceiling if round=0    */
+
+static double
+nicenum (double x, int round)
+{
+    int expv;				/* exponent of x */
+    double f;				/* fractional part of x */
+    double nf;				/* nice, rounded fraction */
+
+    expv = floor( log10(x) );
+    f = x/pow( 10.0, expv );		/* between 1 and 10 */
+    if (round) {
+        if ( f < 1.5 ) nf = 1.0;
+        else if ( f < 3.0 ) nf = 2.0;
+        else if ( f < 7.0 ) nf = 5.0;
+        else nf = 10.0;
+    } else {
+        if ( f <= 1.0 ) nf = 1.0;
+        else if ( f <= 2.0 ) nf = 2.0;
+        else if ( f <= 5.0 ) nf = 5.0;
+        else nf = 10.0;
+    }
+    return nf * pow(10.0, expv);
+}
+
+static void
+net_scale (LoadGraph *graph, guint64 din, guint64 dout)
+{
+    graph->data[0][0] = 1.0f * din / graph->net.max;
+    graph->data[0][1] = 1.0f * dout / graph->net.max;
+
+    guint64 dmax = std::max(din, dout);
+    graph->net.values[graph->net.cur] = dmax;
+    graph->net.cur = (graph->net.cur + 1) % LoadGraph::NUM_POINTS;
+
+    guint64 new_max;
+    // both way, new_max is the greatest value
+    if (dmax >= graph->net.max)
+        new_max = dmax;
+    else
+        new_max = *std::max_element(&graph->net.values[0],
+                                    &graph->net.values[LoadGraph::NUM_POINTS]);
+
+    //
+    // Round network maximum
+    //
+
+    const guint64 bak_max(new_max);
+
+    if (ProcData::get_instance()->config.network_in_bits) {
+        // nice number is for the ticks
+        unsigned ticks = graph->num_bars();
+
+        // gets messy at low values due to division by 8
+        guint64 bit_max = std::max( new_max*8, G_GUINT64_CONSTANT(10000) );
+
+        // our tick size leads to max
+        double d = nicenum(bit_max/ticks, 0);
+        bit_max = ticks * d;
+        new_max = bit_max / 8;
+
+        procman_debug("bak*8 %" G_GUINT64_FORMAT ", ticks %d, d %f"
+                      ", bit_max %" G_GUINT64_FORMAT ", new_max %" G_GUINT64_FORMAT,
+                      bak_max*8, ticks, d, bit_max, new_max );
+    } else {
+        // round up to get some extra space
+        // yes, it can overflow
+        new_max = 1.1 * new_max;
+        // make sure max is not 0 to avoid / 0
+        // default to 1 KiB
+        new_max = std::max(new_max, G_GUINT64_CONSTANT(1024));
+
+        // decompose new_max = coef10 * 2**(base10 * 10)
+        // where coef10 and base10 are integers and coef10 < 2**10
+        //
+        // e.g: ceil(100.5 KiB) = 101 KiB = 101 * 2**(1 * 10)
+        //      where base10 = 1, coef10 = 101, pow2 = 16
+
+        guint64 pow2 = std::floor(log2(new_max));
+        guint64 base10 = pow2 / 10.0;
+        guint64 coef10 = std::ceil(new_max / double(G_GUINT64_CONSTANT(1) << (base10 * 10)));
+        g_assert(new_max <= (coef10 * (G_GUINT64_CONSTANT(1) << (base10 * 10))));
+
+        // then decompose coef10 = x * 10**factor10
+        // where factor10 is integer and x < 10
+        // so we new_max has only 1 significant digit
+
+        guint64 factor10 = std::pow(10.0, std::floor(std::log10(coef10)));
+        coef10 = std::ceil(coef10 / double(factor10)) * factor10;
+
+        // then make coef10 divisible by num_bars
+        if (coef10 % graph->num_bars() != 0)
+            coef10 = coef10 + (graph->num_bars() - coef10 % graph->num_bars());
+        g_assert(coef10 % graph->num_bars() == 0);
+        new_max = coef10 * (G_GUINT64_CONSTANT(1) << guint64(base10 * 10));
+        procman_debug("bak %" G_GUINT64_FORMAT " new_max %" G_GUINT64_FORMAT
+                      "pow2 %" G_GUINT64_FORMAT " coef10 %" G_GUINT64_FORMAT,
+                      bak_max, new_max, pow2, coef10);
+    }
+
+    if (bak_max > new_max) {
+        procman_debug("overflow detected: bak=%" G_GUINT64_FORMAT
+                      " new=%" G_GUINT64_FORMAT,
+                      bak_max, new_max);
+        new_max = bak_max;
+    }
+
+    // if max is the same or has decreased but not so much, don't
+    // do anything to avoid rescaling
+    if ((0.8 * graph->net.max) < new_max && new_max <= graph->net.max)
+        return;
+
+    const double scale = 1.0f * graph->net.max / new_max;
+
+    for (size_t i = 0; i < LoadGraph::NUM_POINTS; i++) {
+        if (graph->data[i][0] >= 0.0f) {
+            graph->data[i][0] *= scale;
+            graph->data[i][1] *= scale;
+        }
+    }
+
+    procman_debug("rescale dmax = %" G_GUINT64_FORMAT
+                  " max = %" G_GUINT64_FORMAT
+                  " new_max = %" G_GUINT64_FORMAT,
+                  dmax, graph->net.max, new_max);
+
+    graph->net.max = new_max;
+
+    // force the graph background to be redrawn now that scale has changed
+    graph->clear_background();
+}
+
+static void
+get_net (LoadGraph *graph)
+{
+    glibtop_netlist netlist;
+    char **ifnames;
+    guint32 i;
+    guint64 in = 0, out = 0;
+#if GLIB_CHECK_VERSION(2,61,2)
+    gint64 time;
+#else
+    GTimeVal time;
+#endif
+    guint64 din, dout;
+
+    ifnames = glibtop_get_netlist(&netlist);
+
+    for (i = 0; i < netlist.number; ++i)
+    {
+        glibtop_netload netload;
+        glibtop_get_netload (&netload, ifnames[i]);
+
+        if (netload.if_flags & (1 << GLIBTOP_IF_FLAGS_LOOPBACK))
+            continue;
+
+        /* Skip interfaces without any IPv4/IPv6 address (or
+         those with only a LINK ipv6 addr) However we need to
+         be able to exclude these while still keeping the
+         value so when they get online (with NetworkManager
+         for example) we don't get a suddent peak.  Once we're
+         able to get this, ignoring down interfaces will be
+         possible too.  */
+        if (not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS6)
+             and netload.scope6 != GLIBTOP_IF_IN6_SCOPE_LINK)
+            and not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS)))
+            continue;
+
+        /* Don't skip interfaces that are down (GLIBTOP_IF_FLAGS_UP)
+           to avoid spikes when they are brought up */
+
+        in  += netload.bytes_in;
+        out += netload.bytes_out;
+    }
+
+    g_strfreev(ifnames);
+
+#if GLIB_CHECK_VERSION(2,61,2)
+    time = g_get_real_time ();
+
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time != 0) {
+        float dtime = (double) (time - graph->net.time) / G_USEC_PER_SEC;
+#else
+    g_get_current_time (&time);
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time.tv_sec != 0) {
+        float dtime;
+        dtime = time.tv_sec - graph->net.time.tv_sec +
+            (double) (time.tv_usec - graph->net.time.tv_usec) / G_USEC_PER_SEC;
+#endif
+        din   = static_cast<guint64>((in  - graph->net.last_in)  / dtime);
+        dout  = static_cast<guint64>((out - graph->net.last_out) / dtime);
+    } else {
+        /* Don't calc anything if new data is less than old (interface
+           removed, counters reset, ...) or if it is the first time */
+        din  = 0;
+        dout = 0;
+    }
+
+    graph->net.last_in  = in;
+    graph->net.last_out = out;
+    graph->net.time     = time;
+
+    net_scale(graph, din, dout);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    g_autofree gchar *str=NULL, *formatted_str=NULL;
+
+    str = g_format_size_full (network_in_bits ? din*8 : din, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? in*8 : in, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in_total), str);
+
+    str = g_format_size_full (network_in_bits ? dout*8 : dout, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? out*8 : out, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out_total), str);
+}
+
+
+/* Updates the load graph when the timeout expires */
+static gboolean
+load_graph_update (gpointer user_data)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(user_data);
+
+    if (graph->render_counter == graph->frames_per_unit - 1) {
+        std::rotate(&graph->data[0], &graph->data[LoadGraph::NUM_POINTS - 1], &graph->data[LoadGraph::NUM_POINTS]);
+
+        switch (graph->type) {
+        case LOAD_GRAPH_CPU:
+            get_load(graph);
+            break;
+        case LOAD_GRAPH_MEM:
+            get_memory(graph);
+            break;
+        case LOAD_GRAPH_NET:
+            get_net(graph);
+            break;
+        default:
+            g_assert_not_reached();
+        }
+    }
+
+    if (graph->draw)
+        load_graph_queue_draw (graph);
+
+    graph->render_counter++;
+
+    if (graph->render_counter >= graph->frames_per_unit)
+        graph->render_counter = 0;
+
+    return TRUE;
+}
+
+
+
+LoadGraph::~LoadGraph()
+{
+  load_graph_stop(this);
+
+  if (timer_index)
+    g_source_remove(timer_index);
+
+  clear_background();
+}
+
+
+
+static gboolean
+load_graph_destroy (GtkWidget *widget, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    delete graph;
+
+    return FALSE;
+}
+
+
+LoadGraph::LoadGraph(guint type)
+  : fontsize(8.0),
+    rmargin(3.5 * fontsize),
+    indent(24.0),
+    n(0),
+    type(type),
+    speed(0),
+    draw_width(0),
+    draw_height(0),
+    render_counter(0),
+    frames_per_unit(10), // this will be changed but needs initialising
+    graph_dely(0),
+    real_draw_height(0),
+    graph_delx(0.0),
+    graph_buffer_offset(0),
+    main_widget(NULL),
+    disp(NULL),
+    background(NULL),
+    timer_index(0),
+    draw(FALSE),
+    mem_color_picker(NULL),
+    swap_color_picker(NULL)
+{
+    LoadGraph * const graph = this;
+
+    // FIXME:
+    // on configure, graph->frames_per_unit = graph->draw_width/(LoadGraph::NUM_POINTS);
+    // knock FRAMES down to 5 until cairo gets faster
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memset(&cpu, 0, sizeof cpu);
+        n = ProcData::get_instance()->config.num_cpus;
+
+        for(guint i = 0; i < G_N_ELEMENTS(labels.cpu); ++i)
+            labels.cpu[i] = gtk_label_new(NULL);
+
+        break;
+
+    case LOAD_GRAPH_MEM:
+        n = 2;
+        labels.memory = gtk_label_new(NULL);
+        labels.swap = gtk_label_new(NULL);
+        break;
+
+    case LOAD_GRAPH_NET:
+        memset(&net, 0, sizeof net);
+        n = 2;
+        net.max = 1;
+        labels.net_in = gtk_label_new(NULL);
+        labels.net_in_total = gtk_label_new(NULL);
+        labels.net_out = gtk_label_new(NULL);
+        labels.net_out_total = gtk_label_new(NULL);
+        break;
+    }
+
+    speed  = ProcData::get_instance()->config.graph_update_interval;
+
+    colors.resize(n);
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memcpy(&colors[0], ProcData::get_instance()->config.cpu_color,
+               n * sizeof colors[0]);
+        break;
+    case LOAD_GRAPH_MEM:
+        colors[0] = ProcData::get_instance()->config.mem_color;
+        colors[1] = ProcData::get_instance()->config.swap_color;
+        mem_color_picker = gsm_color_button_new (&colors[0],
+                                                 GSMCP_TYPE_PIE);
+        swap_color_picker = gsm_color_button_new (&colors[1],
+                                                  GSMCP_TYPE_PIE);
+        break;
+    case LOAD_GRAPH_NET:
+        colors[0] = ProcData::get_instance()->config.net_in_color;
+        colors[1] = ProcData::get_instance()->config.net_out_color;
+        break;
+    }
+
+    timer_index = 0;
+    render_counter = (frames_per_unit - 1);
+    draw = FALSE;
+
+    main_widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+    gtk_widget_set_size_request(main_widget, -1, LoadGraph::GRAPH_MIN_HEIGHT);
+    gtk_widget_show (main_widget);
+
+    disp = gtk_drawing_area_new ();
+    gtk_widget_show (disp);
+    g_signal_connect (G_OBJECT (disp), "draw", G_CALLBACK (load_graph_draw), graph);
+    g_signal_connect (G_OBJECT(disp), "configure_event",
+                      G_CALLBACK (load_graph_configure), graph);
+    g_signal_connect (G_OBJECT(disp), "destroy",
+                      G_CALLBACK (load_graph_destroy), graph);
+
+    gtk_widget_set_events (disp, GDK_EXPOSURE_MASK);
+
+    gtk_box_pack_start (GTK_BOX (main_widget), disp, TRUE, TRUE, 0);
+
+
+    /* Allocate data in a contiguous block */
+    data_block = std::vector<float>(n * LoadGraph::NUM_POINTS, -1.0f);
+
+    for (guint i = 0; i < LoadGraph::NUM_POINTS; ++i)
+        data[i] = &data_block[0] + i * n;
+
+    gtk_widget_show_all (main_widget);
+}
+
+void
+load_graph_start (LoadGraph *graph)
+{
+    if(!graph->timer_index) {
+
+        load_graph_update(graph);
+
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->draw = TRUE;
+}
+
+void
+load_graph_stop (LoadGraph *graph)
+{
+    /* don't draw anymore, but continue to poll */
+    graph->draw = FALSE;
+}
+
+void
+load_graph_change_speed (LoadGraph *graph,
+             guint new_speed)
+{
+    if (graph->speed == new_speed)
+        return;
+
+    graph->speed = new_speed;
+
+    if(graph->timer_index) {
+        g_source_remove (graph->timer_index);
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->clear_background();
+}
+
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *graph)
+{
+    return &graph->labels;
+}
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *graph)
+{
+    return graph->main_widget;
+}
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *graph)
+{
+    return graph->mem_color_picker;
+}
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *graph)
+{
+    return graph->swap_color_picker;
+}
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/8.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/8.html new file mode 100644 index 00000000..6bd78123 --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/8.html @@ -0,0 +1,1075 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
#include <config.h>
+
+#include <gtkmm/messagedialog.h>
+#include <glibmm/regex.h>
+#include <glib/gi18n.h>
+#include <glibtop/procopenfiles.h>
+
+#include <sys/wait.h>
+
+#include <set>
+#include <string>
+#include <sstream>
+#include <iterator>
+
+#include <glibmm/regex.h>
+
+#include "procman.h"
+#include "lsof.h"
+#include "util.h"
+
+
+using std::string;
+
+
+namespace
+{
+
+    class Lsof
+    {
+        Glib::RefPtr<Glib::Regex> re;
+
+        bool matches(const string &filename) const
+        {
+            return this->re->match(filename);
+        }
+
+    public:
+
+        Lsof(const string &pattern, bool caseless)
+        {
+            Glib::RegexCompileFlags flags = static_cast<Glib::RegexCompileFlags>(0);
+
+            if (caseless)
+                flags |= Glib::REGEX_CASELESS;
+
+            this->re = Glib::Regex::create(pattern, flags);
+        }
+
+
+        template<typename OutputIterator>
+        void search(const ProcInfo &info, OutputIterator out) const
+        {
+            glibtop_open_files_entry *entries;
+            glibtop_proc_open_files buf;
+
+            entries = glibtop_get_proc_open_files(&buf, info.pid);
+
+            for (unsigned i = 0; i != buf.number; ++i) {
+                if (entries[i].type & GLIBTOP_FILE_TYPE_FILE) {
+                    const string filename(entries[i].info.file.name);
+                    if (this->matches(filename))
+                        *out++ = filename;
+                }
+            }
+
+            g_free(entries);
+        }
+    };
+
+
+
+    // GUI Stuff
+
+
+    enum ProcmanLsof {
+        PROCMAN_LSOF_COL_SURFACE,
+        PROCMAN_LSOF_COL_PROCESS,
+        PROCMAN_LSOF_COL_PID,
+        PROCMAN_LSOF_COL_FILENAME,
+        PROCMAN_LSOF_NCOLS
+    };
+
+
+    struct GUI {
+
+        GtkListStore *model;
+        GtkEntry *entry;
+        GtkWindow *window;
+        GtkLabel *count;<--- Shadowed declaration
+        ProcData *procdata;
+        bool case_insensitive;
+
+
+        GUI()
+        {
+            procman_debug("New Lsof GUI %p", this);
+        }
+
+
+        ~GUI()
+        {
+            procman_debug("Destroying Lsof GUI %p", this);
+        }
+
+
+        void clear_results()
+        {
+            gtk_list_store_clear(this->model);
+            gtk_label_set_text(this->count, "");
+        }
+
+
+        void clear()
+        {
+            this->clear_results();
+            gtk_entry_set_text(this->entry, "");
+        }
+
+
+        void display_regex_error(const Glib::RegexError& error)
+        {
+            char * msg = g_strdup_printf ("<b>%s</b>\n%s\n%s",
+                                          _("Error"),
+                                          _("'%s' is not a valid Perl regular expression."),
+                                          "%s");
+            std::string message = make_string(g_strdup_printf(msg, this->pattern().c_str(), error.what().c_str()));
+            g_free(msg);
+
+            Gtk::MessageDialog dialog(message,
+                                      true, // use markup
+                                      Gtk::MESSAGE_ERROR,
+                                      Gtk::BUTTONS_OK,
+                                      true); // modal
+            dialog.run();
+        }
+
+
+        void update_count(unsigned count)
+        {
+            std::ostringstream ss;
+            ss << count;
+            string s = ss.str();
+            gtk_label_set_text(this->count, s.c_str());
+        }
+
+
+        string pattern() const
+        {
+            return gtk_entry_get_text(this->entry);
+        }
+
+
+        void search()
+        {
+            typedef std::set<string> MatchSet;
+            typedef MatchSet::const_iterator iterator;
+
+            this->clear_results();
+
+
+            try {
+                Lsof lsof(this->pattern(), this->case_insensitive);
+
+                unsigned count = 0;<--- Shadow variable
+
+                for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it) {
+                    const ProcInfo &info(*it->second);
+
+                    MatchSet matches;
+                    lsof.search(info, std::inserter(matches, matches.begin()));
+                    count += matches.size();
+
+                    for (iterator it(matches.begin()), end(matches.end()); it != end; ++it) {
+                        GtkTreeIter file;
+                        gtk_list_store_append(this->model, &file);
+                        gtk_list_store_set(this->model, &file,
+                                           PROCMAN_LSOF_COL_SURFACE, info.surface,
+                                           PROCMAN_LSOF_COL_PROCESS, info.name,
+                                           PROCMAN_LSOF_COL_PID, info.pid,
+                                           PROCMAN_LSOF_COL_FILENAME, it->c_str(),
+                                           -1);
+                    }
+                }
+
+                this->update_count(count);
+            }
+            catch (Glib::RegexError& error) {
+                this->display_regex_error(error);
+            }
+        }
+
+
+        static void search_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void search_entry_activate(GtkEntry *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void clear_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->clear();
+        }
+
+
+        static void close_button_clicked(GtkButton *, gpointer data)
+        {
+            GUI *gui = static_cast<GUI*>(data);
+            gtk_widget_destroy(GTK_WIDGET(gui->window));
+            delete gui;
+        }
+
+
+        static void case_button_toggled(GtkToggleButton *button, gpointer data)
+        {
+            bool state = gtk_toggle_button_get_active(button);
+            static_cast<GUI*>(data)->case_insensitive = state;
+        }
+
+
+        static gboolean window_delete_event(GtkWidget *, GdkEvent *, gpointer data)
+        {
+            delete static_cast<GUI*>(data);
+            return FALSE;
+        }
+
+    };
+}
+
+
+
+
+void procman_lsof(ProcData *procdata)
+{
+    GtkListStore *model = \
+        gtk_list_store_new(PROCMAN_LSOF_NCOLS,
+                           CAIRO_GOBJECT_TYPE_SURFACE, // PROCMAN_LSOF_COL_SURFACE
+                           G_TYPE_STRING,              // PROCMAN_LSOF_COL_PROCESS
+                           G_TYPE_UINT,                // PROCMAN_LSOF_COL_PID
+                           G_TYPE_STRING               // PROCMAN_LSOF_COL_FILENAME
+        );
+
+    GtkWidget *tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_object_unref(model);
+
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *renderer;
+
+    // SURFACE / PROCESS
+
+    column = gtk_tree_view_column_new();
+
+    renderer = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "surface", PROCMAN_LSOF_COL_SURFACE,
+                                        NULL);
+
+    renderer = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "text", PROCMAN_LSOF_COL_PROCESS,
+                                        NULL);
+
+    gtk_tree_view_column_set_title(column, _("Process"));
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PROCESS);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_column_set_min_width(column, 10);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), PROCMAN_LSOF_COL_PROCESS,
+                                         GTK_SORT_ASCENDING);
+
+
+    // PID
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("PID"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_PID,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PID);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    // FILENAME
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("Filename"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_FILENAME,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_FILENAME);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    GtkWidget *dialog; /* = gtk_dialog_new_with_buttons(_("Search for Open Files"), NULL,
+                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+                                                        NULL); */
+    dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(procdata->app));
+    gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
+    // gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_title(GTK_WINDOW(dialog), _("Search for Open Files"));
+
+    // g_signal_connect(G_OBJECT(dialog), "response",
+    //                           G_CALLBACK(close_dialog), NULL);
+    gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(dialog), 575, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(dialog), 12);
+    GtkWidget *mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_add(GTK_CONTAINER(dialog), mainbox);
+    gtk_box_set_spacing(GTK_BOX(mainbox), 6);
+
+
+    // Label, entry and search button
+
+    GtkWidget *hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), hbox1, FALSE, FALSE, 0);
+
+    GtkWidget *image = gtk_image_new_from_icon_name("edit-find", GTK_ICON_SIZE_DIALOG);
+    gtk_box_pack_start(GTK_BOX(hbox1), image, FALSE, FALSE, 0);
+
+
+    GtkWidget *vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox1), vbox2, TRUE, TRUE, 0);
+
+
+    GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox, TRUE, TRUE, 0);
+    GtkWidget *label = gtk_label_new_with_mnemonic(_("_Name contains:"));
+    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+    GtkWidget *entry = gtk_entry_new();
+
+    gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
+
+    GtkWidget *search_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                         "label", "gtk-find",
+                                                         "use-stock", TRUE,
+                                                         "use-underline", TRUE,
+                                                         NULL));
+
+    gtk_box_pack_start(GTK_BOX(hbox), search_button, FALSE, FALSE, 0);
+
+    GtkWidget *clear_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-clear",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    /* The default accelerator collides with the default close accelerator. */
+    gtk_button_set_label(GTK_BUTTON(clear_button), _("C_lear"));
+    gtk_box_pack_start(GTK_BOX(hbox), clear_button, FALSE, FALSE, 0);
+
+
+    GtkWidget *case_button = gtk_check_button_new_with_mnemonic(_("Case insensitive matching"));
+    GtkWidget *hbox3 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox3), case_button, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox3, FALSE, FALSE, 0);
+
+
+    GtkWidget *results_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), results_box, FALSE, FALSE, 0);
+    GtkWidget *results_label = gtk_label_new_with_mnemonic(_("S_earch results:"));
+    gtk_box_pack_start(GTK_BOX(results_box), results_label, FALSE, FALSE, 0);
+    GtkWidget *count_label = gtk_label_new(NULL);
+    gtk_box_pack_end(GTK_BOX(results_box), count_label, FALSE, FALSE, 0);
+
+    // Scrolled TreeView
+    GtkWidget *scrolled = gtk_scrolled_window_new(NULL, NULL);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
+                                   GTK_POLICY_AUTOMATIC,
+                                   GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled),
+                                        GTK_SHADOW_IN);
+    gtk_container_add(GTK_CONTAINER(scrolled), tree);
+    gtk_box_pack_start(GTK_BOX(mainbox), scrolled, TRUE, TRUE, 0);
+
+    GtkWidget *bottom_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+
+    GtkWidget *close_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-close",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    gtk_box_pack_start(GTK_BOX(mainbox), bottom_box, FALSE, FALSE, 0);
+    gtk_box_pack_end(GTK_BOX(bottom_box), close_button, FALSE, FALSE, 0);
+
+
+    GUI *gui = new GUI; // wil be deleted by the close button or delete-event
+    gui->procdata = procdata;
+    gui->model = model;
+    gui->window = GTK_WINDOW(dialog);
+    gui->entry = GTK_ENTRY(entry);
+    gui->count = GTK_LABEL(count_label);
+
+    g_signal_connect(G_OBJECT(entry), "activate",
+                     G_CALLBACK(GUI::search_entry_activate), gui);
+    g_signal_connect(G_OBJECT(clear_button), "clicked",
+                     G_CALLBACK(GUI::clear_button_clicked), gui);
+    g_signal_connect(G_OBJECT(search_button), "clicked",
+                     G_CALLBACK(GUI::search_button_clicked), gui);
+    g_signal_connect(G_OBJECT(close_button), "clicked",
+                     G_CALLBACK(GUI::close_button_clicked), gui);
+    g_signal_connect(G_OBJECT(case_button), "toggled",
+                     G_CALLBACK(GUI::case_button_toggled), gui);
+    g_signal_connect(G_OBJECT(dialog), "delete-event",
+                     G_CALLBACK(GUI::window_delete_event), gui);
+
+
+    gtk_widget_show_all(dialog);
+}
+
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/9.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/9.html new file mode 100644 index 00000000..b1d95a0b --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/9.html @@ -0,0 +1,1197 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
#include <config.h>
+
+#include <glibtop/procmap.h>
+#include <glibtop/mountlist.h>
+#include <sys/stat.h>
+#include <glib/gi18n.h>
+
+#include <string>
+#include <map>
+#include <sstream>
+#include <iomanip>
+#include <stdexcept>
+
+using std::string;
+
+
+#include "procman.h"
+#include "memmaps.h"
+#include "proctable.h"
+#include "util.h"
+
+
+/* be careful with this enum, you could break the column names */
+enum
+{
+    MMAP_COL_FILENAME,
+    MMAP_COL_VMSTART,
+    MMAP_COL_VMEND,
+    MMAP_COL_VMSZ,
+    MMAP_COL_FLAGS,
+    MMAP_COL_VMOFFSET,
+    MMAP_COL_PRIVATE_CLEAN,
+    MMAP_COL_PRIVATE_DIRTY,
+    MMAP_COL_SHARED_CLEAN,
+    MMAP_COL_SHARED_DIRTY,
+    MMAP_COL_DEVICE,
+    MMAP_COL_INODE,
+    MMAP_COL_MAX
+};
+
+
+namespace
+{
+    class OffsetFormater
+    {
+        string format;
+
+    public:
+
+        void set(const glibtop_map_entry &last_map)
+        {
+            this->format = (last_map.end <= G_MAXUINT32) ? "%08" G_GINT64_MODIFIER "x" : "%016" G_GINT64_MODIFIER "x";
+        }
+
+        string operator()(guint64 v) const
+        {
+            char buffer[17];
+            g_snprintf(buffer, sizeof buffer, this->format.c_str(), v);
+            return buffer;
+        }
+    };
+
+
+    class InodeDevices
+    {
+        typedef std::map<guint16, string> Map;
+        Map devices;
+
+    public:
+
+        void update()
+        {
+            this->devices.clear();
+
+            glibtop_mountlist list;
+            glibtop_mountentry *entries = glibtop_get_mountlist(&list, 1);
+
+            for (unsigned i = 0; i != list.number; ++i) {
+                struct stat buf;
+
+                if (stat(entries[i].devname, &buf) != -1)
+                    this->devices[buf.st_rdev] = entries[i].devname;
+            }
+
+            g_free(entries);
+        }
+
+        string get(guint64 dev64)
+        {
+            if (dev64 == 0)
+                return "";
+
+            guint16 dev = dev64 & 0xffff;
+
+            if (dev != dev64)
+                g_warning("weird device %" G_GINT64_MODIFIER "x", dev64);
+
+            Map::iterator it(this->devices.find(dev));
+
+            if (it != this->devices.end())
+                return it->second;
+
+            guint8 major, minor;
+            major = dev >> 8;
+            minor = dev;
+
+            std::ostringstream out;
+            out << std::hex
+                << std::setfill('0')
+                << std::setw(2) << unsigned(major)
+                << ':'
+                << std::setw(2) << unsigned(minor);
+
+            this->devices[dev] = out.str();
+            return out.str();
+        }
+    };
+
+
+    class MemMapsData
+    {
+    public:
+        guint timer;
+        GtkWidget *tree;
+        GSettings *settings;
+        ProcInfo *info;
+        OffsetFormater format;
+        mutable InodeDevices devices;
+        const char * const schema;
+
+        MemMapsData(GtkWidget *a_tree, GSettings *a_settings)
+            : tree(a_tree),
+            settings(a_settings),
+            schema("memmapstree")
+        {
+            procman_get_tree_state(this->settings, this->tree, this->schema);
+        }
+
+        ~MemMapsData()
+        {
+            procman_save_tree_state(this->settings, this->tree, this->schema);
+        }
+    };
+}
+
+
+struct glibtop_map_entry_cmp
+{
+    bool operator()(const glibtop_map_entry &a, const guint64 start) const
+    {
+        return a.start < start;
+    }
+
+    bool operator()(const guint64 &start, const glibtop_map_entry &a) const
+    {
+        return start < a.start;
+    }
+
+};
+
+
+static void
+update_row(GtkTreeModel *model, GtkTreeIter &row, const MemMapsData &mm, const glibtop_map_entry *memmaps)
+{
+    guint64 size;
+    string filename, device;
+    string vmstart, vmend, vmoffset;
+    char flags[5] = "----";
+
+    size = memmaps->end - memmaps->start;
+
+    if(memmaps->perm & GLIBTOP_MAP_PERM_READ)    flags [0] = 'r';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_WRITE)   flags [1] = 'w';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_EXECUTE) flags [2] = 'x';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_SHARED)  flags [3] = 's';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_PRIVATE) flags [3] = 'p';
+
+    if (memmaps->flags & (1 << GLIBTOP_MAP_ENTRY_FILENAME))
+      filename = memmaps->filename;
+
+    vmstart  = mm.format(memmaps->start);
+    vmend    = mm.format(memmaps->end);
+    vmoffset = mm.format(memmaps->offset);
+    device   = mm.devices.get(memmaps->device);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        MMAP_COL_FILENAME, filename.c_str(),
+                        MMAP_COL_VMSTART, vmstart.c_str(),
+                        MMAP_COL_VMEND, vmend.c_str(),
+                        MMAP_COL_VMSZ, size,
+                        MMAP_COL_FLAGS, flags,
+                        MMAP_COL_VMOFFSET, vmoffset.c_str(),
+                        MMAP_COL_PRIVATE_CLEAN, memmaps->private_clean,
+                        MMAP_COL_PRIVATE_DIRTY, memmaps->private_dirty,
+                        MMAP_COL_SHARED_CLEAN, memmaps->shared_clean,
+                        MMAP_COL_SHARED_DIRTY, memmaps->shared_dirty,
+                        MMAP_COL_DEVICE, device.c_str(),
+                        MMAP_COL_INODE, memmaps->inode,
+                        -1);
+}
+
+
+
+
+static void
+update_memmaps_dialog (MemMapsData *mmdata)
+{
+    GtkTreeModel *model;
+    glibtop_map_entry *memmaps;
+    glibtop_proc_map procmap;
+
+    memmaps = glibtop_get_proc_map (&procmap, mmdata->info->pid);
+    /* process has disappeared */
+    if(!memmaps or procmap.number == 0) return;
+
+    mmdata->format.set(memmaps[procmap.number - 1]);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+
+    GtkTreeIter iter;<--- Shadowed declaration
+
+    typedef std::map<guint64, GtkTreeIter> IterCache;
+    IterCache iter_cache;
+
+    /*
+      removes the old maps and
+      also fills a cache of start -> iter in order to speed
+      up add
+    */
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        while (true) {
+            char *vmstart = 0;
+            guint64 start;
+            gtk_tree_model_get(model, &iter,
+                               MMAP_COL_VMSTART, &vmstart,
+                               -1);
+
+            try {
+                std::istringstream(vmstart) >> std::hex >> start;
+            } catch (std::logic_error &e) {
+                g_warning("Could not parse %s", vmstart);
+                start = 0;
+            }
+
+            g_free(vmstart);
+
+            bool found = std::binary_search(memmaps, memmaps + procmap.number,
+                                            start, glibtop_map_entry_cmp());
+
+            if (found) {
+                iter_cache[start] = iter;
+                if (!gtk_tree_model_iter_next(model, &iter))
+                    break;
+            } else {
+                if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                    break;
+            }
+        }
+    }
+
+    mmdata->devices.update();
+
+    /*
+      add the new maps
+    */
+
+    for (guint i = 0; i != procmap.number; i++) {
+        GtkTreeIter iter;<--- Shadow variable
+        IterCache::iterator it(iter_cache.find(memmaps[i].start));
+
+        if (it != iter_cache.end())
+            iter = it->second;
+        else
+            gtk_list_store_prepend(GTK_LIST_STORE(model), &iter);
+
+        update_row(model, iter, *mmdata, &memmaps[i]);
+    }
+
+    g_free (memmaps);
+}
+
+
+
+static void
+dialog_response (GtkDialog * dialog, gint response_id, gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+
+    g_source_remove (mmdata->timer);
+
+    delete mmdata;
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+
+static MemMapsData*
+create_memmapsdata (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Filename"),
+        // xgettext: virtual memory start
+        N_("VM Start"),
+        // xgettext: virtual memory end
+        N_("VM End"),
+        // xgettext: virtual memory syze
+        N_("VM Size"),
+        N_("Flags"),
+        // xgettext: virtual memory offset
+        N_("VM Offset"),
+        // xgettext: memory that has not been modified since
+        // it has been allocated
+        N_("Private clean"),
+        // xgettext: memory that has been modified since it
+        // has been allocated
+        N_("Private dirty"),
+        // xgettext: shared memory that has not been modified
+        // since it has been allocated
+        N_("Shared clean"),
+        // xgettext: shared memory that has been modified
+        // since it has been allocated
+        N_("Shared dirty"),
+        N_("Device"),
+        N_("Inode")
+    };
+
+    model = gtk_list_store_new (MMAP_COL_MAX,
+                                G_TYPE_STRING, /* MMAP_COL_FILENAME  */
+                                G_TYPE_STRING, /* MMAP_COL_VMSTART     */
+                                G_TYPE_STRING, /* MMAP_COL_VMEND     */
+                                G_TYPE_UINT64, /* MMAP_COL_VMSZ     */
+                                G_TYPE_STRING, /* MMAP_COL_FLAGS     */
+                                G_TYPE_STRING, /* MMAP_COL_VMOFFSET  */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_DIRTY */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_DIRTY */
+                                G_TYPE_STRING, /* MMAP_COL_DEVICE     */
+                                G_TYPE_UINT64 /* MMAP_COL_INODE     */
+                                );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < MMAP_COL_MAX; i++) {
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(tree), col);
+
+        switch (i) {
+            case MMAP_COL_PRIVATE_CLEAN:
+            case MMAP_COL_PRIVATE_DIRTY:
+            case MMAP_COL_SHARED_CLEAN:
+            case MMAP_COL_SHARED_DIRTY:
+            case MMAP_COL_VMSZ:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                         &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+                break;
+        }
+
+
+        switch (i) {
+            case MMAP_COL_VMSTART:
+            case MMAP_COL_VMEND:
+            case MMAP_COL_FLAGS:
+            case MMAP_COL_VMOFFSET:
+            case MMAP_COL_DEVICE:
+                g_object_set(cell, "family", "monospace", NULL);
+                break;
+        }
+    }
+
+    return new MemMapsData(tree, procdata->settings);
+}
+
+
+static gboolean
+memmaps_timer (gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+    g_assert(model);
+
+    update_memmaps_dialog (mmdata);
+
+    return TRUE;
+}
+
+
+static void
+create_single_memmaps_dialog (GtkTreeModel *model, GtkTreePath *path,
+                              GtkTreeIter *iter, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    MemMapsData *mmdata;
+    GtkWidget *memmapsdialog;
+    GtkWidget *dialog_vbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    ProcInfo *info;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    mmdata = create_memmapsdata (procdata);
+    mmdata->info = info;
+
+    memmapsdialog = gtk_dialog_new_with_buttons (_("Memory Maps"), GTK_WINDOW (procdata->app),
+                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                 "gtk-close", GTK_RESPONSE_CLOSE,
+                                                 NULL);
+    gtk_window_set_resizable(GTK_WINDOW(memmapsdialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(memmapsdialog), 620, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(memmapsdialog), 5);
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG(memmapsdialog));
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Memory maps for process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), label, FALSE, TRUE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    gtk_container_add (GTK_CONTAINER (scrolled), mmdata->tree);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), mmdata->tree);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+
+    g_signal_connect(G_OBJECT(memmapsdialog), "response",
+                              G_CALLBACK(dialog_response), mmdata);
+
+    gtk_widget_show_all (memmapsdialog);
+
+    mmdata->timer = g_timeout_add_seconds (5, memmaps_timer, mmdata);
+
+    update_memmaps_dialog (mmdata);
+}
+
+
+void
+create_memmaps_dialog (ProcData *procdata)
+{
+    /* TODO: do we really want to open multiple dialogs ? */
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_memmaps_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/index.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/index.html new file mode 100644 index 00000000..02bb6ffc --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/index.html @@ -0,0 +1,323 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/cgroups.cpp
27variableScope398styleThe scope of the variable 'paren_offset' can be reduced.
27variableScope398styleThe scope of the variable 'off' can be reduced.
27variableScope398styleThe scope of the variable 'tmp_size' can be reduced.
55cstyleCast398styleC-style pointer casting
src/disks.cpp
202redundantAssignment563styleVariable 'res' is reassigned a value before the old one has been used.
src/gsm_color_button.c
648variableScope398styleThe scope of the variable 'color_chooser' can be reduced.
src/interface.cpp
452cstyleCast398styleC-style pointer casting
454cstyleCast398styleC-style pointer casting
src/load-graph.cpp
41shadowVariable398styleLocal variable 'n' shadows outer variable
164shadowVariable398styleLocal variable 'i' shadows outer variable
src/load-graph.h
36noExplicitConstructor398styleStruct 'LoadGraph' has a constructor with 1 argument that is not explicit.
src/lsof.cpp
164shadowVariable398styleLocal variable 'count' shadows outer variable
src/memmaps.cpp
269shadowVariable398styleLocal variable 'iter' shadows outer variable
src/msm-resources.c
9unusedStructMember563styleunion member 'Anonymous0::alignment' is never used.
9unusedStructMember563styleunion member 'Anonymous0::ptr' is never used.
src/openfiles.cpp
73nullPointerRedundantCheck476warningEither the condition 'res' is redundant or there is possible null pointer dereference: res.
205shadowVariable398styleLocal variable 'openfiles' shadows outer variable
247variableScope398styleThe scope of the variable 'column' can be reduced.
248variableScope398styleThe scope of the variable 'cell' can be reduced.
src/prettytable.h
39unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_opened'
40unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_closed'
src/procdialogs.cpp
294noExplicitConstructor398styleClass 'SpinButtonUpdater' has a constructor with 1 argument that is not explicit.
415shadowVariable398styleLocal variable 'column' shadows outer variable
475cstyleCast398styleC-style pointer casting
498cstyleCast398styleC-style pointer casting
513cstyleCast398styleC-style pointer casting
src/procman-app.cpp
348uninitMemberVar398warningMember variable 'ProcmanApp::procdata' is not initialized in the constructor.
src/procman.cpp
34uninitMemberVarPrivate398warningMember variable 'ProcData::uimanager' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::action_group' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::statusbar' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::loadavg' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::endprocessbutton' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::popup_menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::disk_list' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::notebook' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::config' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::selection' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::settings' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::app' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::frequency' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::smooth_refresh' is not initialized in the constructor.
112shadowVariable398styleLocal variable 'order' shadows outer variable
162shadowVariable398styleLocal variable 'order' shadows outer variable
src/procman.h
103uninitMemberVar398warningMember variable 'MutableProcInfo::cgroup_name' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::unit' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::session' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::seat' is not initialized in the constructor.
173noExplicitConstructor398styleClass 'ProcInfo' has a constructor with 1 argument that is not explicit.
src/procproperties.cpp
208variableScope398styleThe scope of the variable 'column' can be reduced.
209variableScope398styleThe scope of the variable 'cell' can be reduced.
src/proctable.cpp
920shadowVariable398styleLocal variable 'arguments' shadows outer variable
929shadowVariable398styleLocal variable 'tooltip' shadows outer variable
1016shadowVariable398styleLocal variable 'it' shadows outer variable
1022shadowVariable398styleLocal variable 'it' shadows outer variable
1068shadowVariable398styleLocal variable 'it' shadows outer variable
1073shadowVariable398styleLocal variable 'it' shadows outer variable
src/selinux.cpp
21varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
src/smooth_refresh.h
22noExplicitConstructor398styleClass 'SmoothRefresh' has a constructor with 1 argument that is not explicit.
src/sysinfo.cpp
126unusedPrivateFunction398styleUnused private function: 'SysInfo::get_os_type'
233cstyleCast398styleC-style pointer casting
343cstyleCast398styleC-style pointer casting
509uninitMemberVar398warningMember variable 'LSBSysInfo::lsb_fd' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::name' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::release' is not initialized in the constructor.
515missingOverridestyleThe function 'set_distro_labels' overrides a function in a base class but is not marked with a 'override' specifier.
570shadowVariable398styleLocal variable 'release' shadows outer variable
615unusedPrivateFunction398styleUnused private function: 'LSBSysInfo::sync_lsb_release'
626variableScope398styleThe scope of the variable 'codename' can be reduced.
626shadowVariable398styleLocal variable 'release' shadows outer variable
690stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
697stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
701stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
736variableScope398styleThe scope of the variable 'len' can be reduced.
738stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
1001unreadVariable563styleVariable 'table_count' is assigned a value that is never used.
+
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/stats.html b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/stats.html new file mode 100644 index 00000000..aa8922ed --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/stats.html @@ -0,0 +1,189 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+

Top 10 files for warning severity, total findings: 24
+   15  src/procman.cpp
+   4   src/procman.h
+   3   src/sysinfo.cpp
+   1   src/procman-app.cpp
+   1   src/openfiles.cpp
+

+

Top 10 files for portability severity, total findings: 1
+   1  src/selinux.cpp
+

+

Top 10 files for performance severity, total findings: 4
+   4  src/sysinfo.cpp
+

+

Top 10 files for style severity, total findings: 47
+   10  src/sysinfo.cpp
+   6   src/proctable.cpp
+   5   src/procdialogs.cpp
+   4   src/cgroups.cpp
+   3   src/openfiles.cpp
+   2   src/procproperties.cpp
+   2   src/procman.cpp
+   2   src/prettytable.h
+   2   src/msm-resources.c
+   2   src/load-graph.cpp
+

+ +
+ +
+ + diff --git a/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/style.css b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/style.css new file mode 100644 index 00000000..3897bfaf --- /dev/null +++ b/2023-09-05-135640-0574-cppcheck@c439634163d9_test-ci/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-09-11-094458-6134-1@4954edb594c8_master/index.html b/2023-09-11-094458-6134-1@4954edb594c8_master/index.html new file mode 100644 index 00000000..5a4965b4 --- /dev/null +++ b/2023-09-11-094458-6134-1@4954edb594c8_master/index.html @@ -0,0 +1,136 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@6642c989495b
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 16.0.6 (Fedora 16.0.6-2.fc38) +
Date:Mon Sep 11 09:44:58 2023
+

Bug Summary

+ + + + + + + +
Bug TypeQuantityDisplay?
All Bugs14
Logic error
Use of identical expressions1
Unused code
Dead assignment1
Unreachable code12
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
Unused codeDead assignmentrootdir/src/disks.cppget_mount_opt2011View Report
Unused codeUnreachable coderootdir/src/procman-app.cppon_command_line3811View Report
Unused codeUnreachable coderootdir/src/util.cppio_rate_cell_data_func4941View Report
Unused codeUnreachable coderootdir/src/util.cppstatus_cell_data_func5911View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_gicon421View Report
Unused codeUnreachable coderootdir/src/util.cppduration_cell_data_func5351View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_na_cell_data_func3841View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_na_cell_data_func4561View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_cell_data_func4221View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_icon131View Report
Unused codeUnreachable coderootdir/src/util.cpptime_cell_data_func5641View Report
Unused codeUnreachable coderootdir/src/procman-app.cpptimeouts_changed_cb1511View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_cell_data_func3501View Report
Logic errorUse of identical expressionsusr/include/sigc++-2.0/sigc++/visit_each.hoperator()981View Report
+ + diff --git a/2023-09-11-094458-6134-1@4954edb594c8_master/report-22e004.html b/2023-09-11-094458-6134-1@4954edb594c8_master/report-22e004.html new file mode 100644 index 00000000..102f51bb --- /dev/null +++ b/2023-09-11-094458-6134-1@4954edb594c8_master/report-22e004.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 381, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-094458-6134-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
This statement is never executed
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2023-09-11-094458-6134-1@4954edb594c8_master/report-491eb3.html b/2023-09-11-094458-6134-1@4954edb594c8_master/report-491eb3.html new file mode 100644 index 00000000..7dccf993 --- /dev/null +++ b/2023-09-11-094458-6134-1@4954edb594c8_master/report-491eb3.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 494, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-094458-6134-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-11-094458-6134-1@4954edb594c8_master/report-4d889d.html b/2023-09-11-094458-6134-1@4954edb594c8_master/report-4d889d.html new file mode 100644 index 00000000..0097a3b2 --- /dev/null +++ b/2023-09-11-094458-6134-1@4954edb594c8_master/report-4d889d.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 591, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-094458-6134-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-11-094458-6134-1@4954edb594c8_master/report-633ebf.html b/2023-09-11-094458-6134-1@4954edb594c8_master/report-633ebf.html new file mode 100644 index 00000000..d0eee411 --- /dev/null +++ b/2023-09-11-094458-6134-1@4954edb594c8_master/report-633ebf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 42, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-094458-6134-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
This statement is never executed
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2023-09-11-094458-6134-1@4954edb594c8_master/report-6c54e6.html b/2023-09-11-094458-6134-1@4954edb594c8_master/report-6c54e6.html new file mode 100644 index 00000000..fa5dbde7 --- /dev/null +++ b/2023-09-11-094458-6134-1@4954edb594c8_master/report-6c54e6.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 535, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-094458-6134-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-11-094458-6134-1@4954edb594c8_master/report-6c8186.html b/2023-09-11-094458-6134-1@4954edb594c8_master/report-6c8186.html new file mode 100644 index 00000000..16e021dd --- /dev/null +++ b/2023-09-11-094458-6134-1@4954edb594c8_master/report-6c8186.html @@ -0,0 +1,886 @@ + + + +/usr/include/sigc++-2.0/sigc++/visit_each.h + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:usr/include/sigc++-2.0/sigc++/visit_each.h
Warning:line 98, column 64
identical expressions on both sides of logical operator
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-094458-6134-1 -x c++ procman.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright 2002, The libsigc++ Development Team
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18#ifndef _SIGC_VISIT_EACH_HPP_
19#define _SIGC_VISIT_EACH_HPP_
20
21#include <sigc++/type_traits.h>
22#include <type_traits>
23
24namespace sigc {
25
26#ifndef DOXYGEN_SHOULD_SKIP_THIS
27namespace internal {
28
29//This should really be an inner class of limit_derived_target, without the T_limit template type,
30//But the SUN CC 5.7 (not earlier versions) compiler finds it ambiguous when we specify a particular specialization of it.
31//and does not seem to allow us to tell it explicitly that it's an inner class.
32template <bool I_derived, class T_type, class T_limit>
33struct with_type;
34
35//Specialization for I_derived = false
36template <class T_type, class T_limit> struct
37with_type<false, T_type, T_limit>
38{
39 static void execute_(const T_type&, const T_limit&) {}
40};
41
42//Specialization for I_derived = true
43template <class T_type, class T_limit>
44struct with_type<true, T_type, T_limit>
45{
46 static void execute_(const T_type& _A_type, const T_limit& _A_action)
47 { _A_action.action_(_A_type); }
48};
49
50
51/// Helper struct for visit_each_type().
52template <class T_target, class T_action>
53struct limit_derived_target
54{
55 typedef limit_derived_target<T_target, T_action> T_self;
56
57 template <class T_type>
58 void operator()(const T_type& _A_type) const
59 {
60 with_type<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
61 }
62
63 limit_derived_target(const T_action& _A_action)
64 : action_(_A_action)
65 {}
66
67 T_action action_;
68};
69
70// Specialization for T_target pointer types, to provide a slightly different execute_() implementation.
71
72template <bool I_derived, class T_type, class T_limit>
73struct with_type_pointer;
74
75//Specialization for I_derived = false
76template <class T_type, class T_limit>
77struct with_type_pointer<false, T_type, T_limit>
78{
79 static void execute_(const T_type&, const T_limit&) {}
80};
81
82//Specialization for I_derived = true
83template <class T_type, class T_limit>
84struct with_type_pointer<true, T_type, T_limit>
85{
86 static void execute_(const T_type& _A_type, const T_limit& _A_action)
87 { _A_action.action_(&_A_type); }
88};
89
90template <class T_target, class T_action>
91struct limit_derived_target<T_target*, T_action>
92{
93 typedef limit_derived_target<T_target*, T_action> T_self;
94
95 template <class T_type>
96 void operator()(const T_type& _A_type) const
97 {
98 with_type_pointer<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
identical expressions on both sides of logical operator
99 }
100
101 limit_derived_target(const T_action& _A_action)
102 : action_(_A_action)
103 {}
104
105 T_action action_;
106};
107
108} /* namespace internal */
109#endif // DOXYGEN_SHOULD_SKIP_THIS
110
111// struct visitor was introduced as a result of https://bugzilla.gnome.org/show_bug.cgi?id=724496
112// The advantage of using specializations of a template struct instead of overloads of
113// a template function is described by Herb Sutter in http://www.gotw.ca/publications/mill17.htm
114// In libsigc++ the main reason for using this technique is that we can avoid using ADL
115// (argument-dependent lookup), and therefore there is no risk that a visit_each() overload
116// in e.g. Boost is selected by mistake.
117
118/** sigc::visitor<T_functor>::do_visit_each() performs a functor on each of the targets of a functor.
119 * All unknown types just call @a _A_action on them.
120 * Add specializations that specialize the @a T_functor argument for your own
121 * functor types, so that subobjects get visited. This is needed to enable
122 * auto-disconnection support for your functor types.
123 *
124 * @par Example:
125 * @code
126 * namespace some_ns
127 * {
128 * struct some_functor
129 * {
130 * void operator()() {}
131 * some_possibly_sigc_trackable_derived_type some_data_member;
132 * some_other_functor_type some_other_functor;
133 * };
134 * }
135 *
136 * namespace sigc
137 * {
138 * template <>
139 * struct visitor<some_ns::some_functor>
140 * {
141 * template <class T_action>
142 * static void do_visit_each(const T_action& _A_action,
143 * const some_ns::some_functor& _A_target)
144 * {
145 * sigc::visit_each(_A_action, _A_target.some_data_member);
146 * sigc::visit_each(_A_action, _A_target.some_other_functor);
147 * }
148 * };
149 * }
150 * @endcode
151 *
152 * @ingroup sigcfunctors
153 */
154template <class T_functor>
155struct visitor
156{
157 template <class T_action>
158 static void do_visit_each(const T_action& _A_action, const T_functor& _A_functor)
159 {
160 _A_action(_A_functor);
161 }
162};
163
164/** This function performs a functor on each of the targets of a functor.
165 *
166 * @ingroup sigcfunctors
167 */
168template <class T_action, class T_functor>
169void visit_each(const T_action& _A_action, const T_functor& _A_functor)
170{ sigc::visitor<T_functor>::do_visit_each(_A_action, _A_functor); }
171
172/** This function performs a functor on each of the targets
173 * of a functor limited to a restricted type.
174 *
175 * @ingroup sigcfunctors
176 */
177template <class T_type, class T_action, class T_functor>
178void visit_each_type(const T_action& _A_action, const T_functor& _A_functor)
179{
180 typedef internal::limit_derived_target<T_type, T_action> type_limited_action;
181
182 type_limited_action limited_action(_A_action);
183
184 //specifying the types of the template specialization prevents disconnection of bound trackable references (such as with std::ref()),
185 //probably because the visit_each<> specializations take various different template types,
186 //in various sequences, and we are probably specifying only a subset of them with this.
187 //
188 //But this is required by the AIX (and maybe IRIX MipsPro and Tru64) compilers.
189 //I guess that std::ref() therefore does not work on those platforms. murrayc
190 // sigc::visit_each<type_limited_action, T_functor>(limited_action, _A_functor);
191
192 //g++ (even slightly old ones) is our primary platform, so we could use the non-crashing version.
193 //However, the explicit version also fixes a crash in a slightly more common case: http://bugzilla.gnome.org/show_bug.cgi?id=169225
194 //Users (and distributors) of libsigc++ on AIX (and maybe IRIX MipsPro and Tru64) do
195 //need to use the version above instead, to allow compilation.
196
197 //Added 2014-03-20: The preceding comment probably does not apply any more,
198 //now when the visit_each<>() overloads have been replaced by visitor<> specializations.
199 //It's probably safe to add explicit template parameters on calls to visit_each(),
200 //visit_each_type() and visitor::do_visit_each(), if necessary.
201
202 sigc::visit_each(limited_action, _A_functor);
203}
204
205} /* namespace sigc */
206#endif
diff --git a/2023-09-11-094458-6134-1@4954edb594c8_master/report-77634b.html b/2023-09-11-094458-6134-1@4954edb594c8_master/report-77634b.html new file mode 100644 index 00000000..c2366a68 --- /dev/null +++ b/2023-09-11-094458-6134-1@4954edb594c8_master/report-77634b.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 384, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-094458-6134-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-11-094458-6134-1@4954edb594c8_master/report-7bbc8c.html b/2023-09-11-094458-6134-1@4954edb594c8_master/report-7bbc8c.html new file mode 100644 index 00000000..7136faad --- /dev/null +++ b/2023-09-11-094458-6134-1@4954edb594c8_master/report-7bbc8c.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 456, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-094458-6134-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-11-094458-6134-1@4954edb594c8_master/report-7ce786.html b/2023-09-11-094458-6134-1@4954edb594c8_master/report-7ce786.html new file mode 100644 index 00000000..52037d74 --- /dev/null +++ b/2023-09-11-094458-6134-1@4954edb594c8_master/report-7ce786.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 422, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-094458-6134-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-11-094458-6134-1@4954edb594c8_master/report-802eaf.html b/2023-09-11-094458-6134-1@4954edb594c8_master/report-802eaf.html new file mode 100644 index 00000000..ee118dc2 --- /dev/null +++ b/2023-09-11-094458-6134-1@4954edb594c8_master/report-802eaf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 13, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-094458-6134-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
This statement is never executed
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2023-09-11-094458-6134-1@4954edb594c8_master/report-8e6c9c.html b/2023-09-11-094458-6134-1@4954edb594c8_master/report-8e6c9c.html new file mode 100644 index 00000000..311fe2d8 --- /dev/null +++ b/2023-09-11-094458-6134-1@4954edb594c8_master/report-8e6c9c.html @@ -0,0 +1,1200 @@ + + + +disks.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/disks.cpp
Warning:line 201, column 13
Value stored to 'res' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name disks.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-094458-6134-1 -x c++ disks.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#ifdef __linux__1
4#include <mntent.h>
5#endif // __linux__
6
7#include <giomm.h>
8#include <giomm/themedicon.h>
9#include <gtk/gtk.h>
10#include <glibtop/mountlist.h>
11#include <glibtop/fsusage.h>
12#include <glib/gi18n.h>
13
14#include "procman.h"
15#include "disks.h"
16#include "util.h"
17#include "interface.h"
18#include "iconthemewrapper.h"
19
20namespace
21{
22 const unsigned DISK_ICON_SIZE = 24;
23}
24
25enum DiskColumns
26{
27 /* string columns* */
28 DISK_DEVICE,
29 DISK_DIR,
30 DISK_TYPE,
31 DISK_SUBVOLUME,
32 DISK_TOTAL,
33 DISK_FREE,
34 DISK_AVAIL,
35 /* USED has to be the last column */
36 DISK_USED,
37 // then unvisible columns
38 /* Surface column */
39 DISK_ICON,
40 /* numeric columns */
41 DISK_USED_PERCENTAGE,
42 DISK_N_COLUMNS
43};
44
45
46
47static void
48fsusage_stats(const glibtop_fsusage *buf,
49 guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
50 gint *percentage)
51{
52 guint64 total = buf->blocks * buf->block_size;
53
54 if (!total) {
55 /* not a real device */
56 *btotal = *bfree = *bavail = *bused = 0ULL;
57 *percentage = 0;
58 } else {
59 int percent;
60 *btotal = total;
61 *bfree = buf->bfree * buf->block_size;
62 *bavail = buf->bavail * buf->block_size;
63 *bused = *btotal - *bfree;
64 /* percent = 100.0f * *bused / *btotal; */
65 percent = 100 * *bused / (*bused + *bavail);
66 *percentage = CLAMP(percent, 0, 100)(((percent) > (100)) ? (100) : (((percent) < (0)) ? (0)
: (percent)))
;
67 }
68}
69
70
71namespace
72{
73 string get_icon_for_path(const std::string& path)
74 {
75 using namespace Glib;
76 using namespace Gio;
77
78 // FIXME: I don't know whether i should use Volume or Mount or UnixMount
79 // all i need an icon name.
80 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
81
82 std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
83
84 for (size_t i = 0; i != mounts.size(); ++i) {
85 if (mounts[i]->get_name() != path)
86 continue;
87
88 RefPtr<Icon> icon = mounts[i]->get_icon();
89 RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
90
91 if (themed_icon) {
92 char* name = 0;
93 // FIXME: not wrapped yet
94 g_object_get(G_OBJECT(themed_icon->gobj())((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((themed_icon->gobj())), (((GType) ((20) << (2)))
)))))
, "name", &name, NULL__null);
95 return make_string(name);
96 }
97 }
98
99 return "";
100 }
101}
102
103
104static Glib::RefPtr<Gdk::Pixbuf>
105get_icon_for_device(const char *mountpoint)
106{
107 procman::IconThemeWrapper icon_theme;
108 string icon_name = get_icon_for_path(mountpoint);
109 if (icon_name == "")
110 // FIXME: defaults to a safe value
111 icon_name = "drive-harddisk"; // get_icon_for_path("/");
112 return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
113}
114
115
116static gboolean
117find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
118 GtkTreeIter *result)
119{
120 GtkTreeIter iter;
121 gboolean found = FALSE(0);
122
123 if (gtk_tree_model_get_iter_first(model, &iter)) {
124 do {
125 char *dir;
126
127 gtk_tree_model_get(model, &iter,
128 DISK_DIR, &dir,
129 -1);
130
131 if (dir && !strcmp(dir, mountpoint)) {
132 *result = iter;
133 found = TRUE(!(0));
134 }
135
136 g_free(dir);
137
138 } while (!found && gtk_tree_model_iter_next(model, &iter));
139 }
140
141 return found;
142}
143
144
145
146static void
147remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
148{
149 GtkTreeIter iter;
150
151 if (!gtk_tree_model_get_iter_first(model, &iter))
152 return;
153
154 while (true) {
155 char *dir;
156 guint i;
157 gboolean found = FALSE(0);
158
159 gtk_tree_model_get(model, &iter,
160 DISK_DIR, &dir,
161 -1);
162
163 for (i = 0; i != n; ++i) {
164 if (!strcmp(dir, entries[i].mountdir)) {
165 found = TRUE(!(0));
166 break;
167 }
168 }
169
170 g_free(dir);
171
172 if (!found) {
173 if (!gtk_list_store_remove(GTK_LIST_STORE(model)((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_list_store_get_type ()))))))
, &iter))
174 break;
175 else
176 continue;
177 }
178
179 if (!gtk_tree_model_iter_next(model, &iter))
180 break;
181 }
182}
183
184#ifdef __linux__1
185static char *
186get_mount_opt(const glibtop_mountentry *entry, const char* opt)
187{
188 char *opt_value = NULL__null;
189 const struct mntent *mnt;
190 FILE *fp;
191
192 if (!(fp = setmntent(MOUNTED"/etc/mtab", "r"))) {
193 goto out;
194 }
195
196 while ((mnt = getmntent(fp))) {
197 if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
198 (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
199 char *res;
200
201 res = hasmntopt(mnt, "subvol");
Value stored to 'res' is never read
202 if ((res = hasmntopt(mnt, "subvol")) != NULL__null) {
203 char **strs = g_strsplit_set(res, "=", 2);
204
205 if (g_strv_length(strs) == 2) {
206 char *value = strs[1];
207 if (g_strcmp0 (value,"/root") == 0)
208 opt_value = g_strdup("/")g_strdup_inline ("/");
209 else
210 opt_value = g_strdup(strs[1])g_strdup_inline (strs[1]);
211 g_strfreev(strs);
212 }
213 }
214 break;
215 }
216 }
217
218 endmntent(fp);
219
220 out:
221 return opt_value;
222}
223#endif // __linux__
224
225
226static void
227add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
228{
229 Glib::RefPtr<Gdk::Pixbuf> pixbuf;
230 cairo_surface_t *surface;
231 GtkTreeIter iter;
232 glibtop_fsusage usage;
233 guint64 bused, bfree, bavail, btotal;
234 gint percentage;
235#ifdef __linux__1
236 char *subvol = NULL__null;
237#endif // __linux__
238
239 glibtop_get_fsusage(&usage, entry->mountdir);
240
241 if (not show_all_fs and usage.blocks == 0) {
242 if (find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
243 gtk_list_store_remove(list, &iter);
244 return;
245 }
246
247 fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
248#ifdef __linux__1
249 subvol = get_mount_opt(entry, "subvol");
250#endif // __linux__
251 pixbuf = get_icon_for_device(entry->mountdir);
252 surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL__null);
253
254 /* if we can find a row with the same mountpoint, we get it but we
255 still need to update all the fields.
256 This makes selection persistent.
257 */
258 if (!find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
259 gtk_list_store_append(list, &iter);
260
261 gtk_list_store_set(list, &iter,
262 DISK_ICON, surface,
263 DISK_DEVICE, entry->devname,
264 DISK_DIR, entry->mountdir,
265 DISK_TYPE, entry->type,
266#ifdef __linux__1
267
268 DISK_SUBVOLUME, subvol != NULL__null ? subvol : "",
269#else
270 DISK_SUBVOLUME, "",
271#endif // __linux__
272 DISK_USED_PERCENTAGE, percentage,
273 DISK_TOTAL, btotal,
274 DISK_FREE, bfree,
275 DISK_AVAIL, bavail,
276 DISK_USED, bused,
277 -1);
278#ifdef __linux__1
279 g_free (subvol);
280#endif // __linux__
281}
282
283
284
285int
286cb_update_disks(gpointer data)
287{
288 ProcData *const procdata = static_cast<ProcData*>(data);
289
290 GtkListStore *list;
291 glibtop_mountentry * entries;
292 glibtop_mountlist mountlist;
293 guint i;
294
295 list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)))((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_tree_view_get_model(((((GtkTreeView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((procdata->disk_list)), ((gtk_tree_view_get_type
()))))))))), ((gtk_list_store_get_type ()))))))
;
296
297 entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
298
299 remove_old_disks(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entries, mountlist.number);
300
301 for (i = 0; i < mountlist.number; i++)
302 add_disk(list, &entries[i], procdata->config.show_all_fs);
303
304 g_free(entries);
305
306 return TRUE(!(0));
307}
308
309
310static void
311cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
312{
313 ProcData * const procdata = static_cast<ProcData*>(user_data);
314
315 procman_save_tree_state(procdata->settings,
316 GTK_WIDGET(treeview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_widget_get_type ()))))))
,
317 "disktreenew");
318}
319
320
321static void
322open_dir(GtkTreeView *tree_view,
323 GtkTreePath *path,
324 GtkTreeViewColumn *column,
325 gpointer user_data)
326{
327 GtkTreeIter iter;
328 GtkTreeModel *model;
329 char *dir, *url;
330
331 model = gtk_tree_view_get_model(tree_view);
332
333 if (!gtk_tree_model_get_iter(model, &iter, path)) {
334 char *p;
335 p = gtk_tree_path_to_string(path);
336 g_warning("Cannot get iter for path '%s'\n", p);
337 g_free(p);
338 return;
339 }
340
341 gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
342
343 url = g_strdup_printf("file://%s", dir);
344
345 GError* error = 0;
346 if (!g_app_info_launch_default_for_uri(url, NULL__null, &error)) {
347 g_warning("Cannot open '%s' : %s\n", url, error->message);
348 g_error_free(error);
349 }
350
351 g_free(url);
352 g_free(dir);
353}
354
355static guint timeout_id = 0;
356static GtkTreeViewColumn *current_column;
357
358static gboolean
359save_column_width (gpointer data)
360{
361 gint width;
362 gchar *key;
363 int id;
364 GSettings *settings;
365
366 settings = g_settings_get_child (G_SETTINGS (data)((((GSettings*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((g_settings_get_type ()))))))
, "disktreenew");
367 id = gtk_tree_view_column_get_sort_column_id (current_column);
368 width = gtk_tree_view_column_get_width (current_column);
369
370 key = g_strdup_printf ("col-%d-width", id);
371 g_settings_set_int(settings, key, width);
372 g_free (key);
373
374 if (timeout_id) {
375 g_source_remove (timeout_id);
376 timeout_id = 0;
377 }
378
379 return FALSE(0);
380}
381
382static void
383cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
384{
385 current_column = GTK_TREE_VIEW_COLUMN(widget)((((GtkTreeViewColumn*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((widget)), ((gtk_tree_view_column_get_type (
)))))))
;
386
387 if (timeout_id)
388 g_source_remove (timeout_id);
389
390 timeout_id = g_timeout_add (250, save_column_width, data);
391}
392
393void
394create_disk_view(ProcData *procdata, GtkBuilder *builder)
395{
396 GtkWidget *scrolled;
397 GtkWidget *disk_tree;
398 GtkListStore *model;
399 GtkTreeViewColumn *col;
400 GtkCellRenderer *cell;
401 guint i;
402
403 const gchar * const titles[] = {
404 N_("Device")("Device"),
405 N_("Directory")("Directory"),
406 N_("Type")("Type"),
407 N_("SubVolume")("SubVolume"),
408 N_("Total")("Total"),
409 N_("Free")("Free"),
410 N_("Available")("Available"),
411 N_("Used")("Used")
412 };
413
414 scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "disks_scrolled"))), ((
gtk_widget_get_type ()))))))
;
415
416 model = gtk_list_store_new(DISK_N_COLUMNS, /* n columns */
417 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DEVICE */
418 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DIR */
419 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_TYPE */
420 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_SUBVOLUME */
421 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_TOTAL */
422 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_FREE */
423 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_AVAIL */
424 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_USED */
425 CAIRO_GOBJECT_TYPE_SURFACEcairo_gobject_surface_get_type (), /* DISK_ICON */
426 G_TYPE_INT((GType) ((6) << (2)))); /* DISK_USED_PERCENTAGE */
427
428 disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_model_get_type ()))))))
);
429 g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("row-activated"), (((GCallback) (open_dir))), (__null
), __null, (GConnectFlags) 0)
;
430 procdata->disk_list = disk_tree;
431 gtk_container_add(GTK_CONTAINER(scrolled)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((scrolled)), ((gtk_container_get_type ()))))))
, disk_tree);
432 g_object_unref(G_OBJECT(model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
);
433
434 /* icon + device */
435
436 col = gtk_tree_view_column_new();
437 cell = gtk_cell_renderer_pixbuf_new();
438 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
439 gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
440 NULL__null);
441
442 cell = gtk_cell_renderer_text_new();
443 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
444 gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
445 NULL__null);
446 gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE])gettext (titles[DISK_DEVICE]));
447 gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
448 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
449 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
450 gtk_tree_view_column_set_min_width (col, 30);
451 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
452 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
453 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
454
455 /* sizes - used */
456
457 for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
458 cell = gtk_cell_renderer_text_new();
459 col = gtk_tree_view_column_new();
460 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
461 gtk_tree_view_column_set_title(col, _(titles[i])gettext (titles[i]));
462 gtk_tree_view_column_set_sort_column_id(col, i);
463 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
464 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
465 gtk_tree_view_column_set_min_width (col, 30);
466 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
467 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
468 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
469
470 switch (i) {
471 case DISK_TOTAL:
472 case DISK_FREE:
473 case DISK_AVAIL:
474 g_object_set(cell, "xalign", 1.0f, NULL__null);
475 gtk_tree_view_column_set_cell_data_func(col, cell,
476 &procman::storage_size_cell_data_func,
477 GUINT_TO_POINTER(i)((gpointer) (gulong) (i)),
478 NULL__null);
479 break;
480
481 default:
482 gtk_tree_view_column_set_attributes(col, cell,
483 "text", i,
484 NULL__null);
485 break;
486 }
487 }
488
489 /* used + percentage */
490
491 col = gtk_tree_view_column_new();
492 cell = gtk_cell_renderer_text_new();
493 g_object_set(cell, "xalign", 1.0f, NULL__null);
494 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
495 gtk_tree_view_column_set_cell_data_func(col, cell,
496 &procman::storage_size_cell_data_func,
497 GUINT_TO_POINTER(DISK_USED)((gpointer) (gulong) (DISK_USED)),
498 NULL__null);
499
500 cell = gtk_cell_renderer_progress_new();
501 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
502 gtk_tree_view_column_set_attributes(col, cell, "value",
503 DISK_USED_PERCENTAGE, NULL__null);
504 gtk_tree_view_column_set_title(col, _(titles[DISK_USED])gettext (titles[DISK_USED]));
505 gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
506 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
507 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
508 gtk_tree_view_column_set_min_width (col, 150);
509 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
510 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
511 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
512
513 /* numeric sort */
514
515 procman_get_tree_state(procdata->settings, disk_tree,
516 "disktreenew");
517
518 g_signal_connect (G_OBJECT(disk_tree), "columns-changed",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
519 G_CALLBACK(cb_disk_columns_changed), procdata)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
;
520}
diff --git a/2023-09-11-094458-6134-1@4954edb594c8_master/report-c673b5.html b/2023-09-11-094458-6134-1@4954edb594c8_master/report-c673b5.html new file mode 100644 index 00000000..879dabb4 --- /dev/null +++ b/2023-09-11-094458-6134-1@4954edb594c8_master/report-c673b5.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 564, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-094458-6134-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-11-094458-6134-1@4954edb594c8_master/report-d507c5.html b/2023-09-11-094458-6134-1@4954edb594c8_master/report-d507c5.html new file mode 100644 index 00000000..569894e1 --- /dev/null +++ b/2023-09-11-094458-6134-1@4954edb594c8_master/report-d507c5.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 151, column 9
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-094458-6134-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
This statement is never executed
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2023-09-11-094458-6134-1@4954edb594c8_master/report-e8ff80.html b/2023-09-11-094458-6134-1@4954edb594c8_master/report-e8ff80.html new file mode 100644 index 00000000..1a404d61 --- /dev/null +++ b/2023-09-11-094458-6134-1@4954edb594c8_master/report-e8ff80.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 350, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-094458-6134-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-11-094458-6134-1@4954edb594c8_master/scanview.css b/2023-09-11-094458-6134-1@4954edb594c8_master/scanview.css new file mode 100644 index 00000000..cf8a5a6a --- /dev/null +++ b/2023-09-11-094458-6134-1@4954edb594c8_master/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/2023-09-11-094458-6134-1@4954edb594c8_master/sorttable.js b/2023-09-11-094458-6134-1@4954edb594c8_master/sorttable.js new file mode 100644 index 00000000..32faa078 --- /dev/null +++ b/2023-09-11-094458-6134-1@4954edb594c8_master/sorttable.js @@ -0,0 +1,492 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse',''); + cell.className = cell.className.replace('sorttable_sorted',''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j=0; j 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } + else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } + else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i=0; i=0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a,b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); + if (isNaN(bb)) bb = 0; + return aa-bb; + }, + sort_alpha: function(a,b) { + if (a[0]==b[0]) return 0; + if (a[0] 0 ) { + var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for(var i = t; i > b; --i) { + if ( comp_func(list[i], list[i-1]) < 0 ) { + var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write(" + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef _PROCMAN_PROCMAN_H_
+#define _PROCMAN_PROCMAN_H_
+
+#include <glibmm/refptr.h>
+#include <cairo-gobject.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+#include <glibtop/cpu.h>
+
+#include <time.h>
+#include <sys/types.h>
+
+#include <map>
+#include <string>
+
+struct ProcInfo;
+struct ProcData;
+struct LoadGraph;
+
+#include "smooth_refresh.h"
+#include "prettytable.h"
+
+#define GSM_GSETTINGS_SCHEMA "org.mate.system-monitor"
+
+enum
+{
+    ALL_PROCESSES,
+    MY_PROCESSES,
+    ACTIVE_PROCESSES
+};
+
+enum
+{
+    VERY_HIGH_PRIORITY,
+    HIGH_PRIORITY,
+    NORMAL_PRIORITY,
+    LOW_PRIORITY,
+    VERY_LOW_PRIORITY,
+    CUSTOM_PRIORITY
+};
+
+static const unsigned MIN_UPDATE_INTERVAL =   1 * 1000;
+static const unsigned MAX_UPDATE_INTERVAL = 100 * 1000;
+
+enum ProcmanTab
+{
+    PROCMAN_TAB_SYSINFO,
+    PROCMAN_TAB_PROCESSES,
+    PROCMAN_TAB_RESOURCES,
+    PROCMAN_TAB_DISKS
+};
+
+struct ProcConfig
+{
+    gint        width;
+    gint        height;
+    gint        xpos;
+    gint        ypos;
+    gboolean    maximized;
+    gboolean    show_kill_warning;
+    gboolean    show_tree;
+    gboolean    show_all_fs;
+    int         update_interval;
+    int         graph_update_interval;
+    int         disks_update_interval;
+    gint        whose_process;
+    gint        current_tab;
+    GdkRGBA     cpu_color[GLIBTOP_NCPU];
+    GdkRGBA     mem_color;
+    GdkRGBA     swap_color;
+    GdkRGBA     net_in_color;
+    GdkRGBA     net_out_color;
+    GdkRGBA     bg_color;
+    GdkRGBA     frame_color;
+    gint        num_cpus;
+    bool solaris_mode;
+    bool network_in_bits;
+};
+
+struct MutableProcInfo
+{
+MutableProcInfo()<--- Member variable 'MutableProcInfo::cgroup_name' is not initialized in the constructor.<--- Member variable 'MutableProcInfo::unit' is not initialized in the constructor.<--- Member variable 'MutableProcInfo::session' is not initialized in the constructor.<--- Member variable 'MutableProcInfo::seat' is not initialized in the constructor.
+  : disk_write_bytes_current(0ULL),
+    disk_read_bytes_current(0ULL),
+    disk_write_bytes_total(0ULL),
+    disk_read_bytes_total(0ULL),
+    status(0U)
+    { }
+
+    std::string user;
+
+    gchar wchan[40];
+
+    // all these members are filled with libgtop which uses
+    // guint64 (to have fixed size data) but we don't need more
+    // than an unsigned long (even for 32bit apps on a 64bit
+    // kernel) as these data are amounts, not offsets.
+    gulong vmsize;
+    gulong memres;
+    gulong memshared;
+    gulong memwritable;
+    gulong mem;
+
+#ifdef HAVE_WNCK
+    // wnck gives an unsigned long
+    gulong memxserver;
+#endif
+
+    gulong start_time;
+    guint64 cpu_time;
+    guint64 disk_write_bytes_current;
+    guint64 disk_read_bytes_current;
+    guint64 disk_write_bytes_total;
+    guint64 disk_read_bytes_total;
+    guint status;
+    guint pcpu;
+    gint nice;
+    gchar *cgroup_name;
+
+    gchar *unit;
+    gchar *session;
+    gchar *seat;
+
+    std::string owner;
+};
+
+class ProcInfo
+: public MutableProcInfo
+{
+    /* undefined */ ProcInfo& operator=(const ProcInfo&);
+    /* undefined */ ProcInfo(const ProcInfo&);
+
+    typedef std::map<guint, std::string> UserMap;
+    /* cached username */
+    static UserMap users;
+
+  public:
+
+    // TODO: use a set instead
+    // sorted by pid. The map has a nice property : it is sorted
+    // by pid so this helps a lot when looking for the parent node
+    // as ppid is nearly always < pid.
+    typedef std::map<pid_t, ProcInfo*> List;
+    typedef List::iterator Iterator;
+
+    static List all;
+
+    static ProcInfo* find(pid_t pid);
+    static Iterator begin() { return ProcInfo::all.begin(); }
+    static Iterator end() { return ProcInfo::all.end(); }
+
+    ProcInfo(pid_t pid);
+    ~ProcInfo();
+    // adds one more ref to icon
+    void set_icon(Glib::RefPtr<Gdk::Pixbuf> icon);
+    void set_user(guint uid);
+    std::string lookup_user(guint uid);
+
+    GtkTreeIter      node;
+    cairo_surface_t *surface;
+    gchar           *tooltip;
+    gchar           *name;
+    gchar           *arguments;
+    gchar           *security_context;
+
+    const pid_t      pid;
+    pid_t            ppid;
+    guint            uid;
+
+// private:
+    // tracks cpu time per process keeps growing because if a
+    // ProcInfo is deleted this does not mean that the process is
+    // not going to be recreated on the next update.  For example,
+    // if dependencies + (My or Active), the proclist is cleared
+    // on each update.  This is a workaround
+    static std::map<pid_t, guint64> cpu_times;
+};
+
+struct ProcData
+{
+    // lazy initialization
+    static ProcData* get_instance();
+
+    GtkUIManager    *uimanager;
+    GtkActionGroup    *action_group;
+    GtkWidget    *statusbar;
+    gint        tip_message_cid;
+    GtkWidget    *tree;
+    GtkWidget    *loadavg;
+    GtkWidget    *endprocessbutton;
+    GtkWidget    *popup_menu;
+    GtkWidget    *disk_list;
+    GtkWidget    *notebook;
+    ProcConfig    config;
+    LoadGraph    *cpu_graph;
+    LoadGraph    *mem_graph;
+    LoadGraph    *net_graph;
+    gint        cpu_label_fixed_width;
+    gint        net_label_fixed_width;
+    ProcInfo    *selected_process;
+    GtkTreeSelection *selection;
+    guint        timeout;
+    guint        disk_timeout;
+
+    PrettyTable    pretty_table;
+
+    GSettings       *settings;
+    GtkWidget        *app;
+    GtkUIManager    *menu;
+
+    unsigned    frequency;
+
+    SmoothRefresh  *smooth_refresh;
+
+    guint64 cpu_total_time;
+    guint64 cpu_total_time_last;
+
+    gboolean terminating;
+
+private:
+    ProcData();
+    /* undefined */ ProcData(const ProcData &);
+    /* undefined */ ProcData& operator=(const ProcData &);
+};
+
+void        procman_save_config (ProcData *data);
+void        procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+gboolean    procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+
+struct ReniceArgs
+{
+    ProcData *procdata;
+    int nice_value;
+};
+
+struct KillArgs
+{
+    ProcData *procdata;
+    int signal;
+};
+
+#endif /* _PROCMAN_PROCMAN_H_ */
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/1.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/1.html new file mode 100644 index 00000000..b83a4070 --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/1.html @@ -0,0 +1,435 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
#ifndef _PROCMAN_SMOOTH_REFRESH
+#define _PROCMAN_SMOOTH_REFRESH
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <string>
+
+using std::string;
+
+class SmoothRefresh
+{
+  public:
+
+    /*
+      smooth_refresh_new
+
+      @config_interval : pointer to config_interval so we can observe
+      config_interval changes.
+
+      @return : initialized SmoothRefresh
+    */
+    SmoothRefresh(GSettings *a_settings);
+
+    ~SmoothRefresh();
+
+    /*
+      smooth_refresh_reset
+
+      Resets state and re-read config_interval
+    */
+    void reset();
+
+    /*
+      smooth_refresh_get
+
+      Computes the new refresh_interval so that CPU usage is lower than
+      SMOOTH_REFRESH_PCPU.
+
+      @new_interval : where the new refresh_interval is stored.
+
+      @return : TRUE is refresh_interval has changed. The new refresh_interval
+      is stored in @new_interval. Else FALSE;
+    */
+    bool get(guint &new_interval);
+
+    static const string KEY;
+    static const bool KEY_DEFAULT_VALUE;
+
+  private:
+
+    unsigned get_own_cpu_usage();
+
+    static void status_changed(GSettings *settings,
+                               const gchar *key,
+                               gpointer user_data);
+
+    void load_settings_value(const gchar *key);
+
+    /*
+      fuzzy logic:
+      - decrease refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_LO
+      - increase refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_HI
+
+    */
+
+    enum
+    {
+        PCPU_HI = 22,
+        PCPU_LO = 18
+    };
+
+    /*
+      -self : procman's PID (so we call getpid() only once)
+
+      -interval : current refresh interval
+
+      -config_interval : pointer to the configuration refresh interval.
+      Used to watch configuration changes
+
+      -interval >= -config_interval
+
+      -last_pcpu : to avoid spikes, the last CPU%. See PCPU_{LO,HI}
+
+      -last_total_time:
+      -last_cpu_time: Save last cpu and process times to compute CPU%
+    */
+
+    GSettings *settings;
+    bool active;
+    guint connection;
+    guint interval;
+    unsigned  last_pcpu;
+    guint64 last_total_time;
+    guint64 last_cpu_time;
+};
+
+#endif /* _PROCMAN_SMOOTH_REFRESH */
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/10.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/10.html new file mode 100644 index 00000000..cb5e0f54 --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/10.html @@ -0,0 +1,1067 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
#include <gio/gio.h>
+
+#if defined (__ELF__) && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
+# define SECTION __attribute__ ((section (".gresource.msm"), aligned (8)))
+#else
+# define SECTION
+#endif
+
+static const SECTION union { const guint8 data[3353]; const double alignment; void * const ptr;}  msm_resource_data = { {<--- union member 'Anonymous0::alignment' is never used.<--- union member 'Anonymous0::ptr' is never used.
+  0107, 0126, 0141, 0162, 0151, 0141, 0156, 0164, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0030, 0000, 0000, 0000, 0310, 0000, 0000, 0000, 0000, 0000, 0000, 0050, 0006, 0000, 0000, 0000, 
+  0000, 0000, 0000, 0000, 0001, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0005, 0000, 0000, 0000, 0376, 0236, 0033, 0101, 0005, 0000, 0000, 0000, 
+  0310, 0000, 0000, 0000, 0024, 0000, 0114, 0000, 0334, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 
+  0113, 0120, 0220, 0013, 0002, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 0004, 0000, 0114, 0000, 
+  0350, 0000, 0000, 0000, 0354, 0000, 0000, 0000, 0324, 0265, 0002, 0000, 0377, 0377, 0377, 0377, 
+  0354, 0000, 0000, 0000, 0001, 0000, 0114, 0000, 0360, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 
+  0173, 0250, 0316, 0037, 0000, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 0014, 0000, 0166, 0000, 
+  0000, 0001, 0000, 0000, 0034, 0006, 0000, 0000, 0234, 0164, 0275, 0021, 0000, 0000, 0000, 0000, 
+  0034, 0006, 0000, 0000, 0016, 0000, 0166, 0000, 0060, 0006, 0000, 0000, 0017, 0015, 0000, 0000, 
+  0201, 0321, 0040, 0031, 0001, 0000, 0000, 0000, 0017, 0015, 0000, 0000, 0005, 0000, 0114, 0000, 
+  0024, 0015, 0000, 0000, 0030, 0015, 0000, 0000, 0155, 0141, 0164, 0145, 0055, 0163, 0171, 0163, 
+  0164, 0145, 0155, 0055, 0155, 0157, 0156, 0151, 0164, 0157, 0162, 0057, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0157, 0162, 0147, 0057, 0005, 0000, 0000, 0000, 0057, 0000, 0000, 0000, 
+  0001, 0000, 0000, 0000, 0151, 0156, 0164, 0145, 0162, 0146, 0141, 0143, 0145, 0056, 0165, 0151, 
+  0242, 0073, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0133, 0133, 0163, 0352, 0066, 
+  0020, 0176, 0317, 0257, 0160, 0375, 0332, 0161, 0010, 0227, 0320, 0164, 0006, 0070, 0323, 0166, 
+  0232, 0364, 0241, 0347, 0114, 0046, 0344, 0114, 0037, 0031, 0331, 0136, 0260, 0212, 0054, 0271, 
+  0222, 0314, 0345, 0337, 0237, 0065, 0066, 0004, 0002, 0370, 0102, 0210, 0061, 0224, 0067, 0154, 
+  0257, 0054, 0355, 0267, 0253, 0335, 0317, 0253, 0245, 0363, 0145, 0346, 0063, 0143, 0002, 0122, 
+  0121, 0301, 0273, 0146, 0375, 0366, 0316, 0064, 0200, 0073, 0302, 0245, 0174, 0324, 0065, 0277, 
+  0277, 0076, 0132, 0017, 0346, 0227, 0336, 0115, 0347, 0047, 0313, 0062, 0236, 0200, 0203, 0044, 
+  0032, 0134, 0143, 0112, 0265, 0147, 0214, 0030, 0161, 0301, 0150, 0336, 0066, 0037, 0156, 0033, 
+  0206, 0145, 0241, 0020, 0345, 0032, 0344, 0220, 0070, 0320, 0353, 0110, 0370, 0057, 0244, 0022, 
+  0224, 0301, 0250, 0335, 0065, 0107, 0172, 0374, 0263, 0371, 0066, 0113, 0363, 0266, 0321, 0062, 
+  0153, 0275, 0216, 0260, 0377, 0005, 0107, 0033, 0016, 0043, 0112, 0165, 0315, 0047, 0075, 0376, 
+  0207, 0162, 0127, 0114, 0115, 0203, 0272, 0135, 0323, 0047, 0224, 0017, 0246, 0361, 0215, 0136, 
+  0047, 0220, 0042, 0000, 0251, 0347, 0006, 0047, 0076, 0164, 0115, 0207, 0160, 0153, 0050, 0234, 
+  0120, 0231, 0275, 0107, 0302, 0024, 0164, 0152, 0113, 0201, 0055, 0121, 0115, 0065, 0003, 0323, 
+  0320, 0222, 0160, 0305, 0210, 0046, 0066, 0303, 0233, 0163, 0300, 0221, 0375, 0271, 0322, 0340, 
+  0033, 0137, 0005, 0247, 0132, 0310, 0224, 0127, 0270, 0060, 0044, 0041, 0323, 0326, 0224, 0272, 
+  0332, 0063, 0173, 0255, 0326, 0135, 0016, 0141, 0017, 0350, 0310, 0323, 0050, 0375, 0353, 0375, 
+  0272, 0264, 0343, 0121, 0346, 0356, 0120, 0375, 0167, 0061, 0133, 0323, 0333, 0306, 0253, 0255, 
+  0067, 0117, 0250, 0242, 0270, 0172, 0263, 0367, 0052, 0303, 0064, 0215, 0013, 0200, 0043, 0044, 
+  0005, 0256, 0211, 0106, 0263, 0230, 0075, 0264, 0217, 0246, 0016, 0141, 0073, 0226, 0033, 0060, 
+  0264, 0252, 0047, 0230, 0013, 0022, 0355, 0126, 0113, 0356, 0356, 0323, 0345, 0233, 0320, 0140, 
+  0013, 0061, 0216, 0025, 0342, 0313, 0253, 0143, 0050, 0224, 0041, 0351, 0023, 0071, 0242, 0334, 
+  0122, 0232, 0110, 0204, 0276, 0336, 0310, 0026, 0005, 0356, 0346, 0023, 0324, 0042, 0170, 0057, 
+  0230, 0151, 0113, 0065, 0127, 0224, 0017, 0105, 0151, 0346, 0364, 0140, 0026, 0220, 0110, 0241, 
+  0214, 0127, 0116, 0162, 0312, 0331, 0102, 0242, 0305, 0227, 0176, 0237, 0212, 0222, 0012, 0210, 
+  0203, 0061, 0143, 0017, 0104, 0251, 0376, 0263, 0373, 0141, 0055, 0206, 0365, 0235, 0264, 0241, 
+  0347, 0101, 0264, 0251, 0211, 0155, 0356, 0000, 0376, 0157, 0142, 0003, 0333, 0204, 0236, 0055, 
+  0156, 0225, 0001, 0176, 0074, 0323, 0376, 0100, 0263, 0076, 0164, 0245, 0034, 0242, 0066, 0106, 
+  0330, 0266, 0243, 0026, 0261, 0255, 0041, 0145, 0154, 0307, 0264, 0265, 0325, 0230, 0254, 0175, 
+  0270, 0362, 0103, 0034, 0354, 0374, 0037, 0234, 0060, 0063, 0234, 0355, 0165, 0332, 0207, 0074, 
+  0373, 0172, 0315, 0275, 0230, 0040, 0356, 0200, 0114, 0106, 0045, 0372, 0227, 0107, 0030, 0035, 
+  0241, 0136, 0213, 0340, 0126, 0310, 0231, 0226, 0100, 0147, 0315, 0020, 0073, 0134, 0306, 0212, 
+  0003, 0241, 0150, 0014, 0360, 0335, 0141, 0136, 0331, 0167, 0244, 0140, 0014, 0334, 0365, 0144, 
+  0037, 0071, 0050, 0050, 0005, 0152, 0240, 0222, 0247, 0145, 0144, 0213, 0143, 0173, 0252, 0362, 
+  0010, 0152, 0144, 0105, 0041, 0312, 0354, 0121, 0236, 0073, 0016, 0236, 0312, 0200, 0365, 0003, 
+  0303, 0112, 0250, 0065, 0016, 0137, 0030, 0016, 0323, 0147, 0142, 0073, 0073, 0276, 0133, 0040, 
+  0054, 0376, 0311, 0135, 0143, 0360, 0034, 0217, 0116, 0131, 0157, 0250, 0300, 0042, 0116, 0264, 
+  0142, 0213, 0004, 0001, 0020, 0174, 0221, 0003, 0331, 0130, 0034, 0337, 0135, 0044, 0070, 0100, 
+  0047, 0240, 0254, 0204, 0342, 0145, 0373, 0127, 0262, 0143, 0021, 0244, 0014, 0375, 0102, 0216, 
+  0036, 0301, 0050, 0337, 0261, 0334, 0123, 0071, 0107, 0043, 0335, 0071, 0062, 0227, 0125, 0314, 
+  0315, 0162, 0347, 0365, 0105, 0052, 0253, 0102, 0122, 0177, 0136, 0206, 0254, 0102, 0306, 0332, 
+  0203, 0312, 0247, 0146, 0177, 0374, 0014, 0273, 0046, 0377, 0242, 0214, 0165, 0077, 0234, 0116, 
+  0020, 0126, 0347, 0373, 0154, 0257, 0116, 0167, 0005, 0011, 0115, 0244, 0125, 0025, 0266, 0325, 
+  0037, 0317, 0337, 0215, 0277, 0250, 0302, 0017, 0362, 0171, 0312, 0370, 0131, 0022, 0131, 0067, 
+  0264, 0044, 0132, 0113, 0212, 0151, 0010, 0324, 0332, 0357, 0144, 0300, 0064, 0376, 0032, 0067, 
+  0046, 0204, 0205, 0013, 0267, 0142, 0156, 0124, 0201, 0250, 0255, 0217, 0071, 0063, 0036, 0265, 
+  0341, 0220, 0043, 0111, 0002, 0357, 0154, 0167, 0371, 0301, 0156, 0336, 0376, 0160, 0255, 0342, 
+  0221, 0211, 0351, 0006, 0222, 0103, 0274, 0121, 0032, 0220, 0223, 0175, 0234, 0076, 0265, 0256, 
+  0161, 0377, 0113, 0332, 0354, 0202, 0205, 0076, 0212, 0056, 0041, 0112, 0013, 0231, 0022, 0331, 
+  0152, 0056, 0101, 0037, 0047, 0137, 0040, 0050, 0201, 0133, 0370, 0300, 0212, 0271, 0112, 0063, 
+  0165, 0311, 0263, 0135, 0103, 0322, 0213, 0010, 0300, 0040, 0146, 0172, 0276, 0160, 0121, 0230, 
+  0013, 0176, 0112, 0056, 0204, 0223, 0044, 0144, 0076, 0235, 0301, 0345, 0246, 0072, 0025, 0045, 
+  0372, 0347, 0032, 0370, 0174, 0360, 0057, 0060, 0023, 0107, 0132, 0125, 0041, 0023, 0177, 0005, 
+  0037, 0223, 0260, 0201, 0206, 0067, 0372, 0123, 0022, 0134, 0263, 0162, 0161, 0347, 0274, 0146, 
+  0345, 0174, 0131, 0071, 0072, 0135, 0302, 0004, 0263, 0310, 0134, 0252, 0333, 0302, 0337, 0230, 
+  0231, 0124, 0167, 0161, 0254, 0264, 0015, 0361, 0223, 0244, 0356, 0033, 0306, 0013, 0227, 0055, 
+  0005, 0337, 0002, 0111, 0070, 0257, 0051, 0066, 0022, 0160, 0273, 0100, 0126, 0157, 0147, 0274, 
+  0324, 0023, 0276, 0030, 0001, 0007, 0261, 0253, 0256, 0221, 0043, 0010, 0051, 0334, 0361, 0145, 
+  0326, 0066, 0163, 0342, 0225, 0122, 0143, 0307, 0005, 0027, 0015, 0115, 0231, 0241, 0205, 0301, 
+  0120, 0133, 0030, 0214, 0210, 0343, 0245, 0223, 0035, 0055, 0202, 0225, 0334, 0201, 0201, 0143, 
+  0063, 0003, 0140, 0240, 0075, 0053, 0370, 0343, 0144, 0361, 0271, 0006, 0250, 0037, 0325, 0000, 
+  0007, 0034, 0111, 0235, 0342, 0341, 0225, 0362, 0136, 0024, 0345, 0255, 0177, 0220, 0125, 0160, 
+  0320, 0027, 0110, 0171, 0043, 0255, 0252, 0100, 0171, 0277, 0201, 0236, 0012, 0071, 0276, 0122, 
+  0335, 0342, 0116, 0171, 0245, 0272, 0173, 0330, 0154, 0073, 0067, 0233, 0215, 0140, 0074, 0031, 
+  0233, 0155, 0345, 0154, 0225, 0151, 0076, 0134, 0062, 0355, 0215, 0217, 0370, 0160, 0252, 0263, 
+  0042, 0137, 0057, 0313, 0125, 0237, 0023, 0377, 0112, 0063, 0203, 0026, 0232, 0260, 0101, 0162, 
+  0336, 0352, 0236, 0225, 0055, 0136, 0243, 0245, 0033, 0057, 0311, 0322, 0253, 0141, 0220, 0372, 
+  0207, 0015, 0242, 0160, 0357, 0237, 0333, 0256, 0350, 0143, 0104, 0377, 0134, 0374, 0357, 0113, 
+  0336, 0020, 0150, 0005, 0175, 0206, 0233, 0241, 0072, 0206, 0070, 0302, 0106, 0300, 0101, 0040, 
+  0267, 0341, 0137, 0034, 0120, 0133, 0121, 0327, 0063, 0050, 0235, 0221, 0045, 0077, 0215, 0322, 
+  0366, 0156, 0112, 0256, 0156, 0154, 0071, 0114, 0334, 0362, 0334, 0070, 0014, 0346, 0337, 0042, 
+  0077, 0360, 0321, 0131, 0336, 0347, 0342, 0200, 0072, 0143, 0220, 0003, 0262, 0172, 0136, 0006, 
+  0244, 0233, 0235, 0007, 0355, 0343, 0065, 0163, 0155, 0300, 0176, 0127, 0071, 0330, 0227, 0241, 
+  0376, 0202, 0101, 0157, 0225, 0016, 0372, 0045, 0026, 0176, 0076, 0122, 0146, 0313, 0255, 0134, 
+  0306, 0262, 0057, 0243, 0050, 0164, 0274, 0126, 0273, 0306, 0061, 0133, 0355, 0242, 0276, 0261, 
+  0052, 0124, 0145, 0136, 0100, 0211, 0120, 0072, 0007, 0167, 0332, 0065, 0112, 0353, 0264, 0033, 
+  0226, 0327, 0150, 0127, 0106, 0143, 0134, 0073, 0317, 0327, 0363, 0256, 0166, 0156, 0227, 0252, 
+  0361, 0265, 0225, 0273, 0102, 0045, 0274, 0002, 0273, 0245, 0171, 0314, 0020, 0062, 0254, 0106, 
+  0004, 0171, 0244, 0014, 0214, 0370, 0137, 0070, 0207, 0006, 0221, 0346, 0261, 0202, 0310, 0231, 
+  0235, 0074, 0364, 0061, 0160, 0204, 0312, 0046, 0062, 0141, 0207, 0253, 0313, 0112, 0237, 0100, 
+  0064, 0076, 0261, 0153, 0054, 0113, 0252, 0170, 0136, 0337, 0276, 0361, 0366, 0117, 0332, 0233, 
+  0037, 0325, 0360, 0311, 0023, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0160, 0162, 0145, 0146, 
+  0145, 0162, 0145, 0156, 0143, 0145, 0163, 0056, 0165, 0151, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0065, 0123, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0134, 0335, 0162, 0342, 0066, 
+  0024, 0276, 0357, 0123, 0250, 0276, 0355, 0050, 0004, 0262, 0155, 0167, 0072, 0301, 0073, 0335, 
+  0335, 0046, 0335, 0231, 0266, 0263, 0323, 0354, 0266, 0227, 0036, 0331, 0076, 0140, 0155, 0204, 
+  0344, 0112, 0002, 0102, 0257, 0372, 0054, 0175, 0264, 0076, 0111, 0217, 0177, 0010, 0140, 0300, 
+  0066, 0004, 0210, 0041, 0334, 0331, 0346, 0110, 0072, 0072, 0377, 0237, 0216, 0206, 0353, 0067, 
+  0017, 0003, 0101, 0106, 0240, 0015, 0127, 0262, 0353, 0264, 0057, 0056, 0035, 0002, 0062, 0120, 
+  0041, 0227, 0375, 0256, 0363, 0371, 0323, 0015, 0175, 0355, 0274, 0161, 0277, 0272, 0376, 0232, 
+  0122, 0162, 0013, 0022, 0064, 0263, 0020, 0222, 0061, 0267, 0021, 0351, 0013, 0026, 0002, 0271, 
+  0272, 0270, 0172, 0175, 0321, 0041, 0224, 0042, 0021, 0227, 0026, 0164, 0217, 0005, 0340, 0136, 
+  0153, 0370, 0153, 0310, 0065, 0030, 0042, 0270, 0337, 0165, 0372, 0366, 0376, 0033, 0147, 0266, 
+  0312, 0325, 0105, 0347, 0225, 0323, 0162, 0257, 0225, 0377, 0005, 0002, 0113, 0002, 0301, 0214, 
+  0351, 0072, 0267, 0366, 0376, 0303, 0200, 0365, 0301, 0041, 0074, 0354, 0072, 0074, 0171, 0154, 
+  0073, 0356, 0165, 0254, 0125, 0014, 0332, 0116, 0210, 0144, 0003, 0350, 0072, 0043, 0156, 0270, 
+  0057, 0300, 0161, 0077, 0351, 0041, 0134, 0267, 0246, 0277, 0056, 0321, 0005, 0114, 0322, 0236, 
+  0012, 0206, 0306, 0161, 0157, 0230, 0060, 0145, 0244, 0074, 0120, 0222, 0046, 0217, 0216, 0073, 
+  0346, 0062, 0124, 0143, 0032, 0010, 0265, 0070, 0242, 0225, 0261, 0132, 0203, 0345, 0316, 0241, 
+  0131, 0216, 0100, 0304, 0324, 0327, 0152, 0154, 0100, 0327, 0143, 0371, 0075, 0147, 0102, 0365, 
+  0063, 0236, 0143, 0015, 0075, 0320, 0250, 0161, 0060, 0136, 0230, 0175, 0177, 0012, 0137, 0276, 
+  0322, 0041, 0150, 0072, 0346, 0241, 0215, 0034, 0367, 0333, 0022, 0112, 0313, 0055, 0212, 0204, 
+  0130, 0315, 0244, 0021, 0314, 0062, 0024, 0120, 0327, 0231, 0000, 0256, 0161, 0067, 0061, 0026, 
+  0006, 0344, 0127, 0045, 0271, 0125, 0232, 0174, 0234, 0161, 0130, 0062, 0135, 0010, 0075, 0066, 
+  0024, 0166, 0272, 0362, 0253, 0313, 0313, 0032, 0304, 0021, 0360, 0176, 0144, 0221, 0272, 0123, 
+  0116, 0155, 0254, 0126, 0023, 0232, 0030, 0075, 0215, 0031, 0262, 0142, 0053, 0125, 0151, 0047, 
+  0061, 0320, 0210, 0047, 0224, 0231, 0124, 0347, 0151, 0203, 0210, 0213, 0220, 0244, 0316, 0042, 
+  0231, 0240, 0351, 0053, 0132, 0211, 0257, 0036, 0234, 0025, 0332, 0172, 0213, 0237, 0123, 0125, 
+  0145, 0023, 0171, 0202, 0115, 0324, 0320, 0076, 0111, 0113, 0003, 0246, 0373, 0134, 0122, 0253, 
+  0342, 0162, 0035, 0345, 0164, 0276, 0262, 0126, 0015, 0312, 0111, 0225, 0346, 0050, 0027, 0146, 
+  0321, 0277, 0035, 0027, 0035, 0335, 0362, 0200, 0211, 0022, 0172, 0023, 0263, 0000, 0103, 0214, 
+  0343, 0166, 0252, 0045, 0303, 0202, 0144, 0132, 0017, 0045, 0317, 0126, 0012, 0150, 0210, 0354, 
+  0311, 0242, 0230, 0026, 0007, 0155, 0040, 0253, 0164, 0321, 0265, 0313, 0144, 0153, 0044, 0076, 
+  0347, 0371, 0331, 0207, 0245, 0311, 0005, 0363, 0101, 0070, 0356, 0317, 0110, 0123, 0042, 0200, 
+  0241, 0001, 0232, 0361, 0110, 0131, 0034, 0003, 0103, 0077, 0010, 0240, 0132, 0165, 0133, 0304, 
+  0222, 0012, 0112, 0015, 0001, 0360, 0021, 0030, 0232, 0173, 0105, 0345, 0200, 0064, 0314, 0071, 
+  0156, 0026, 0355, 0126, 0106, 0034, 0324, 0355, 0075, 0052, 0167, 0151, 0044, 0074, 0304, 0114, 
+  0206, 0325, 0233, 0354, 0161, 0041, 0052, 0331, 0210, 0225, 0341, 0231, 0271, 0055, 0070, 0157, 
+  0353, 0161, 0361, 0126, 0256, 0311, 0072, 0012, 0115, 0003, 0176, 0225, 0106, 0337, 0025, 0263, 
+  0302, 0111, 0252, 0264, 0335, 0004, 0225, 0266, 0313, 0125, 0172, 0140, 0266, 0160, 0021, 0232, 
+  0104, 0164, 0307, 0005, 0031, 0356, 0320, 0044, 0223, 0242, 0112, 0322, 0100, 0211, 0341, 0100, 
+  0232, 0156, 0033, 0237, 0223, 0064, 0216, 0017, 0130, 0115, 0055, 0333, 0353, 0255, 0346, 0141, 
+  0156, 0255, 0012, 0043, 0244, 0264, 0136, 0077, 0371, 0162, 0210, 0162, 0143, 0323, 0350, 0236, 
+  0155, 0211, 0226, 0004, 0371, 0025, 0373, 0373, 0115, 0131, 0360, 0225, 0272, 0317, 0366, 0050, 
+  0247, 0157, 0007, 0360, 0227, 0150, 0152, 0056, 0025, 0164, 0243, 0232, 0164, 0045, 0125, 0120, 
+  0271, 0346, 0073, 0125, 0232, 0307, 0211, 0260, 0016, 0062, 0130, 0254, 0141, 0305, 0344, 0345, 
+  0166, 0160, 0020, 0023, 0330, 0257, 0214, 0332, 0235, 0035, 0132, 0037, 0212, 0162, 0146, 0172, 
+  0355, 0327, 0173, 0021, 0277, 0017, 0021, 0033, 0161, 0245, 0017, 0042, 0373, 0205, 0015, 0175, 
+  0127, 0307, 0227, 0176, 0111, 0063, 0326, 0032, 0236, 0275, 0074, 0237, 0035, 0302, 0152, 0230, 
+  0340, 0175, 0324, 0232, 0261, 0114, 0333, 0022, 0272, 0214, 0243, 0125, 0150, 0340, 0155, 0316, 
+  0164, 0131, 0055, 0211, 0162, 0021, 0100, 0005, 0227, 0100, 0007, 0052, 0134, 0261, 0001, 0146, 
+  0255, 0346, 0230, 0335, 0301, 0314, 0075, 0347, 0243, 0307, 0031, 0010, 0040, 0043, 0046, 0206, 
+  0251, 0135, 0212, 0060, 0301, 0246, 0255, 0371, 0061, 0225, 0371, 0106, 0100, 0317, 0122, 0034, 
+  0301, 0202, 0250, 0020, 0374, 0213, 0300, 0100, 0305, 0253, 0351, 0066, 0115, 0022, 0257, 0066, 
+  0267, 0125, 0317, 0100, 0220, 0071, 0321, 0001, 0064, 0237, 0143, 0207, 0124, 0361, 0025, 0376, 
+  0135, 0151, 0336, 0213, 0042, 0350, 0324, 0316, 0223, 0303, 0070, 0144, 0026, 0274, 0024, 0117, 
+  0240, 0172, 0017, 0227, 0057, 0353, 0006, 0313, 0142, 0236, 0154, 0167, 0266, 0166, 0356, 0307, 
+  0115, 0036, 0316, 0271, 0327, 0073, 0255, 0367, 0071, 0225, 0074, 0231, 0062, 0205, 0017, 0004, 
+  0215, 0117, 0311, 0320, 0374, 0120, 0121, 0100, 0017, 0045, 0246, 0205, 0304, 0225, 0053, 0071, 
+  0035, 0110, 0030, 0050, 0311, 0203, 0044, 0207, 0364, 0001, 0215, 0154, 0205, 0060, 0114, 0314, 
+  0245, 0134, 0163, 0056, 0362, 0014, 0276, 0274, 0244, 0312, 0073, 0344, 0157, 0036, 0207, 0254, 
+  0337, 0302, 0041, 0352, 0040, 0056, 0363, 0071, 0021, 0171, 0063, 0134, 0361, 0277, 0177, 0376, 
+  0055, 0233, 0127, 0360, 0201, 0117, 0223, 0003, 0301, 0102, 0275, 0136, 0074, 0077, 0341, 0175, 
+  0156, 0115, 0241, 0010, 0334, 0114, 0013, 0355, 0335, 0150, 0241, 0121, 0252, 0177, 0027, 0101, 
+  0260, 0200, 0101, 0315, 0100, 0051, 0033, 0125, 0200, 0320, 0125, 0336, 0366, 0223, 0114, 0136, 
+  0210, 0227, 0115, 0100, 0064, 0364, 0064, 0230, 0350, 0070, 0201, 0152, 0025, 0017, 0233, 0205, 
+  0210, 0120, 0263, 0061, 0345, 0062, 0304, 0202, 0321, 0046, 0265, 0132, 0221, 0174, 0077, 0006, 
+  0321, 0336, 0221, 0101, 0004, 0311, 0207, 0055, 0354, 0341, 0107, 0201, 0144, 0304, 0207, 0236, 
+  0322, 0100, 0020, 0261, 0342, 0352, 0104, 0151, 0342, 0335, 0043, 0330, 0115, 0236, 0037, 0203, 
+  0314, 0331, 0104, 0236, 0313, 0104, 0072, 0273, 0212, 0031, 0112, 0060, 0315, 0315, 0026, 0106, 
+  0342, 0275, 0347, 0043, 0036, 0002, 0171, 0367, 0361, 0063, 0031, 0032, 0326, 0007, 0342, 0117, 
+  0322, 0227, 0100, 0015, 0245, 0075, 0133, 0306, 0163, 0131, 0306, 0325, 0163, 0244, 0260, 0166, 
+  0163, 0363, 0346, 0323, 0241, 0172, 0217, 0203, 0010, 0315, 0121, 0036, 0222, 0354, 0010, 0370, 
+  0147, 0022, 0150, 0004, 0062, 0370, 0040, 0061, 0053, 0015, 0322, 0263, 0034, 0162, 0223, 0262, 
+  0125, 0062, 0315, 0227, 0241, 0261, 0274, 0067, 0161, 0334, 0344, 0230, 0266, 0204, 0016, 0060, 
+  0257, 0305, 0206, 0377, 0135, 0171, 0100, 0133, 0175, 0122, 0120, 0030, 0360, 0220, 0237, 0137, 
+  0134, 0236, 0370, 0151, 0302, 0306, 0356, 0324, 0074, 0054, 0135, 0327, 0247, 0052, 0117, 0023, 
+  0267, 0161, 0255, 0324, 0304, 0033, 0341, 0140, 0037, 0063, 0326, 0010, 0367, 0346, 0074, 0315, 
+  0104, 0152, 0054, 0023, 0020, 0056, 0270, 0261, 0173, 0106, 0340, 0126, 0003, 0170, 0271, 0201, 
+  0155, 0352, 0131, 0315, 0302, 0346, 0201, 0126, 0102, 0100, 0370, 0147, 0172, 0047, 0244, 0250, 
+  0170, 0223, 0377, 0172, 0214, 0375, 0011, 0023, 0261, 0344, 0226, 0113, 0326, 0322, 0342, 0262, 
+  0216, 0361, 0177, 0102, 0255, 0376, 0301, 0141, 0116, 0014, 0363, 0172, 0076, 0214, 0020, 0030, 
+  0332, 0245, 0241, 0217, 0063, 0127, 0371, 0010, 0244, 0260, 0230, 0032, 0054, 0121, 0023, 0053, 
+  0130, 0335, 0350, 0137, 0272, 0154, 0140, 0100, 0074, 0236, 0222, 0256, 0224, 0302, 0335, 0043, 
+  0301, 0242, 0105, 0114, 0203, 0052, 0235, 0315, 0320, 0132, 0121, 0102, 0235, 0140, 0041, 0327, 
+  0350, 0105, 0027, 0274, 0234, 0044, 0046, 0217, 0363, 0060, 0337, 0251, 0033, 0340, 0223, 0076, 
+  0133, 0203, 0342, 0372, 0042, 0150, 0257, 0024, 0055, 0316, 0100, 0263, 0036, 0367, 0322, 0312, 
+  0073, 0357, 0112, 0153, 0060, 0152, 0250, 0203, 0163, 0157, 0362, 0171, 0172, 0223, 0063, 0361, 
+  0367, 0065, 0213, 0243, 0146, 0001, 0236, 0047, 0001, 0231, 0342, 0316, 0016, 0331, 0277, 0254, 
+  0271, 0277, 0365, 0176, 0173, 0233, 0262, 0174, 0006, 0071, 0307, 0000, 0162, 0226, 0014, 0255, 
+  0241, 0015, 0323, 0203, 0037, 0063, 0154, 0333, 0200, 0235, 0011, 0264, 0320, 0212, 0075, 0255, 
+  0056, 0354, 0154, 0233, 0347, 0056, 0254, 0273, 0102, 0030, 0307, 0326, 0205, 0135, 0277, 0205, 
+  0163, 0027, 0366, 0324, 0273, 0260, 0076, 0112, 0151, 0233, 0166, 0312, 0135, 0244, 0306, 0104, 
+  0202, 0035, 0053, 0175, 0117, 0114, 0014, 0220, 0100, 0113, 0222, 0314, 0166, 0232, 0275, 0224, 
+  0272, 0301, 0365, 0004, 0032, 0266, 0057, 0247, 0347, 0122, 0271, 0150, 0355, 0033, 0332, 0233, 
+  0301, 0355, 0105, 0350, 0330, 0204, 0334, 0371, 0373, 0224, 0243, 0215, 0254, 0157, 0215, 0170, 
+  0366, 0007, 0312, 0053, 0113, 0332, 0020, 0106, 0374, 0014, 0311, 0237, 0011, 0222, 0117, 0205, 
+  0177, 0074, 0227, 0205, 0213, 0034, 0037, 0025, 0324, 0256, 0161, 0125, 0370, 0014, 0266, 0033, 
+  0003, 0266, 0227, 0114, 0355, 0310, 0301, 0366, 0336, 0100, 0364, 0124, 0120, 0047, 0174, 0215, 
+  0171, 0151, 0213, 0057, 0027, 0076, 0057, 0211, 0342, 0330, 0300, 0363, 0272, 0015, 0234, 0241, 
+  0363, 0251, 0103, 0147, 0046, 0204, 0067, 0325, 0176, 0172, 0167, 0165, 0023, 0000, 0235, 0342, 
+  0147, 0017, 0247, 0040, 0230, 0232, 0201, 0230, 0364, 0117, 0000, 0316, 0330, 0371, 0214, 0235, 
+  0137, 0310, 0175, 0305, 0251, 0343, 0274, 0324, 0333, 0212, 0213, 0373, 0077, 0052, 0334, 0161, 
+  0276, 0323, 0170, 0012, 0056, 0167, 0302, 0067, 0032, 0367, 0350, 0247, 0315, 0271, 0370, 0170, 
+  0063, 0053, 0033, 0236, 0347, 0362, 0143, 0310, 0315, 0175, 0162, 0051, 0116, 0302, 0370, 0144, 
+  0357, 0077, 0116, 0265, 0377, 0242, 0157, 0077, 0256, 0120, 0364, 0013, 0276, 0000, 0231, 0233, 
+  0004, 0115, 0044, 0062, 0102, 0031, 0235, 0357, 0077, 0036, 0305, 0242, 0263, 0126, 0105, 0147, 
+  0227, 0235, 0234, 0004, 0274, 0171, 0071, 0170, 0153, 0114, 0063, 0047, 0115, 0015, 0167, 0313, 
+  0210, 0162, 0133, 0041, 0075, 0245, 0237, 0323, 0314, 0276, 0136, 0315, 0320, 0271, 0247, 0177, 
+  0161, 0232, 0176, 0310, 0341, 0174, 0226, 0120, 0115, 0341, 0235, 0150, 0060, 0261, 0222, 0006, 
+  0127, 0240, 0355, 0166, 0366, 0277, 0207, 0171, 0243, 0036, 0113, 0321, 0171, 0312, 0222, 0201, 
+  0337, 0073, 0356, 0374, 0137, 0175, 0055, 0015, 0154, 0025, 0131, 0230, 0361, 0070, 0373, 0163, 
+  0313, 0257, 0376, 0007, 0112, 0344, 0157, 0105, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0155, 
+  0141, 0164, 0145, 0057, 0000, 0000, 0000, 0000
+} };
+
+static GStaticResource static_resource = { msm_resource_data.data, sizeof (msm_resource_data.data) - 1 /* nul terminator */, NULL, NULL, NULL };
+
+G_MODULE_EXPORT
+GResource *msm_get_resource (void);
+GResource *msm_get_resource (void)
+{
+  return g_static_resource_get_resource (&static_resource);
+}
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GLib Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __G_CONSTRUCTOR_H__
+#define __G_CONSTRUCTOR_H__
+
+/*
+  If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and
+  destructors, in a usable way, including e.g. on library unload. If not you're on
+  your own.
+
+  Some compilers need #pragma to handle this, which does not work with macros,
+  so the way you need to use this is (for constructors):
+
+  #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+  #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(my_constructor)
+  #endif
+  G_DEFINE_CONSTRUCTOR(my_constructor)
+  static void my_constructor(void) {
+   ...
+  }
+
+*/
+
+#ifndef __GTK_DOC_IGNORE__
+
+#if  __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func (void);
+#define G_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func (void);
+
+#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
+/* Visual studio 2008 and later has _Pragma */
+
+/*
+ * Only try to include gslist.h if not already included via glib.h,
+ * so that items using gconstructor.h outside of GLib (such as
+ * GResources) continue to build properly.
+ */
+#ifndef __G_LIB_H__
+#include "gslist.h"
+#endif
+
+#include <stdlib.h>
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* We do some weird things to avoid the constructors being optimized
+ * away on VS2015 if WholeProgramOptimization is enabled. First we
+ * make a reference to the array from the wrapper to make sure its
+ * references. Then we use a pragma to make sure the wrapper function
+ * symbol is always included at the link stage. Also, the symbols
+ * need to be extern (but not dllexport), even though they are not
+ * really used from another object file.
+ */
+
+/* We need to account for differences between the mangling of symbols
+ * for x86 and x64/ARM/ARM64 programs, as symbols on x86 are prefixed
+ * with an underscore but symbols on x64/ARM/ARM64 are not.
+ */
+#ifdef _M_IX86
+#define G_MSVC_SYMBOL_PREFIX "_"
+#else
+#define G_MSVC_SYMBOL_PREFIX ""
+#endif
+
+#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
+#define G_DEFINE_DESTRUCTOR(_func) G_MSVC_DTOR (_func, G_MSVC_SYMBOL_PREFIX)
+
+#define G_MSVC_CTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _wrapper(void) { _func(); g_slist_find (NULL,  _array ## _func); return 0; } \
+  __pragma(comment(linker,"/include:" _sym_prefix # _func "_wrapper")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _wrapper;
+
+#define G_MSVC_DTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _constructor(void) { atexit (_func); g_slist_find (NULL,  _array ## _func); return 0; } \
+   __pragma(comment(linker,"/include:" _sym_prefix # _func "_constructor")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined (_MSC_VER)
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* Pre Visual studio 2008 must use #pragma section */
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _wrapper(void) { _func(); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func ## _wrapper;
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _constructor(void) { atexit (_func); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined(__SUNPRO_C)
+
+/* This is not tested, but i believe it should work, based on:
+ * http://opensource.apple.com/source/OpenSSL098/OpenSSL098-35/src/fips/fips_premain.c
+ */
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  init(_func)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void);
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  fini(_func)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void);
+
+#else
+
+/* constructors not supported for this compiler */
+
+#endif
+
+#endif /* __GTK_DOC_IGNORE__ */
+#endif /* __G_CONSTRUCTOR_H__ */
+
+#ifdef G_HAS_CONSTRUCTORS
+
+#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(msmresource_constructor)
+#endif
+G_DEFINE_CONSTRUCTOR(msmresource_constructor)
+#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(msmresource_destructor)
+#endif
+G_DEFINE_DESTRUCTOR(msmresource_destructor)
+
+#else
+#warning "Constructor not supported on this compiler, linking in resources will not work"
+#endif
+
+static void msmresource_constructor (void)
+{
+  g_static_resource_init (&static_resource);
+}
+
+static void msmresource_destructor (void)
+{
+  g_static_resource_fini (&static_resource);
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/11.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/11.html new file mode 100644 index 00000000..174d418f --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/11.html @@ -0,0 +1,1039 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
#include <config.h>
+
+#include <glib/gi18n.h>
+#include <glibtop/procopenfiles.h>
+#include <sys/stat.h>
+#include <netdb.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include "procman.h"
+#include "openfiles.h"
+#include "proctable.h"
+#include "util.h"
+#include "settings-keys.h"
+
+#ifndef NI_IDN
+#define NI_IDN 0
+#endif
+
+enum
+{
+    COL_FD,
+    COL_TYPE,
+    COL_OBJECT,
+    COL_OPENFILE_STRUCT,
+    NUM_OPENFILES_COL
+};
+
+
+static const char*
+get_type_name(enum glibtop_file_type t)
+{
+    switch(t)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        return _("file");
+    case GLIBTOP_FILE_TYPE_PIPE:
+        return _("pipe");
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+        return _("IPv6 network connection");
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        return _("IPv4 network connection");
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        return _("local socket");
+    default:
+        return _("unknown type");
+    }
+}
+
+
+
+static char *
+friendlier_hostname(const char *addr_str, int port)
+{
+    struct addrinfo hints = { };
+    struct addrinfo *res = NULL;
+    char hostname[NI_MAXHOST];
+    char service[NI_MAXSERV];
+    char port_str[6];
+
+    if (!addr_str[0]) return g_strdup("");
+
+    snprintf(port_str, sizeof port_str, "%d", port);
+
+    hints.ai_family = AF_UNSPEC;
+    hints.ai_socktype = SOCK_STREAM;
+
+    if (getaddrinfo(addr_str, port_str, &hints, &res))
+        goto failsafe;
+
+    if (getnameinfo(res->ai_addr, res->ai_addrlen, hostname,<--- Null pointer dereference
+            sizeof hostname, service, sizeof service, NI_IDN))
+        goto failsafe;
+
+    if (res) freeaddrinfo(res);<--- Assuming that condition 'res' is not redundant
+        return g_strdup_printf("%s, TCP port %d (%s)", hostname, port, service);
+
+  failsafe:
+    if (res) freeaddrinfo(res);
+    return g_strdup_printf("%s, TCP port %d", addr_str, port);
+}
+
+
+
+static void
+add_new_files (gpointer key, gpointer value, gpointer data)
+{
+    glibtop_open_files_entry *openfiles = static_cast<glibtop_open_files_entry*>(value);
+
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreeIter row;
+
+    char *object;
+
+    switch(openfiles->type)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        object = g_strdup(openfiles->info.file.name);
+        break;
+
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        object = friendlier_hostname(openfiles->info.sock.dest_host,
+                         openfiles->info.sock.dest_port);
+        break;
+
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        object = g_strdup(openfiles->info.localsock.name);
+        break;
+
+    default:
+        object = g_strdup("");
+    }
+
+    gtk_list_store_insert (GTK_LIST_STORE (model), &row, 0);
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        COL_FD, openfiles->fd,
+                        COL_TYPE, get_type_name(static_cast<glibtop_file_type>(openfiles->type)),
+                        COL_OBJECT, object,
+#if GLIB_CHECK_VERSION (2, 68, 0)
+                        COL_OPENFILE_STRUCT, g_memdup2(openfiles, sizeof(*openfiles)),
+#else
+                        COL_OPENFILE_STRUCT, g_memdup(openfiles, sizeof(*openfiles)),
+#endif
+                        -1);
+
+    g_free(object);
+}
+
+static GList *old_maps = NULL;
+
+static gboolean
+classify_openfiles (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+    GHashTable *new_maps = static_cast<GHashTable*>(data);
+    GtkTreeIter *old_iter;
+    glibtop_open_files_entry *openfiles;
+    gchar *old_name;
+
+    gtk_tree_model_get (model, iter, 1, &old_name, -1);
+
+    openfiles = static_cast<glibtop_open_files_entry*>(g_hash_table_lookup (new_maps, old_name));
+    if (openfiles) {
+        g_hash_table_remove (new_maps, old_name);
+        g_free (old_name);
+        return FALSE;
+
+    }
+
+    old_iter = gtk_tree_iter_copy (iter);
+    old_maps = g_list_append (old_maps, old_iter);
+    g_free (old_name);
+    return FALSE;
+
+}
+
+
+static gboolean
+compare_open_files(gconstpointer a, gconstpointer b)
+{
+    const glibtop_open_files_entry *o1 = static_cast<const glibtop_open_files_entry *>(a);
+    const glibtop_open_files_entry *o2 = static_cast<const glibtop_open_files_entry *>(b);
+
+    /* Falta manejar los diferentes tipos! */
+    return (o1->fd == o2->fd) && (o1->type == o2->type); /* XXX! */
+}
+
+
+static void
+update_openfiles_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+    GtkTreeModel *model;
+    glibtop_open_files_entry *openfiles;<--- Shadowed declaration
+    glibtop_proc_open_files procmap;
+    GHashTable *new_maps;
+    guint i;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    if (!info)
+        return;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    openfiles = glibtop_get_proc_open_files (&procmap, info->pid);
+
+    if (!openfiles)
+        return;
+
+    new_maps = static_cast<GHashTable *>(g_hash_table_new_full (g_str_hash, compare_open_files,
+                                                                NULL, NULL));
+    for (i=0; i < procmap.number; i++)
+        g_hash_table_insert (new_maps, openfiles + i, openfiles + i);
+
+    gtk_tree_model_foreach (model, classify_openfiles, new_maps);
+
+    g_hash_table_foreach (new_maps, add_new_files, model);
+
+    while (old_maps) {
+        GtkTreeIter *iter = static_cast<GtkTreeIter*>(old_maps->data);
+        glibtop_open_files_entry *openfiles = NULL;<--- Shadow variable
+
+        gtk_tree_model_get (model, iter,
+                            COL_OPENFILE_STRUCT, &openfiles,
+                            -1);
+
+        gtk_list_store_remove (GTK_LIST_STORE (model), iter);
+        gtk_tree_iter_free (iter);
+        g_free (openfiles);
+
+        old_maps = g_list_next (old_maps);
+
+    }
+
+    g_hash_table_destroy (new_maps);
+    g_free (openfiles);
+}
+
+static void
+close_openfiles_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GSettings *settings;
+    guint timer;
+
+    settings = static_cast<GSettings*>(g_object_get_data (G_OBJECT (tree), "settings"));
+    procman_save_tree_state (settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    return ;
+}
+
+
+static GtkWidget *
+create_openfiles_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    const gchar * const titles[] = {
+        /* Translators: "FD" here means "File Descriptor". Please use
+           a very short translation if possible, and at most
+           2-3 characters for it to be able to fit in the UI. */
+        N_("FD"),
+        N_("Type"),
+        N_("Object")
+    };
+
+    model = gtk_list_store_new (NUM_OPENFILES_COL,
+                                G_TYPE_INT,        /* FD */
+                                G_TYPE_STRING,    /* Type */
+                                G_TYPE_STRING,    /* Object */
+                                G_TYPE_POINTER    /* open_files_entry */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_OPENFILES_COL-1; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        switch (i) {
+        case COL_FD:
+            g_object_set(cell, "xalign", 1.0f, NULL);
+            break;
+        }
+
+        column = gtk_tree_view_column_new_with_attributes (_(titles[i]),
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_sort_column_id (column, i);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    procman_get_tree_state (procdata->settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    return tree;
+}
+
+
+static gboolean
+openfiles_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_openfiles_dialog (tree);
+
+    return TRUE;
+}
+
+
+static void
+create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *openfilesdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    openfilesdialog = gtk_dialog_new_with_buttons (_("Open Files"), NULL,
+                                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                   "gtk-close", GTK_RESPONSE_CLOSE,
+                                                   NULL);
+    gtk_window_set_resizable (GTK_WINDOW (openfilesdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (openfilesdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (openfilesdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (openfilesdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Files opened by process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                    GTK_POLICY_AUTOMATIC,
+                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_openfiles_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+    g_object_set_data (G_OBJECT (tree), "settings", procdata->settings);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (openfilesdialog), "response",
+                      G_CALLBACK (close_openfiles_dialog), tree);
+
+    gtk_widget_show_all (openfilesdialog);
+
+    timer = g_timeout_add_seconds (5, openfiles_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_openfiles_dialog (tree);
+
+}
+
+
+void
+create_openfiles_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_openfiles_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/12.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/12.html new file mode 100644 index 00000000..c1c9bcc6 --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/12.html @@ -0,0 +1,385 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
// -*- c++ -*-
+
+#ifndef _PROCMAN_PRETTYTABLE_H_
+#define _PROCMAN_PRETTYTABLE_H_
+
+#include <glib.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <glibmm/refptr.h>
+#include <gdkmm/pixbuf.h>
+#include <giomm/filemonitor.h>
+
+#include <map>
+#include <string>
+
+#ifdef HAVE_WNCK
+extern "C" {
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h>
+}
+#endif
+
+#include "iconthemewrapper.h"
+
+class ProcInfo;
+
+using std::string;
+
+class PrettyTable
+{
+ public:
+    PrettyTable();
+    ~PrettyTable();
+
+    void set_icon(ProcInfo &);
+
+private:
+
+#ifdef HAVE_WNCK
+    static void on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_opened'
+    static void on_application_closed(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_closed'
+
+    void register_application(pid_t pid, Glib::RefPtr<Gdk::Pixbuf> icon);
+    void unregister_application(pid_t pid);
+#endif
+
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_theme(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_default(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_gio(const ProcInfo &);
+#ifdef HAVE_WNCK
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_wnck(const ProcInfo &);
+#endif
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_name(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_for_kernel(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_dummy(const ProcInfo &);
+
+    bool get_default_icon_name(const string &cmd, string &name);
+    void file_monitor_event (Glib::RefPtr<Gio::File>,
+                             Glib::RefPtr<Gio::File>,
+                             Gio::FileMonitorEvent);
+    void init_gio_app_cache ();
+
+    typedef std::map<string, Glib::RefPtr<Gdk::Pixbuf> > IconCache;
+    typedef std::map<pid_t, Glib::RefPtr<Gdk::Pixbuf> > IconsForPID;
+    typedef std::map<string, Glib::RefPtr<Gio::AppInfo> > AppCache;
+    typedef std::map<string, Glib::RefPtr<Gio::FileMonitor> > DesktopDirMonitors;
+
+    IconsForPID apps;
+    IconCache defaults;
+    DesktopDirMonitors monitors;
+    AppCache gio_apps;
+    procman::IconThemeWrapper theme;
+};
+
+#endif /* _PROCMAN_PRETTYTABLE_H_ */
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/13.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/13.html new file mode 100644 index 00000000..b7c3450b --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/13.html @@ -0,0 +1,1417 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
/* Procman - dialogs
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+
+#include <signal.h>
+#include <string.h>
+
+#include "procdialogs.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "procactions.h"
+#include "util.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "procman_gksu.h"
+#include "procman_pkexec.h"
+#include "cgroups.h"
+
+#define GET_WIDGET(x) GTK_WIDGET(gtk_builder_get_object(builder, x))
+
+static GtkWidget *renice_dialog = NULL;
+static GtkWidget *prefs_dialog = NULL;
+static gint new_nice_value = 0;
+
+
+static void
+kill_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    struct KillArgs *kargs = static_cast<KillArgs*>(data);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    if (id == GTK_RESPONSE_OK)
+        kill_process (kargs->procdata, kargs->signal);
+
+    g_free (kargs);
+}
+
+void
+procdialog_create_kill_dialog (ProcData *procdata, int signal)
+{
+    GtkWidget *kill_alert_dialog;
+    gchar *primary, *secondary, *button_text;
+    struct KillArgs *kargs;
+
+    kargs = g_new(KillArgs, 1);
+    kargs->procdata = procdata;
+    kargs->signal = signal;
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if ( selected_count == 1 ) {
+        ProcInfo *selected_process = NULL;
+        // get the last selected row
+        gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &selected_process);
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing single process*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        } else {
+            /*xgettext: primary alert message for ending single process*/
+            primary = g_strdup_printf (_("Are you sure you want to end the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        }
+    } else {
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the %d selected processes?"),
+                                       selected_count);
+        } else {
+            /*xgettext: primary alert message for ending multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to end the %d selected processes?"),
+                                       selected_count);
+
+        }
+    }
+
+    if ( signal == SIGKILL ) {
+        /*xgettext: secondary alert message*/
+        secondary = _("Killing a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be killed.");
+        button_text = ngettext("_Kill Process", "_Kill Processes", selected_count);
+    } else {
+        /*xgettext: secondary alert message*/
+        secondary = _("Ending a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be ended.");
+        button_text = ngettext("_End Process", "_End Processes", selected_count);
+    }
+
+    kill_alert_dialog = gtk_message_dialog_new (GTK_WINDOW (procdata->app),
+                                                static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
+                                                GTK_MESSAGE_WARNING,
+                                                GTK_BUTTONS_NONE,
+                                                "%s",
+                                                primary);
+    g_free (primary);
+
+    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (kill_alert_dialog),
+                                              "%s",
+                                              secondary);
+
+    gtk_dialog_add_buttons (GTK_DIALOG (kill_alert_dialog),
+                            "gtk-cancel", GTK_RESPONSE_CANCEL,
+                            button_text, GTK_RESPONSE_OK,
+                            NULL);
+
+    gtk_dialog_set_default_response (GTK_DIALOG (kill_alert_dialog),
+                                     GTK_RESPONSE_CANCEL);
+
+    g_signal_connect (G_OBJECT (kill_alert_dialog), "response",
+                      G_CALLBACK (kill_dialog_button_pressed), kargs);
+
+    gtk_widget_show_all (kill_alert_dialog);
+}
+
+static void
+renice_scale_changed (GtkAdjustment *adj, gpointer data)
+{
+    GtkWidget *label = GTK_WIDGET (data);
+
+    new_nice_value = int(gtk_adjustment_get_value (adj));
+    gchar* text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (new_nice_value));
+    gtk_label_set_text (GTK_LABEL (label), text);
+    g_free(text);
+
+}
+
+static void
+renice_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (id == 100) {
+        if (new_nice_value == -100)
+            return;
+        renice(procdata, new_nice_value);
+    }
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+    renice_dialog = NULL;
+}
+
+void
+procdialog_create_renice_dialog (ProcData *procdata)
+{
+    ProcInfo  *info;
+    GtkWidget *dialog = NULL;
+    GtkWidget *dialog_vbox;
+    GtkWidget *vbox;
+    GtkWidget *label;
+    GtkWidget *priority_label;
+    GtkWidget *grid;
+    GtkAdjustment *renice_adj;
+    GtkWidget *hscale;
+    GtkWidget *button;
+    GtkWidget *icon;
+    gchar     *text;
+    gchar     *dialog_title;
+
+    if (renice_dialog)
+        return;
+
+    gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &info);
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if (!info)
+        return;
+
+    if ( selected_count == 1 ) {
+        dialog_title = g_strdup_printf (_("Change Priority of Process “%s†(PID: %u)"),
+                                        info->name, info->pid);
+    } else {
+        dialog_title = g_strdup_printf (_("Change Priority of %d Selected Processes"),
+                                        selected_count);
+    }
+
+    dialog = gtk_dialog_new_with_buttons (dialog_title, NULL,
+                                          GTK_DIALOG_DESTROY_WITH_PARENT,
+                                          "gtk-cancel", GTK_RESPONSE_CANCEL,
+                                          NULL);
+    g_free (dialog_title);
+
+    renice_dialog = dialog;
+    gtk_window_set_resizable (GTK_WINDOW (renice_dialog), FALSE);
+    gtk_container_set_border_width (GTK_CONTAINER (renice_dialog), 5);
+
+    button = gtk_button_new_with_mnemonic (_("Change _Priority"));
+    gtk_widget_set_can_default (button, TRUE);
+
+    icon = gtk_image_new_from_icon_name ("gtk-apply", GTK_ICON_SIZE_BUTTON);
+    gtk_button_set_image (GTK_BUTTON (button), icon);
+
+    gtk_dialog_add_action_widget (GTK_DIALOG (renice_dialog), button, 100);
+    gtk_dialog_set_default_response (GTK_DIALOG (renice_dialog), 100);
+    new_nice_value = -100;
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+    gtk_box_set_spacing (GTK_BOX (dialog_vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), vbox, TRUE, TRUE, 0);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+
+    grid = gtk_grid_new ();
+    gtk_grid_set_column_spacing (GTK_GRID(grid), 12);
+    gtk_grid_set_row_spacing (GTK_GRID(grid), 6);
+    gtk_box_pack_start (GTK_BOX (vbox), grid, TRUE, TRUE, 0);
+
+    label = gtk_label_new_with_mnemonic (_("_Nice value:"));
+    gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 2);
+
+    renice_adj = gtk_adjustment_new (info->nice, RENICE_VAL_MIN, RENICE_VAL_MAX, 1, 1, 0);
+    new_nice_value = 0;
+    hscale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, renice_adj);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), hscale);
+    gtk_scale_set_digits (GTK_SCALE (hscale), 0);
+    gtk_widget_set_hexpand (hscale, TRUE);
+    gtk_grid_attach (GTK_GRID (grid), hscale, 1, 0, 1, 1);
+    text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (info->nice));
+    priority_label = gtk_label_new (text);
+    gtk_grid_attach (GTK_GRID (grid), priority_label, 1, 1, 1, 1);
+    g_free(text);
+
+    text = g_strconcat("<small><i><b>", _("Note:"), "</b> ",
+        _("The priority of a process is given by its nice value. A lower nice value corresponds to a higher priority."),
+        "</i></small>", NULL);
+    label = gtk_label_new (_(text));
+    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+    g_free (text);
+
+    g_signal_connect (G_OBJECT (dialog), "response",
+                      G_CALLBACK (renice_dialog_button_pressed), procdata);
+    g_signal_connect (G_OBJECT (renice_adj), "value_changed",
+                      G_CALLBACK (renice_scale_changed), priority_label);
+
+    gtk_widget_show_all (dialog);
+
+
+}
+
+static void
+prefs_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    if (id == GTK_RESPONSE_HELP)
+    {
+        GError* error = 0;
+        if (!g_app_info_launch_default_for_uri("help:mate-system-monitor/mate-system-monitor-prefs", NULL, &error))
+        {
+            g_warning("Could not display preferences help : %s", error->message);
+            g_error_free(error);
+        }
+    }
+    else
+    {
+        gtk_widget_destroy (GTK_WIDGET (dialog));
+        prefs_dialog = NULL;
+    }
+}
+
+
+class SpinButtonUpdater
+{
+public:
+    SpinButtonUpdater(const string& key)
+        : key(key)
+    { }
+
+    static gboolean callback(GtkWidget *widget, GdkEventFocus *event, gpointer data)
+    {
+        SpinButtonUpdater* updater = static_cast<SpinButtonUpdater*>(data);
+        gtk_spin_button_update(GTK_SPIN_BUTTON(widget));
+        updater->update(GTK_SPIN_BUTTON(widget));
+        return FALSE;
+    }
+
+private:
+
+    void update(GtkSpinButton* spin)
+    {
+        int new_value = int(1000 * gtk_spin_button_get_value(spin));
+        g_settings_set_int(ProcData::get_instance()->settings,
+                           this->key.c_str(), new_value);
+
+        procman_debug("set %s to %d", this->key.c_str(), new_value);
+    }
+
+    const string key;
+};
+
+
+static void
+field_toggled (const gchar *child_schema, GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+    GtkTreeIter iter;
+    GtkTreeViewColumn *column;
+    gboolean toggled;
+    GSettings *settings = g_settings_get_child (ProcData::get_instance()->settings, child_schema);
+    gchar *key;
+    int id;
+
+    if (!path)
+        return;
+
+    gtk_tree_model_get_iter (model, &iter, path);
+
+    gtk_tree_model_get (model, &iter, 2, &column, -1);
+    toggled = gtk_cell_renderer_toggle_get_active (cell);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, !toggled, -1);
+    gtk_tree_view_column_set_visible (column, !toggled);
+
+    id = gtk_tree_view_column_get_sort_column_id (column);
+
+    key = g_strdup_printf ("col-%d-visible", id);
+    g_settings_set_boolean (settings, key, !toggled);
+    g_free (key);
+
+    gtk_tree_path_free (path);
+}
+
+static void
+proc_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("proctree", cell, path_str, data);
+}
+
+static void
+disk_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("disktreenew", cell, path_str, data);
+}
+
+static void
+create_field_page(GtkBuilder* builder, GtkWidget *tree, const gchar *widgetname)
+{
+    GtkTreeView *treeview;
+    GList *it, *columns;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;<--- Shadowed declaration
+    GtkCellRenderer *cell;
+    gchar *full_widgetname;
+
+    full_widgetname = g_strdup_printf ("%s_columns", widgetname);
+    treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, full_widgetname));
+    g_free (full_widgetname);
+
+    model = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER);
+
+    gtk_tree_view_set_model (GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(model));
+    g_object_unref (G_OBJECT (model));
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_toggle_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "active", 0,
+                                         NULL);
+
+    if (g_strcmp0 (widgetname, "proctree") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (proc_field_toggled), model);
+    else if (g_strcmp0 (widgetname, "disktreenew") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (disk_field_toggled), model);
+
+    gtk_tree_view_column_set_clickable (column, TRUE);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "text", 1,
+                                         NULL);
+
+    gtk_tree_view_column_set_title (column, "Not Shown");
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    for(it = columns; it; it = it->next)
+    {
+        GtkTreeViewColumn *column = static_cast<GtkTreeViewColumn*>(it->data);<--- Shadow variable
+        GtkTreeIter iter;
+        const gchar *title;
+        gboolean visible;
+        gint column_id;
+
+        title = gtk_tree_view_column_get_title (column);
+        if (!title)
+            title = _("Icon");
+
+        column_id = gtk_tree_view_column_get_sort_column_id(column);
+        if ((column_id == COL_CGROUP) && (!cgroups_enabled()))
+            continue;
+
+        if ((column_id == COL_UNIT ||
+             column_id == COL_SESSION ||
+             column_id == COL_SEAT ||
+             column_id == COL_OWNER)
+#ifdef HAVE_SYSTEMD
+            && !LOGIND_RUNNING()
+#endif
+                )
+            continue;
+
+        visible = gtk_tree_view_column_get_visible (column);
+
+        gtk_list_store_append (model, &iter);
+        gtk_list_store_set (model, &iter, 0, visible, 1, title, 2, column,-1);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procdialog_create_preferences_dialog (ProcData *procdata)
+{
+    typedef SpinButtonUpdater SBU;
+
+    static SBU interval_updater("update-interval");
+    static SBU graph_interval_updater("graph-update-interval");
+    static SBU disks_interval_updater("disks-interval");
+
+    GtkWidget *notebook;
+    GtkAdjustment *adjustment;
+    GtkWidget *spin_button;
+    GtkWidget *check_button;
+    GtkWidget *smooth_button;
+    GtkBuilder *builder;
+    gfloat update;
+
+    if (prefs_dialog)
+        return;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/preferences.ui");
+
+    prefs_dialog = GET_WIDGET("preferences_dialog");
+    notebook = GET_WIDGET("notebook");
+    spin_button = GET_WIDGET("processes_interval_spinner");
+
+    update = (gfloat) procdata->config.update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0,
+                                   MIN_UPDATE_INTERVAL / 1000,
+                                   MAX_UPDATE_INTERVAL / 1000,
+                                   0.25,
+                                   1.0,
+                                   0);
+
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK (SBU::callback), &interval_updater);
+
+    smooth_button = GET_WIDGET("smooth_button");
+    g_settings_bind(procdata->settings, SmoothRefresh::KEY.c_str(), smooth_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    check_button = GET_WIDGET("check_button");
+    g_settings_bind(procdata->settings, "kill-dialog", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    GtkWidget *solaris_button = GET_WIDGET("solaris_button");
+    g_settings_bind(procdata->settings, procman::settings::solaris_mode.c_str(), solaris_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->tree, "proctree");
+
+    update = (gfloat) procdata->config.graph_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0, 0.25,
+                                                      100.0, 0.25, 1.0, 0);
+
+    spin_button = GET_WIDGET("resources_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &graph_interval_updater);
+
+    GtkWidget *bits_button = GET_WIDGET("bits_button");
+    g_settings_bind(procdata->settings, procman::settings::network_in_bits.c_str(), bits_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+
+    update = (gfloat) procdata->config.disks_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new (update / 1000.0, 1.0,
+                                                       100.0, 1.0, 1.0, 0);
+
+    spin_button = GET_WIDGET("devices_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &disks_interval_updater);
+
+    check_button = GET_WIDGET("all_devices_check");
+    g_settings_bind(procdata->settings, "show-all-fs", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->disk_list, "disktreenew");
+
+    gtk_widget_show_all (prefs_dialog);
+    g_signal_connect (G_OBJECT (prefs_dialog), "response",
+                       G_CALLBACK (prefs_dialog_button_pressed), procdata);
+
+    switch (procdata->config.current_tab) {
+    case PROCMAN_TAB_SYSINFO:
+    case PROCMAN_TAB_PROCESSES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
+        break;
+    case PROCMAN_TAB_RESOURCES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 1);
+        break;
+    case PROCMAN_TAB_DISKS:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 2);
+        break;
+    }
+
+    gtk_builder_connect_signals (builder, NULL);
+    g_object_unref (G_OBJECT (builder));
+}
+
+
+static char *
+procman_action_to_command(ProcmanActionType type,
+                          gint pid,
+                          gint extra_value)
+{
+    switch (type) {
+    case PROCMAN_ACTION_KILL:
+           return g_strdup_printf("kill -s %d %d", extra_value, pid);
+    case PROCMAN_ACTION_RENICE:
+        return g_strdup_printf("renice %d %d", extra_value, pid);
+    default:
+        g_assert_not_reached();
+    }
+}
+
+
+/*
+ * type determines whether if dialog is for killing process or renice.
+ * type == PROCMAN_ACTION_KILL,   extra_value -> signal to send
+ * type == PROCMAN_ACTION_RENICE, extra_value -> new priority.
+ */
+gboolean
+procdialog_create_root_password_dialog(ProcmanActionType type,
+                                       ProcData *procdata,
+                                       gint pid,
+                                       gint extra_value)
+{
+    char * command;
+    gboolean ret = FALSE;
+
+    command = procman_action_to_command(type, pid, extra_value);
+
+    procman_debug("Trying to run '%s' as root", command);
+
+    if (procman_has_pkexec())
+        ret = procman_pkexec_create_root_password_dialog(command);
+    else if (procman_has_gksu())
+        ret = procman_gksu_create_root_password_dialog(command);
+
+    g_free(command);
+    return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/14.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/14.html new file mode 100644 index 00000000..3c8a776c --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/14.html @@ -0,0 +1,1109 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
#include <glib/gi18n.h>
+#include <glibtop.h>
+#include <glibtop/close.h>
+#include <glibtop/cpu.h>
+#include <glibtop/sysinfo.h>
+
+#include "procman-app.h"
+#include "procman.h"
+#include "interface.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "argv.h"
+#include "util.h"
+
+static void
+mount_changed(const Glib::RefPtr<Gio::Mount>&)
+{
+    cb_update_disks(ProcData::get_instance());
+}
+
+
+static void
+init_volume_monitor(ProcData *procdata)
+{
+    using namespace Gio;
+    using namespace Glib;
+
+    RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+    monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
+}
+
+static gboolean
+has_key (gchar **keys, const gchar *key)
+{
+    gchar **loop = keys;
+
+    while (*loop) {
+        if (!strcmp (*loop++, key))
+            return TRUE;
+    }
+
+    return FALSE;
+}
+
+static void
+tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_tree = g_settings_get_boolean(settings, key);
+
+    g_object_set(G_OBJECT(procdata->tree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
+    proctable_update (procdata);
+}
+
+
+static void
+network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
+    // force scale to be redrawn
+    procdata->net_graph->clear_background();
+}
+
+static void
+view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.whose_process = g_settings_get_int (settings, key);
+    procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2);
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "kill-dialog")) {
+        procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
+    }
+}
+
+static void
+timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "update-interval")) {
+        procdata->config.update_interval = g_settings_get_int (settings, key);
+        procdata->config.update_interval =
+            MAX (procdata->config.update_interval, 1000);
+
+        procdata->smooth_refresh->reset();
+
+        if(procdata->timeout) {
+            g_source_remove (procdata->timeout);
+            procdata->timeout = g_timeout_add (procdata->config.update_interval,
+                                               cb_timeout,
+                                               procdata);
+        }
+    }
+    else if (g_str_equal (key, "graph-update-interval")){
+        procdata->config.graph_update_interval = g_settings_get_int (settings, key);
+        procdata->config.graph_update_interval =
+            MAX (procdata->config.graph_update_interval,
+                 250);
+        load_graph_change_speed(procdata->cpu_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->mem_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->net_graph,
+                                procdata->config.graph_update_interval);
+    }
+    else if (g_str_equal(key, "disks-interval")) {
+        procdata->config.disks_update_interval = g_settings_get_int (settings, key);
+        procdata->config.disks_update_interval =
+            MAX (procdata->config.disks_update_interval, 1000);
+
+        if(procdata->disk_timeout) {
+            g_source_remove (procdata->disk_timeout);
+            procdata->disk_timeout = \
+                g_timeout_add (procdata->config.disks_update_interval,
+                               cb_update_disks,
+                               procdata);
+        }
+    }
+    else {
+        g_assert_not_reached();
+    }
+}
+
+static void
+color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    gchar *color = g_settings_get_string (settings, key);
+
+    if (g_str_has_prefix (key, "cpu-color")) {
+        for (int i = 0; i < procdata->config.num_cpus; i++) {
+            string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
+            if (cpu_key == key) {
+                gdk_rgba_parse (&procdata->config.cpu_color[i], color);
+                procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
+                break;
+            }
+        }
+    }
+    else if (g_str_equal (key, "mem-color")) {
+        gdk_rgba_parse (&procdata->config.mem_color, color);
+        procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
+    }
+    else if (g_str_equal (key, "swap-color")) {
+        gdk_rgba_parse (&procdata->config.swap_color, color);
+        procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
+    }
+    else if (g_str_equal (key, "net-in-color")) {
+        gdk_rgba_parse (&procdata->config.net_in_color, color);
+        procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
+    }
+    else if (g_str_equal (key, "net-out-color")) {
+        gdk_rgba_parse (&procdata->config.net_out_color, color);
+        procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
+    }
+    else {
+        g_assert_not_reached();
+    }
+    g_free(color);
+}
+
+static void
+show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
+
+    cb_update_disks (data);
+}
+
+static ProcData *
+procman_data_new (GSettings *settings)
+{
+    GSettingsSchema *schema;
+    ProcData *pd;
+    gchar *color;
+    gchar **keys;
+    glibtop_cpu cpu;
+
+    pd = ProcData::get_instance();
+
+    g_settings_get (settings, "window-state", "(iiii)",
+                    &pd->config.width, &pd->config.height,
+                    &pd->config.xpos, &pd->config.ypos);
+
+    pd->config.maximized = g_settings_get_boolean(settings, "maximized");
+
+    pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
+    g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd);
+
+    pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
+    std::string detail_string("changed::" + procman::settings::solaris_mode);
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd);
+
+    pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
+    detail_string = "changed::" + procman::settings::network_in_bits;
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd);
+
+    pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
+    g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd);
+    pd->config.update_interval = g_settings_get_int (settings, "update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.graph_update_interval = g_settings_get_int (settings,
+                                                           "graph-update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",
+                      G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd);
+
+
+    /* show_all_fs */
+    pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
+    g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd);
+
+
+    pd->config.whose_process = g_settings_get_int (settings, "view-as");
+    g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd);
+    pd->config.current_tab = g_settings_get_int (settings, "current-tab");
+
+    glibtop_get_cpu (&cpu);
+    pd->frequency = cpu.frequency;
+    pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
+
+    g_object_get (settings, "settings-schema", &schema, NULL);
+    keys = g_settings_schema_list_keys (schema);
+    g_settings_schema_unref (schema);
+
+    for (int i = 0; i < pd->config.num_cpus; i++) {
+        gchar *key;
+        key = g_strdup_printf ("cpu-color%d", i);
+
+        if (has_key (keys, key))
+            color = g_settings_get_string (settings, key);
+        else
+            color = g_strdup ("#f25915e815e8");
+        detail_string = std::string("changed::") + std::string(key);
+        g_signal_connect (G_OBJECT(settings), detail_string.c_str(),
+                          G_CALLBACK(color_changed_cb), pd);
+        gdk_rgba_parse (&pd->config.cpu_color[i], color);
+        g_free (color);
+        g_free (key);
+    }
+    g_strfreev (keys);
+
+    color = g_settings_get_string (settings, "mem-color");
+    if (!color)
+        color = g_strdup ("#000000ff0082");
+    g_signal_connect (G_OBJECT(settings), "changed::mem-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.mem_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "swap-color");
+    if (!color)
+        color = g_strdup ("#00b6000000ff");
+    g_signal_connect (G_OBJECT(settings), "changed::swap-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.swap_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-in-color");
+    if (!color)
+        color = g_strdup ("#000000f200f2");
+    g_signal_connect (G_OBJECT(settings), "changed::net-in-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_in_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-out-color");
+    if (!color)
+        color = g_strdup ("#00f2000000c1");
+    g_signal_connect (G_OBJECT(settings), "changed::net-out-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_out_color, color);
+    g_free (color);
+
+    /* Sanity checks */
+    GdkDisplay *display;
+    GdkMonitor *monitor;
+    GdkRectangle monitor_geometry;
+
+    display = gdk_display_get_default ();
+    monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
+    if (monitor == NULL) {
+        monitor = gdk_display_get_monitor (display, 0);
+    }
+    gdk_monitor_get_geometry (monitor, &monitor_geometry);
+
+    pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width);
+    pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height);
+    pd->config.update_interval = MAX (pd->config.update_interval, 1000);
+    pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250);
+    pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000);
+    pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2);
+    pd->config.current_tab = CLAMP(pd->config.current_tab,
+                                   PROCMAN_TAB_SYSINFO,
+                                   PROCMAN_TAB_DISKS);
+
+    // delayed initialization as SmoothRefresh() needs ProcData
+    // i.e. we can't call ProcData::get_instance
+    pd->smooth_refresh = new SmoothRefresh(settings);
+
+    pd->terminating = FALSE;
+
+    return pd;
+}
+
+static void
+procman_free_data (ProcData *procdata)
+{
+
+    proctable_free_table (procdata);
+    delete procdata->smooth_refresh;
+}
+
+ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)<--- Member variable 'ProcmanApp::procdata' is not initialized in the constructor.
+{
+    Glib::set_application_name(_("System Monitor"));
+}
+
+Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
+{
+    return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
+}
+
+void ProcmanApp::on_activate()
+{
+    gtk_window_present (GTK_WINDOW (procdata->app));
+}
+
+static void
+set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
+{
+    gtk_notebook_set_current_page(notebook, tab);
+    cb_change_current_page(notebook, tab, procdata);
+}
+
+int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
+{
+    int argc = 0;
+    char** argv = command_line->get_arguments(argc);
+
+    Glib::OptionContext context;
+    context.set_summary(_("A simple process and system monitor."));
+    context.set_ignore_unknown_options(true);
+    procman::OptionGroup option_group;
+    context.set_main_group(option_group);
+
+    try {
+        context.parse(argc, argv);
+    } catch (const Glib::Error& ex) {
+        g_error("Arguments parse error : %s", ex.what().c_str());
+    }
+
+    if (option_group.show_system_tab) {
+        procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_SYSINFO, procdata);
+    } else if (option_group.show_processes_tab) {
+        procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_PROCESSES, procdata);
+    } else if (option_group.show_resources_tab) {
+        procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_RESOURCES, procdata);
+    } else if (option_group.show_file_systems_tab) {
+        procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_DISKS, procdata);
+    }
+
+    on_activate ();
+
+    return 0;
+}
+
+void ProcmanApp::on_startup()
+{
+    Gtk::Application::on_startup();
+
+    GSettings *settings;
+
+    Gtk::Window::set_default_icon_name ("utilities-system-monitor");
+
+    settings = g_settings_new (GSM_GSETTINGS_SCHEMA);
+
+    glibtop_init ();
+
+    procdata = procman_data_new (settings);
+    procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA);
+
+    create_main_window (procdata);
+    init_volume_monitor (procdata);
+
+    Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app));
+    window->show();
+    window->set_name ("mate-system-monitor");
+
+    add_window (*window);
+}
+
+void ProcmanApp::on_shutdown()
+{
+    procman_free_data(procdata);
+    glibtop_close();
+}
+
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/15.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/15.html new file mode 100644 index 00000000..caf6d784 --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/15.html @@ -0,0 +1,671 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+
+#include <locale.h>
+
+#include <gtkmm.h>
+#include <glib/gi18n.h>
+
+#include "procman-app.h"
+#include "procman.h"
+#include "proctable.h"
+
+ProcData::ProcData()<--- Member variable 'ProcData::uimanager' is not initialized in the constructor.<--- Member variable 'ProcData::action_group' is not initialized in the constructor.<--- Member variable 'ProcData::statusbar' is not initialized in the constructor.<--- Member variable 'ProcData::loadavg' is not initialized in the constructor.<--- Member variable 'ProcData::endprocessbutton' is not initialized in the constructor.<--- Member variable 'ProcData::popup_menu' is not initialized in the constructor.<--- Member variable 'ProcData::disk_list' is not initialized in the constructor.<--- Member variable 'ProcData::notebook' is not initialized in the constructor.<--- Member variable 'ProcData::config' is not initialized in the constructor.<--- Member variable 'ProcData::selection' is not initialized in the constructor.<--- Member variable 'ProcData::settings' is not initialized in the constructor.<--- Member variable 'ProcData::app' is not initialized in the constructor.<--- Member variable 'ProcData::menu' is not initialized in the constructor.<--- Member variable 'ProcData::frequency' is not initialized in the constructor.<--- Member variable 'ProcData::smooth_refresh' is not initialized in the constructor.
+    : tree(NULL),
+      cpu_graph(NULL),
+      mem_graph(NULL),
+      net_graph(NULL),
+      selected_process(NULL),
+      timeout(0),
+      disk_timeout(0),
+      cpu_total_time(1),
+      cpu_total_time_last(1)
+{ }
+
+ProcData* ProcData::get_instance()
+{
+    static ProcData instance;
+    return &instance;
+}
+
+gboolean
+procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns, *it;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    sort_col = g_settings_get_int (pt_settings, "sort-col");
+
+    order = static_cast<GtkSortType>(g_settings_get_int (pt_settings, "sort-order"));
+
+    if (sort_col != -1)
+        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
+                                              sort_col,
+                                              order);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        for (it = columns; it; it = it->next)
+        {
+            GtkTreeViewColumn *column;
+            gint width;
+            gboolean visible;
+            int id;
+            gchar *key;
+
+            column = static_cast<GtkTreeViewColumn*>(it->data);
+            id = gtk_tree_view_column_get_sort_column_id (column);
+
+            key = g_strdup_printf ("col-%d-width", id);
+            g_settings_get (pt_settings, key, "i", &width);
+            g_free (key);
+
+            key = g_strdup_printf ("col-%d-visible", id);
+            visible = g_settings_get_boolean (pt_settings, key);
+            g_free (key);
+
+            gtk_tree_view_column_set_visible (column, visible);
+            if (visible) {
+                /* ensure column is really visible */
+                width = MAX(width, 20);
+                gtk_tree_view_column_set_fixed_width(column, width);
+            }
+        }
+
+        GVariant     *value;
+        GVariantIter iter;
+        int          sortIndex;
+
+        GSList *order = NULL;<--- Shadow variable
+
+        value = g_settings_get_value(pt_settings, "columns-order");
+        g_variant_iter_init(&iter, value);
+
+        while (g_variant_iter_loop (&iter, "i", &sortIndex))
+            order = g_slist_append(order, GINT_TO_POINTER(sortIndex));
+
+        proctable_set_columns_order(GTK_TREE_VIEW(tree), order);
+
+        g_variant_unref(value);
+        g_slist_free(order);
+    }
+
+    g_object_unref(pt_settings);
+    pt_settings = NULL;
+
+    g_list_free(columns);
+
+    return TRUE;
+}
+
+void
+procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    if (ProcData::get_instance()->terminating)
+        return;
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    if (gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (model), &sort_col,
+                                              &order)) {
+        g_settings_set_int (pt_settings, "sort-col", sort_col);
+        g_settings_set_int (pt_settings, "sort-order", order);
+    }
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        GSList *order;<--- Shadow variable
+        GSList *order_node;
+        GVariantBuilder *builder;
+        GVariant *order_variant;
+
+        order = proctable_get_columns_order(GTK_TREE_VIEW(tree));
+
+        builder = g_variant_builder_new (G_VARIANT_TYPE ("ai"));
+
+        for (order_node = order; order_node; order_node = order_node->next)
+            g_variant_builder_add(builder, "i", GPOINTER_TO_INT(order_node->data));
+
+        order_variant = g_variant_new("ai", builder);
+        g_settings_set_value(pt_settings, "columns-order", order_variant);
+
+        g_slist_free(order);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procman_save_config (ProcData *data)
+{
+    GSettings *settings = data->settings;
+
+    g_assert(data);
+
+    data->config.maximized = gdk_window_get_state(gtk_widget_get_window (data->app)) & GDK_WINDOW_STATE_MAXIMIZED;
+    if (!data->config.maximized) {
+        // we only want to store/overwrite size and position info with non-maximized state info
+        data->config.width  = gdk_window_get_width (gtk_widget_get_window (data->app));
+        data->config.height = gdk_window_get_height(gtk_widget_get_window (data->app));
+
+        gtk_window_get_position(GTK_WINDOW(data->app), &data->config.xpos, &data->config.ypos);
+
+        g_settings_set (settings, "window-state", "(iiii)",
+                        data->config.width, data->config.height,
+                        data->config.xpos, data->config.ypos);
+    }
+    g_settings_set_boolean (settings, "maximized", data->config.maximized);
+
+    g_settings_set_int (settings, "current-tab", data->config.current_tab);
+}
+
+int
+main (int argc, char *argv[])
+{
+    bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+    textdomain (GETTEXT_PACKAGE);
+    setlocale (LC_ALL, "");
+
+    Glib::RefPtr<ProcmanApp> application = ProcmanApp::create();
+    return application->run (argc, argv);
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/16.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/16.html new file mode 100644 index 00000000..91267585 --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/16.html @@ -0,0 +1,913 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
/* Process properties dialog
+ * Copyright (C) 2010 Krishnan Parthasarathi <krishnan.parthasarathi@gmail.com>
+ *                    Robert Ancell <robert.ancell@canonical.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <glibtop/procmem.h>
+#include <glibtop/procmap.h>
+#include <glibtop/procstate.h>
+
+#include "procman.h"
+#include "procproperties.h"
+#include "proctable.h"
+#include "util.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
+enum
+{
+    COL_PROP = 0,
+    COL_VAL,
+    NUM_COLS,
+};
+
+typedef struct _proc_arg {
+    const gchar *prop;
+    gchar *val;
+} proc_arg;
+
+static void
+get_process_memory_writable (ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info (ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+static gchar*
+format_memsize(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
+}
+
+static gchar*
+format_size(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size(size);
+}
+
+static void
+fill_proc_properties (GtkWidget *tree, ProcInfo *info)
+{
+    guint i;
+    GtkListStore *store;
+
+    if (!info)
+        return;
+
+    get_process_memory_info(info);
+
+    proc_arg proc_props[] = {
+        { N_("Process Name"), g_strdup_printf("%s", info->name)},
+        { N_("User"), g_strdup_printf("%s (%d)", info->user.c_str(), info->uid)},
+        { N_("Status"), g_strdup(format_process_state(info->status))},
+        { N_("Memory"), format_memsize(info->mem)},
+        { N_("Virtual Memory"), format_memsize(info->vmsize)},
+        { N_("Resident Memory"), format_memsize(info->memres)},
+        { N_("Writable Memory"), format_memsize(info->memwritable)},
+        { N_("Shared Memory"), format_memsize(info->memshared)},
+#ifdef HAVE_WNCK
+        { N_("X Server Memory"), format_memsize(info->memxserver)},
+#endif
+        { N_("Disk Read Total"), format_size(info->disk_read_bytes_total)},
+        { N_("Disk Write Total"), format_size(info->disk_write_bytes_total)},
+        { N_("CPU"), g_strdup_printf("%d%%", info->pcpu)},
+        { N_("CPU Time"), procman::format_duration_for_display(100 * info->cpu_time / ProcData::get_instance()->frequency) },
+        { N_("Started"), procman_format_date_for_display(info->start_time) },
+        { N_("Nice"), g_strdup_printf("%d", info->nice)},
+        { N_("Priority"), g_strdup_printf("%s", procman::get_nice_level(info->nice)) },
+        { N_("ID"), g_strdup_printf("%d", info->pid)},
+        { N_("Security Context"), info->security_context ? g_strdup_printf("%s", info->security_context) : g_strdup(_("N/A"))},
+        { N_("Command Line"), g_strdup_printf("%s", info->arguments)},
+        { N_("Waiting Channel"), g_strdup_printf("%s", info->wchan)},
+        { N_("Control Group"), info->cgroup_name ? g_strdup_printf("%s", info->cgroup_name) : g_strdup(_("N/A"))},
+        { NULL, NULL}
+    };
+
+    store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
+    for (i = 0; proc_props[i].prop; i++) {
+        GtkTreeIter iter;
+
+        if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL(store), &iter, NULL, i)) {
+            gtk_list_store_append(store, &iter);
+            gtk_list_store_set(store, &iter, COL_PROP, _(proc_props[i].prop), -1);
+        }
+
+        gtk_list_store_set(store, &iter, COL_VAL, g_strstrip(proc_props[i].val), -1);
+        g_free(proc_props[i].val);
+    }
+}
+
+static void
+update_procproperties_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    fill_proc_properties(tree, info);
+}
+
+static void
+close_procprop_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    guint timer;
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static GtkWidget *
+create_procproperties_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    model = gtk_list_store_new (NUM_COLS,
+                                G_TYPE_STRING,	/* Property */
+                                G_TYPE_STRING	/* Value */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_COLS; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        column = gtk_tree_view_column_new_with_attributes (NULL,
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tree), FALSE);
+    fill_proc_properties(tree, procdata->selected_process);
+
+    return tree;
+}
+
+static gboolean
+procprop_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_procproperties_dialog (tree);
+
+    return TRUE;
+}
+
+static void
+create_single_procproperties_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                     GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *procpropdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    procpropdialog = gtk_dialog_new_with_buttons (_("Process Properties"), NULL,
+                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                  "gtk-close", GTK_RESPONSE_CLOSE,
+                                                  NULL);
+    gtk_window_set_resizable (GTK_WINDOW (procpropdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (procpropdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (procpropdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (procpropdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("Properties of process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_procproperties_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (procpropdialog), "response",
+                      G_CALLBACK (close_procprop_dialog), tree);
+
+    gtk_widget_show_all (procpropdialog);
+
+    timer = g_timeout_add_seconds (5, procprop_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_procproperties_dialog (tree);
+}
+
+void
+create_procproperties_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_procproperties_dialog,
+                                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/17.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/17.html new file mode 100644 index 00000000..3ce08395 --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/17.html @@ -0,0 +1,2635 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
/* Procman tree view and process updating
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <cairo-gobject.h>
+#include <string.h>
+#include <math.h>
+#include <glib/gi18n.h>
+#include <glib/gprintf.h>
+#include <glibtop.h>
+#include <glibtop/loadavg.h>
+#include <glibtop/proclist.h>
+#include <glibtop/procio.h>
+#include <glibtop/procstate.h>
+#include <glibtop/procmem.h>
+#include <glibtop/procmap.h>
+#include <glibtop/proctime.h>
+#include <glibtop/procuid.h>
+#include <glibtop/procargs.h>
+#include <glibtop/prockernel.h>
+#include <glibtop/mem.h>
+#include <glibtop/swap.h>
+#include <sys/stat.h>
+#include <pwd.h>
+#include <time.h>
+
+#include <set>
+#include <list>
+
+#ifdef HAVE_SYSTEMD
+#include <systemd/sd-login.h>
+#endif
+
+#include "procman.h"
+#include "selection.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "util.h"
+#include "interface.h"
+#include "selinux.h"
+#include "cgroups.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
+ProcInfo::UserMap ProcInfo::users;
+ProcInfo::List ProcInfo::all;
+std::map<pid_t, guint64> ProcInfo::cpu_times;
+
+
+ProcInfo* ProcInfo::find(pid_t pid)
+{
+    Iterator it(ProcInfo::all.find(pid));
+    return (it == ProcInfo::all.end() ? NULL : it->second);
+}
+
+void
+get_last_selected (GtkTreeModel *model, GtkTreePath *path,
+           GtkTreeIter *iter, gpointer data)
+{
+    ProcInfo **info = static_cast<ProcInfo**>(data);
+
+    gtk_tree_model_get (model, iter, COL_POINTER, info, -1);
+}
+
+static void
+cb_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "proctree");
+}
+
+static void
+cb_sort_changed (GtkTreeSortable *model, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state (procdata->settings,
+                             GTK_WIDGET (procdata->tree),
+                             "proctree");
+}
+
+
+static GtkTreeViewColumn*
+my_gtk_tree_view_get_column_with_sort_column_id(GtkTreeView *treeview, int id)
+{
+    GList *columns, *it;
+    GtkTreeViewColumn *col = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(it = columns; it; it = it->next)
+    {
+        if(gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(it->data)) == id)
+        {
+            col = static_cast<GtkTreeViewColumn*>(it->data);
+            break;
+        }
+    }
+
+    g_list_free(columns);
+
+    return col;
+}
+
+
+void
+proctable_set_columns_order(GtkTreeView *treeview, GSList *order)
+{
+    GtkTreeViewColumn* last = NULL;
+    GSList *it;
+
+    for(it = order; it; it = it->next)
+    {
+        int id;
+        GtkTreeViewColumn *cur;
+
+        id = GPOINTER_TO_INT(it->data);
+
+        cur = my_gtk_tree_view_get_column_with_sort_column_id(treeview, id);
+
+        if(cur && cur != last)
+        {
+            gtk_tree_view_move_column_after(treeview, cur, last);
+            last = cur;
+        }
+    }
+}
+
+
+GSList*
+proctable_get_columns_order(GtkTreeView *treeview)
+{
+    GList *columns, *col;
+    GSList *order = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(col = columns; col; col = col->next)
+    {
+        int id;
+
+        id = gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(col->data));
+        order = g_slist_prepend(order, GINT_TO_POINTER(id));
+    }
+
+    g_list_free(columns);
+
+    order = g_slist_reverse(order);
+
+    return order;
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "proctree");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_proctable_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+static gboolean
+search_equal_func(GtkTreeModel *model,
+                  gint column,
+                  const gchar *key,
+                  GtkTreeIter *iter,
+                  gpointer search_data)
+{
+    char* name;
+    char* user;
+    gboolean found;
+
+    gtk_tree_model_get(model, iter,
+                       COL_NAME, &name,
+                       COL_USER, &user,
+                       -1);
+
+    found = !((name && strcasestr(name, key))
+              || (user && strcasestr(user, key)));
+
+    g_free(name);
+    g_free(user);
+
+    return found;
+}
+
+
+
+GtkWidget *
+proctable_new (ProcData * const procdata)
+{
+    GtkWidget *proctree;
+    GtkTreeStore *model;
+    GtkTreeSelection *selection;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell_renderer;
+
+    const gchar *titles[] = {
+        N_("Process Name"),
+        N_("User"),
+        N_("Status"),
+        N_("Virtual Memory"),
+        N_("Resident Memory"),
+        N_("Writable Memory"),
+        N_("Shared Memory"),
+        N_("X Server Memory"),
+        /* xgettext:no-c-format */ N_("% CPU"),
+        N_("CPU Time"),
+        N_("Started"),
+        N_("Nice"),
+        N_("ID"),
+        N_("Security Context"),
+        N_("Command Line"),
+        N_("Memory"),
+        /* xgettext: combined noun, the function the process is waiting in, see wchan ps(1) */
+        N_("Waiting Channel"),
+        N_("Control Group"),
+        N_("Unit"),
+        N_("Session"),
+        /* TRANSLATORS: Seat = i.e. the physical seat the session of the process belongs to, only
+	for multi-seat environments. See http://en.wikipedia.org/wiki/Multiseat_configuration */
+        N_("Seat"),
+        N_("Owner"),
+        N_("Disk Read Total"),
+        N_("Disk Write Total"),
+        N_("Disk Read"),
+        N_("Disk Write"),
+        N_("Priority"),
+        NULL,
+        "POINTER"
+    };
+
+    gint i;
+
+    model = gtk_tree_store_new (NUM_COLUMNS,
+                                G_TYPE_STRING,              /* Process Name */
+                                G_TYPE_STRING,              /* User         */
+                                G_TYPE_UINT,                /* Status       */
+                                G_TYPE_ULONG,               /* VM Size      */
+                                G_TYPE_ULONG,               /* Resident Memory */
+                                G_TYPE_ULONG,               /* Writable Memory */
+                                G_TYPE_ULONG,               /* Shared Memory */
+                                G_TYPE_ULONG,               /* X Server Memory */
+                                G_TYPE_UINT,                /* % CPU        */
+                                G_TYPE_UINT64,              /* CPU time     */
+                                G_TYPE_ULONG,               /* Started      */
+                                G_TYPE_INT,                 /* Nice         */
+                                G_TYPE_UINT,                /* ID           */
+                                G_TYPE_STRING,              /* Security Context */
+                                G_TYPE_STRING,              /* Arguments    */
+                                G_TYPE_ULONG,               /* Memory       */
+                                G_TYPE_STRING,              /* wchan        */
+                                G_TYPE_STRING,              /* Cgroup       */
+                                G_TYPE_STRING,              /* Unit         */
+                                G_TYPE_STRING,              /* Session      */
+                                G_TYPE_STRING,              /* Seat         */
+                                G_TYPE_STRING,              /* Owner        */
+                                G_TYPE_UINT64,              /* Disk read total */
+                                G_TYPE_UINT64,              /* Disk write total*/
+                                G_TYPE_UINT64,              /* Disk read    */
+                                G_TYPE_UINT64,              /* Disk write   */
+                                G_TYPE_STRING,              /* Priority     */
+                                CAIRO_GOBJECT_TYPE_SURFACE, /* Icon         */
+                                G_TYPE_POINTER,             /* ProcInfo     */
+                                G_TYPE_STRING               /* Sexy tooltip */
+        );
+
+    proctree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (proctree), COL_TOOLTIP);
+    g_object_set(G_OBJECT(proctree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+    gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (proctree),
+                                         search_equal_func,
+                                         NULL,
+                                         NULL);
+    g_object_unref (G_OBJECT (model));
+
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree));
+    gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+
+    column = gtk_tree_view_column_new ();
+
+    cell_renderer = gtk_cell_renderer_pixbuf_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "surface", COL_SURFACE,
+                                         NULL);
+
+    cell_renderer = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "text", COL_NAME,
+                                         NULL);
+    gtk_tree_view_column_set_title (column, _(titles[0]));
+    gtk_tree_view_column_set_sort_column_id (column, COL_NAME);
+    gtk_tree_view_column_set_resizable (column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+    gtk_tree_view_column_set_min_width (column, 20);
+    gtk_tree_view_column_set_reorderable (column, TRUE);
+    g_signal_connect(G_OBJECT(column), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (proctree), column);
+    gtk_tree_view_set_expander_column (GTK_TREE_VIEW (proctree), column);
+
+
+    for (i = COL_USER; i <= COL_PRIORITY; i++) {
+
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+#ifndef HAVE_WNCK
+        if (i == COL_MEMXSERVER) {
+          continue;
+        }
+#endif
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(proctree), col);
+
+        // type
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_CPU_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::duration_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_START_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::time_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_STATUS:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::status_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::io_rate_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_PRIORITY:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::priority_cell_data_func,
+                                                        GUINT_TO_POINTER(COL_NICE),
+                                                        NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+        }
+
+        // sorting
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+            case COL_CPU:
+            case COL_CPU_TIME:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_START_TIME:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::number_compare_func, GUINT_TO_POINTER(i),
+                                                NULL);
+                break;
+            case COL_PRIORITY:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::priority_compare_func,
+                                                GUINT_TO_POINTER(COL_NICE), NULL);
+                break;
+            default:
+                break;
+        }
+
+        // xalign
+        switch(i)
+        {
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMWRITABLE:
+            case COL_MEMSHARED:
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_CPU:
+            case COL_NICE:
+            case COL_PID:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_CPU_TIME:
+            case COL_MEM:
+                g_object_set(G_OBJECT(cell), "xalign", 1.0f, NULL);
+                break;
+        }
+
+        // sizing
+        switch (i) {
+            case COL_ARGS:
+                gtk_tree_view_column_set_min_width(col, 150);
+                break;
+            default:
+                gtk_tree_view_column_set_min_width(col, 20);
+                break;
+        }
+    }
+
+    procdata->tree = proctree;
+
+    procman_get_tree_state (procdata->settings, proctree, "proctree");
+
+    /* Override column settings by hiding this column if it's meaningless: */
+    if (!can_show_security_context_column ()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id (GTK_TREE_VIEW (proctree), COL_SECURITYCONTEXT);
+        gtk_tree_view_column_set_visible (column, FALSE);
+    }
+
+    if (!cgroups_enabled()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), COL_CGROUP);
+        gtk_tree_view_column_set_visible(column, FALSE);
+    }
+
+#ifdef HAVE_SYSTEMD
+    if (!LOGIND_RUNNING())
+#endif
+    {
+        for (i = COL_UNIT; i <= COL_OWNER; i++) {
+            column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), i);
+            gtk_tree_view_column_set_visible(column, FALSE);
+        }
+    }
+
+    g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree))),
+                      "changed",
+                      G_CALLBACK (cb_row_selected), procdata);
+    g_signal_connect (G_OBJECT (proctree), "popup_menu",
+                      G_CALLBACK (cb_tree_popup_menu), procdata);
+    g_signal_connect (G_OBJECT (proctree), "button_press_event",
+                      G_CALLBACK (cb_tree_button_pressed), procdata);
+
+    g_signal_connect (G_OBJECT(proctree), "columns-changed",
+                      G_CALLBACK(cb_columns_changed), procdata);
+
+    g_signal_connect (G_OBJECT (model), "sort-column-changed",
+                      G_CALLBACK (cb_sort_changed), procdata);
+
+    return proctree;
+}
+
+
+ProcInfo::~ProcInfo()
+{
+    g_free(this->name);
+    g_free(this->tooltip);
+    g_free(this->arguments);
+    g_free(this->security_context);
+    g_free(this->cgroup_name);
+    g_free(this->unit);
+    g_free(this->session);
+    g_free(this->seat);
+    cairo_surface_destroy(this->surface);
+}
+
+
+static void
+get_process_name (ProcInfo *info,
+                  const gchar *cmd, const GStrv args)
+{
+    if (args) {
+        // look for /usr/bin/very_long_name
+        // and also /usr/bin/interpreter /usr/.../very_long_name
+        // which may have use prctl to alter 'cmd' name
+        for (int i = 0; i != 2 && args[i]; ++i) {
+            char* basename;
+            basename = g_path_get_basename(args[i]);
+
+            if (g_str_has_prefix(basename, cmd)) {
+                info->name = basename;
+                return;
+            }
+
+            g_free(basename);
+        }
+    }
+
+    info->name = g_strdup (cmd);
+}
+
+std::string
+ProcInfo::lookup_user(guint uid)
+{
+    typedef std::pair<ProcInfo::UserMap::iterator, bool> Pair;
+    ProcInfo::UserMap::value_type hint(uid, "");
+    Pair p(ProcInfo::users.insert(hint));
+
+    // procman_debug("User lookup for uid %u: %s", uid, (p.second ? "MISS" : "HIT"));
+
+    if (p.second) {
+        struct passwd* pwd;
+        pwd = getpwuid(uid);
+
+        if (pwd && pwd->pw_name)
+            p.first->second = pwd->pw_name;
+        else {
+            char username[16];
+            g_sprintf(username, "%u", uid);
+            p.first->second = username;
+        }
+    }
+
+    return p.first->second;
+}
+
+void
+ProcInfo::set_user(guint uid)
+{
+    if (G_LIKELY(this->uid == uid))
+        return;
+
+    this->uid = uid;
+    this->user = lookup_user(uid);
+}
+
+static void get_process_memory_writable(ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info(ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+
+static void
+update_info_mutable_cols(ProcInfo *info)
+{
+    ProcData * const procdata = ProcData::get_instance();
+    GtkTreeModel *model;
+    model = gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->tree));
+
+    using procman::tree_store_update;
+
+    tree_store_update(model, &info->node, COL_STATUS, info->status);
+    tree_store_update(model, &info->node, COL_USER, info->user.c_str());
+    tree_store_update(model, &info->node, COL_VMSIZE, info->vmsize);
+    tree_store_update(model, &info->node, COL_MEMRES, info->memres);
+    tree_store_update(model, &info->node, COL_MEMWRITABLE, info->memwritable);
+    tree_store_update(model, &info->node, COL_MEMSHARED, info->memshared);
+#ifdef HAVE_WNCK
+    tree_store_update(model, &info->node, COL_MEMXSERVER, info->memxserver);
+#endif
+    tree_store_update(model, &info->node, COL_CPU, info->pcpu);
+    tree_store_update(model, &info->node, COL_CPU_TIME, info->cpu_time);
+    tree_store_update(model, &info->node, COL_DISK_READ_TOTAL, info->disk_read_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_TOTAL, info->disk_write_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_READ_CURRENT, info->disk_read_bytes_current);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_CURRENT, info->disk_write_bytes_current);
+    tree_store_update(model, &info->node, COL_START_TIME, info->start_time);
+    tree_store_update(model, &info->node, COL_NICE, info->nice);
+    tree_store_update(model, &info->node, COL_MEM, info->mem);
+    tree_store_update(model, &info->node, COL_WCHAN, info->wchan);
+    tree_store_update(model, &info->node, COL_CGROUP, info->cgroup_name);
+    tree_store_update(model, &info->node, COL_UNIT, info->unit);
+    tree_store_update(model, &info->node, COL_SESSION, info->session);
+    tree_store_update(model, &info->node, COL_SEAT, info->seat);
+    tree_store_update(model, &info->node, COL_OWNER, info->owner.c_str());
+}
+
+
+
+static void
+insert_info_to_tree (ProcInfo *info, ProcData *procdata, bool forced = false)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    if (procdata->config.show_tree) {
+
+        ProcInfo *parent = 0;
+
+        if (not forced)
+            parent = ProcInfo::find(info->ppid);
+
+        if (parent) {
+            GtkTreePath *parent_node = gtk_tree_model_get_path(model, &parent->node);
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, &parent->node, 0);
+
+            if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(procdata->tree), parent_node)
+#ifdef __linux__
+                // on linuxes we don't want to expand kthreadd by default (always has pid 2)
+                && (parent->pid != 2)
+#endif
+            )
+                gtk_tree_view_expand_row(GTK_TREE_VIEW(procdata->tree), parent_node, FALSE);
+            gtk_tree_path_free(parent_node);
+        } else
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, NULL, 0);
+    }
+    else
+        gtk_tree_store_insert (GTK_TREE_STORE (model), &info->node, NULL, 0);
+
+    gtk_tree_store_set (GTK_TREE_STORE (model), &info->node,
+                        COL_POINTER, info,
+                        COL_NAME, info->name,
+                        COL_ARGS, info->arguments,
+                        COL_TOOLTIP, info->tooltip,
+                        COL_PID, info->pid,
+                        COL_SECURITYCONTEXT, info->security_context,
+                        -1);
+
+    procdata->pretty_table.set_icon(*info);
+
+    procman_debug("inserted %d%s", info->pid, (forced ? " (forced)" : ""));
+}
+
+
+/* Removing a node with children - make sure the children are queued
+** to be readded.
+*/
+template<typename List>
+static void
+remove_info_from_tree (ProcData *procdata, GtkTreeModel *model,
+                       ProcInfo *current, List &orphans, unsigned lvl = 0)
+{
+    GtkTreeIter child_node;
+
+    if (std::find(orphans.begin(), orphans.end(), current) != orphans.end()) {
+        procman_debug("[%u] %d already removed from tree", lvl, int(current->pid));
+        return;
+    }
+
+    procman_debug("[%u] pid %d, %d children", lvl, int(current->pid),
+                  gtk_tree_model_iter_n_children(model, &current->node));
+
+    // it is not possible to iterate&erase over a treeview so instead we
+    // just pop one child after another and recursively remove it and
+    // its children
+
+    while (gtk_tree_model_iter_children(model, &child_node, &current->node)) {
+        ProcInfo *child = 0;
+        gtk_tree_model_get(model, &child_node, COL_POINTER, &child, -1);
+        remove_info_from_tree(procdata, model, child, orphans, lvl + 1);
+    }
+
+    g_assert(not gtk_tree_model_iter_has_child(model, &current->node));
+
+    if (procdata->selected_process == current)
+        procdata->selected_process = NULL;
+
+    orphans.push_back(current);
+    gtk_tree_store_remove(GTK_TREE_STORE(model), &current->node);
+    procman::poison(current->node, 0x69);
+}
+
+static void
+get_process_systemd_info(ProcInfo *info)
+{
+#ifdef HAVE_SYSTEMD
+    uid_t uid;
+
+    if (!LOGIND_RUNNING())
+        return;
+
+    free(info->unit);
+    info->unit = NULL;
+    sd_pid_get_unit(info->pid, &info->unit);
+
+    free(info->session);
+    info->session = NULL;
+    sd_pid_get_session(info->pid, &info->session);
+
+    free(info->seat);
+    info->seat = NULL;
+
+    if (info->session != NULL)
+        sd_session_get_seat(info->session, &info->seat);
+
+    if (sd_pid_get_owner_uid(info->pid, &uid) >= 0)
+        info->owner = info->lookup_user(uid);
+    else
+        info->owner = "";
+#endif
+}
+
+static void
+update_info (ProcData *procdata, ProcInfo *info)
+{
+    glibtop_proc_state procstate;
+    glibtop_proc_uid procuid;
+    glibtop_proc_time proctime;
+    glibtop_proc_kernel prockernel;
+    glibtop_proc_io procio;
+
+    glibtop_get_proc_kernel(&prockernel, info->pid);
+    g_strlcpy(info->wchan, prockernel.wchan, sizeof info->wchan);
+
+    glibtop_get_proc_state (&procstate, info->pid);
+    info->status = procstate.state;
+
+    glibtop_get_proc_uid (&procuid, info->pid);
+    glibtop_get_proc_time (&proctime, info->pid);
+    glibtop_get_proc_io (&procio, info->pid);
+
+    get_process_memory_info(info);
+
+    info->set_user(procstate.uid);
+
+    // if the cpu time has increased reset the status to running
+    // regardless of kernel state (https://bugzilla.gnome.org/606579)
+    guint64 difference = proctime.rtime - info->cpu_time;
+    if (difference > 0)
+        info->status = GLIBTOP_PROCESS_RUNNING;
+    info->pcpu = difference * 100 / procdata->cpu_total_time;
+    info->pcpu = MIN(info->pcpu, 100);
+
+    if (not procdata->config.solaris_mode)
+      info->pcpu *= procdata->config.num_cpus;
+
+    ProcInfo::cpu_times[info->pid] = info->cpu_time = proctime.rtime;
+    info->nice = procuid.nice;
+
+    gdouble update_interval_seconds = procdata->config.update_interval / 1000.0;
+    difference = procio.disk_wbytes - info->disk_write_bytes_total;
+    info->disk_write_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+    difference = procio.disk_rbytes - info->disk_read_bytes_total;
+    info->disk_read_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+
+    info->disk_write_bytes_total = procio.disk_wbytes;
+    info->disk_read_bytes_total = procio.disk_rbytes;
+
+    // set the ppid only if one can exist
+    // i.e. pid=0 can never have a parent
+    if (info->pid > 0) {
+        info->ppid = procuid.ppid;
+    }
+
+    g_assert(info->pid != info->ppid);
+    g_assert(info->ppid != -1 || info->pid == 0);
+
+    /* get cgroup data */
+    get_process_cgroup_info(info);
+
+    get_process_systemd_info(info);
+}
+
+
+ProcInfo::ProcInfo(pid_t pid)
+    : node(),
+      surface(),
+      tooltip(NULL),
+      name(NULL),
+      arguments(NULL),
+      security_context(NULL),
+      pid(pid),
+      ppid(-1),
+      uid(-1)
+{
+    ProcInfo * const info = this;
+    glibtop_proc_state procstate;
+    glibtop_proc_time proctime;
+    glibtop_proc_args procargs;
+    gchar** arguments;<--- Shadow variable
+
+    glibtop_get_proc_state (&procstate, pid);
+    glibtop_get_proc_time (&proctime, pid);
+    arguments = glibtop_get_proc_argv (&procargs, pid, 0);
+
+    /* FIXME : wrong. name and arguments may change with exec* */
+    get_process_name (info, procstate.cmd, static_cast<const GStrv>(arguments));
+
+    std::string tooltip = make_string(g_strjoinv(" ", arguments));<--- Shadow variable
+    if (tooltip.empty())
+        tooltip = procstate.cmd;
+
+    info->tooltip = g_markup_escape_text(tooltip.c_str(), -1);
+
+    info->arguments = g_strescape(tooltip.c_str(), "\\\"");
+    g_strfreev(arguments);
+
+    guint64 cpu_time = proctime.rtime;
+    std::map<pid_t, guint64>::iterator it(ProcInfo::cpu_times.find(pid));
+    if (it != ProcInfo::cpu_times.end())
+    {
+        if (proctime.rtime >= it->second)
+          cpu_time = it->second;
+    }
+    info->cpu_time = cpu_time;
+    info->start_time = proctime.start_time;
+
+    get_process_selinux_context (info);
+    info->cgroup_name = NULL;
+    get_process_cgroup_info(info);
+
+    info->unit = info->session = info->seat = NULL;
+    get_process_systemd_info(info);
+}
+
+static void
+refresh_list (ProcData *procdata, const pid_t* pid_list, const guint n)
+{
+    typedef std::list<ProcInfo*> ProcList;
+    ProcList addition;
+
+    GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+    guint i;
+
+    // Add or update processes in the process list
+    for(i = 0; i < n; ++i) {
+        ProcInfo *info = ProcInfo::find(pid_list[i]);
+
+        if (!info) {
+            info = new ProcInfo(pid_list[i]);
+            ProcInfo::all[info->pid] = info;
+            addition.push_back(info);
+        }
+
+        update_info (procdata, info);
+    }
+
+
+    // Remove dead processes from the process list and from the
+    // tree. children are queued to be readded at the right place
+    // in the tree.
+
+    const std::set<pid_t> pids(pid_list, pid_list + n);
+
+    ProcInfo::Iterator it(ProcInfo::begin());<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration
+
+    while (it != ProcInfo::end()) {
+        ProcInfo * const info = it->second;
+        ProcInfo::Iterator next(it);
+        ++next;
+
+        if (pids.find(info->pid) == pids.end()) {
+            procman_debug("ripping %d", info->pid);
+            remove_info_from_tree(procdata, model, info, addition);
+            addition.remove(info);
+            ProcInfo::all.erase(it);
+            delete info;
+        }
+
+        it = next;
+    }
+
+    // INVARIANT
+    // pid_list == ProcInfo::all + addition
+
+
+    if (procdata->config.show_tree) {
+
+        // insert process in the tree. walk through the addition list
+        // (new process + process that have a new parent). This loop
+        // handles the dependencies because we cannot insert a process
+        // until its parent is in the tree.
+
+        std::set<pid_t> in_tree(pids);
+
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            in_tree.erase((*it)->pid);
+
+
+        while (not addition.empty()) {
+            procman_debug("looking for %d parents", int(addition.size()));
+            ProcList::iterator it(addition.begin());<--- Shadow variable
+
+            while (it != addition.end()) {
+                procman_debug("looking for %d's parent with ppid %d",
+                              int((*it)->pid), int((*it)->ppid));
+
+
+                // inserts the process in the treeview if :
+                // - it has no parent (ppid = -1),
+                //   ie it is for example the [kernel] on FreeBSD
+                // - it is init
+                // - its parent is already in tree
+                // - its parent is unreachable
+                //
+                // rounds == 2 means that addition contains processes with
+                // unreachable parents
+                //
+                // FIXME: this is broken if the unreachable parent becomes active
+                // i.e. it gets active or changes ower
+                // so we just clear the tree on __each__ update
+                // see proctable_update_list (ProcData * const procdata)
+
+
+                if ((*it)->ppid <= 0 or in_tree.find((*it)->ppid) != in_tree.end()) {
+                    insert_info_to_tree(*it, procdata);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ProcInfo *parent = ProcInfo::find((*it)->ppid);
+                // if the parent is unreachable
+                if (not parent) {
+                    // or std::find(addition.begin(), addition.end(), parent) == addition.end()) {
+                    insert_info_to_tree(*it, procdata, true);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ++it;
+            }
+        }
+    }
+    else {
+        // don't care of the tree
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            insert_info_to_tree(*it, procdata);
+    }
+
+
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)<--- Shadow variable
+        update_info_mutable_cols(it->second);
+}
+
+
+static void
+proctable_update_list (ProcData * const procdata)
+{
+    pid_t* pid_list;
+    glibtop_proclist proclist;
+    glibtop_cpu cpu;
+    gint which, arg;
+    procman::SelectionMemento selection;
+
+    switch (procdata->config.whose_process) {
+        case ALL_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL;
+            arg = 0;
+            break;
+
+        case ACTIVE_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL | GLIBTOP_EXCLUDE_IDLE;
+            arg = 0;
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+
+        default:
+            which = GLIBTOP_KERN_PROC_UID;
+            arg = getuid ();
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+    }
+
+    pid_list = glibtop_get_proclist (&proclist, which, arg);
+
+    /* FIXME: total cpu time elapsed should be calculated on an individual basis here
+    ** should probably have a total_time_last gint in the ProcInfo structure */
+    glibtop_get_cpu (&cpu);
+    procdata->cpu_total_time = MAX(cpu.total - procdata->cpu_total_time_last, 1);
+    procdata->cpu_total_time_last = cpu.total;
+
+    // FIXME: not sure if glibtop always returns a sorted list of pid
+    // but it is important otherwise refresh_list won't find the parent
+    std::sort(pid_list, pid_list + proclist.number);
+
+    refresh_list (procdata, pid_list, proclist.number);
+
+    selection.restore(procdata->tree);
+
+    g_free (pid_list);
+
+    /* proclist.number == g_list_length(procdata->info) == g_hash_table_size(procdata->pids) */
+}
+
+
+void
+proctable_update (ProcData * const procdata)
+{
+    char* string;
+
+    string = make_loadavg_string();
+    gtk_label_set_text (GTK_LABEL(procdata->loadavg), string);
+    g_free (string);
+
+    proctable_update_list (procdata);
+}
+
+
+void
+proctable_free_table (ProcData * const procdata)
+{
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)
+        delete it->second;
+
+    ProcInfo::all.clear();
+}
+
+
+void
+proctable_clear_tree (ProcData * const procdata)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    gtk_tree_store_clear (GTK_TREE_STORE (model));
+
+    proctable_free_table (procdata);
+
+    update_sensitivity(procdata);
+}
+
+
+char*
+make_loadavg_string(void)
+{
+    glibtop_loadavg buf;
+
+    glibtop_get_loadavg(&buf);
+
+    return g_strdup_printf(
+        _("Load averages for the last 1, 5, 15 minutes: "
+          "%0.2f, %0.2f, %0.2f"),
+        buf.loadavg[0],
+        buf.loadavg[1],
+        buf.loadavg[2]);
+}
+
+
+
+void
+ProcInfo::set_icon(Glib::RefPtr<Gdk::Pixbuf> icon)
+{
+  this->surface = gdk_cairo_surface_create_from_pixbuf (icon->gobj(), 0, NULL);
+
+  GtkTreeModel *model;
+  model = gtk_tree_view_get_model(GTK_TREE_VIEW(ProcData::get_instance()->tree));
+  gtk_tree_store_set(GTK_TREE_STORE(model), &this->node,
+                     COL_SURFACE, this->surface,
+                    -1);
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/18.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/18.html new file mode 100644 index 00000000..4e691255 --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/18.html @@ -0,0 +1,405 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
#include <config.h>
+
+#include <glib.h>
+
+#include "selinux.h"
+#include "procman.h"
+#include "util.h"
+
+
+static int (*getpidcon)(pid_t, char**);
+static void (*freecon)(char*);
+static int (*is_selinux_enabled)(void);
+
+static gboolean has_selinux;
+
+static gboolean load_selinux(void)
+{
+    return load_symbols("libselinux.so.1",
+                        "getpidcon", &getpidcon,
+                        "freecon", &freecon,
+                        "is_selinux_enabled", &is_selinux_enabled,
+                        NULL);
+}
+
+
+
+void
+get_process_selinux_context (ProcInfo *info)
+{
+    char *con;
+
+    if (has_selinux && !getpidcon (info->pid, &con)) {
+        info->security_context = g_strdup (con);
+        freecon (con);
+    }
+}
+
+
+
+gboolean
+can_show_security_context_column (void)
+{
+    if (!(has_selinux = load_selinux()))
+        return FALSE;
+
+    switch (is_selinux_enabled()) {
+        case 1:
+            /* We're running on an SELinux kernel */
+            return TRUE;
+
+        case -1:
+            /* Error; hide the security context column */
+
+        case 0:
+            /* We're not running on an SELinux kernel:
+               hide the security context column */
+
+        default:
+            g_warning("SELinux was found but is not enabled.\n");
+            return FALSE;
+    }
+}
+
+
+
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/19.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/19.html new file mode 100644 index 00000000..913bbae3 --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/19.html @@ -0,0 +1,2359 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
#include <config.h>
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <glibmm.h>
+#include <glib/gi18n.h>
+
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+
+#include <glibtop/fsusage.h>
+#include <glibtop/mountlist.h>
+#include <glibtop/mem.h>
+#include <glibtop/sysinfo.h>
+
+#include <unistd.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#include <math.h>
+#include <errno.h>
+
+#include <exception>
+#include <string>
+#include <vector>
+#include <fstream>
+#include <sstream>
+#include <sys/utsname.h>
+
+#include "sysinfo.h"
+#include "procman.h"
+#include "util.h"
+
+
+using std::string;
+using std::vector;
+
+
+namespace {
+
+    class SysInfo
+    {
+    public:
+        string hostname;
+        string distro_name;
+        string distro_release;
+        string kernel;
+        string mate_version;
+        guint64 memory_bytes;
+        guint64 free_space_bytes;
+
+        string graphics;
+        string processors;
+
+        SysInfo()
+        {
+            this->load_processors_info();
+            this->load_graphics_info();
+            this->load_memory_info();
+            this->load_disk_info();
+            this->load_uname_info();
+            this->load_mate_version();
+        }
+
+        virtual ~SysInfo()
+        { }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Virtual function in base class
+        {
+            g_object_set(G_OBJECT(name),
+                        "label",
+                        ("<big><big><b>" + this->distro_name + "</b></big></big>").c_str(),
+                        NULL);
+
+            char* markup;
+#ifdef __linux__
+            if (this->distro_release != "")
+            {
+                /* Translators: The first string parameter is release version (codename),
+                 * the second one is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("Release %s %s"),
+                                         this->distro_release.c_str(),
+                                         SysInfo::get_os_type().c_str());
+            }
+            else
+            {
+                /* Translators: The string parameter is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("%s Version"),
+                                         SysInfo::get_os_type().c_str());
+            }
+#else
+            /* Translators: The string parameter is release version (codename) */
+            markup = g_strdup_printf(_("Release %s"),
+                                     this->distro_release.c_str());
+#endif
+
+            g_object_set(G_OBJECT(release),
+                         "label",
+                         markup,
+                         NULL);
+
+            g_free(markup);
+        }
+
+        static string release()
+        {
+            return uname().release;
+        }
+
+        static string system()
+        {
+            return uname().sysname;
+        }
+
+    private:
+
+        void load_memory_info()
+        {
+            glibtop_mem mem;
+
+            glibtop_get_mem(&mem);
+            this->memory_bytes = mem.total;
+        }
+
+        static string get_os_type ()<--- Unused private function: 'SysInfo::get_os_type'
+        {
+            int bits;
+
+            if (GLIB_SIZEOF_VOID_P == 8)
+                bits = 64;
+            else
+                bits = 32;
+
+            /* translators: This is the type of architecture, for example:
+             * "64-bit" or "32-bit" */
+            char* bytes = g_strdup_printf (_("%d-bit"), bits);
+            string retval(bytes);
+            g_free(bytes);
+            return retval;
+        }
+
+        typedef struct
+        {
+            const char* regex;
+            const char* replacement;
+        } ReplaceStrings;
+
+        static char* remove_duplicate_whitespace (const char* old)
+        {
+            char* result;
+            GRegex* re;
+            GError* error = NULL;
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+
+            re = g_regex_new ("[ \t\n\r]+", G_REGEX_MULTILINE, flags, &error);
+            if (re == NULL) {
+                g_warning ("Error building regex: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+            result = g_regex_replace (re, old, -1, 0, " ", flags, &error);
+            g_regex_unref (re);
+            if (result == NULL) {
+                g_warning ("Error replacing string: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+
+            return result;
+        }
+
+        static char* prettify_info (const char *info)
+        {
+            char* pretty;
+            const GRegexCompileFlags cflags = static_cast<GRegexCompileFlags>(0);
+            const GRegexMatchFlags mflags = static_cast<GRegexMatchFlags>(0);
+
+            static const ReplaceStrings rs[] = {
+                { "Intel[(]R[)]", "Intel\302\256"},
+                { "Core[(]TM[)]", "Core\342\204\242"},
+                { "Atom[(]TM[)]", "Atom\342\204\242"},
+            };
+
+            pretty = g_markup_escape_text (info, -1);
+
+            for (uint i = 0; i < G_N_ELEMENTS (rs); i++) {
+                GError* error;
+                GRegex* re;
+                char* result;
+
+                error = NULL;
+
+                re = g_regex_new (rs[i].regex, cflags, mflags, &error);
+                if (re == NULL) {
+                    g_warning ("Error building regex: %s", error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                result = g_regex_replace_literal (re, pretty, -1, 0,
+                                             rs[i].replacement, mflags, &error);
+
+                g_regex_unref (re);
+
+                if (error != NULL) {
+                    g_warning ("Error replacing %s: %s", rs[i].regex, error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                g_free (pretty);
+                pretty = result;
+            }
+
+            return pretty;
+        }
+
+        static char* get_renderer_from_helper (gboolean discrete_gpu)
+        {
+            int status;
+            const char *argv[] = { LIBEXECDIR "/mate-session-check-accelerated", NULL };
+            g_auto(GStrv) envp = NULL;
+            g_autofree char *renderer = NULL;
+            g_autoptr(GError) error = NULL;
+
+            if (discrete_gpu)
+            {
+                envp = g_get_environ ();
+                envp = g_environ_setenv (envp, "DRI_PRIME", "1", TRUE);
+            }
+
+            if (!g_spawn_sync (NULL, (char **) argv, envp, G_SPAWN_DEFAULT, NULL, NULL, &renderer, NULL, &status, &error))
+            {
+                g_debug ("Failed to get %s GPU: %s",
+                         discrete_gpu ? "discrete" : "integrated",
+                         error->message);
+                return NULL;
+            }
+
+            if (!g_spawn_check_exit_status (status, NULL))
+                return NULL;
+
+            if (renderer == NULL || *renderer == '\0')
+                return NULL;
+
+            return prettify_info (renderer);
+        }
+
+
+        void load_graphics_info()
+        {
+            g_autofree char *renderer = NULL;
+
+            try
+            {
+                g_autoptr(GDBusProxy) session_proxy = NULL;
+                g_autoptr(GVariant) renderer_variant = NULL;
+                g_autoptr(GError) error = NULL;
+
+                session_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                               G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL,
+                                                               "org.gnome.SessionManager",
+                                                               "/org/gnome/SessionManager",
+                                                               "org.gnome.SessionManager",
+                                                               NULL, &error);
+                if (error != NULL)
+                {
+                    throw std::runtime_error ("Unable to connect to create a proxy for org.gnome.SessionManager");
+                }
+
+                renderer_variant = g_dbus_proxy_get_cached_property (session_proxy, "Renderer");
+                if (!renderer_variant)
+                {
+                    throw std::runtime_error ("Unable to retrieve org.gnome.SessionManager.Renderer property.");
+                }
+
+                renderer = prettify_info (g_variant_get_string (renderer_variant, NULL));
+            }
+            catch (std::exception& e)
+            {
+                g_warning ("%s", e.what());
+            }
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (FALSE);
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (TRUE);
+
+            if (renderer)
+            {
+                this->graphics = g_strdup (renderer);
+            }
+            else
+            {
+                this->graphics = _("Unknown");
+            }
+        }
+
+        void load_processors_info()
+        {
+            const glibtop_sysinfo *info = glibtop_get_sysinfo();
+
+            GHashTable* counts;
+            GString* cpu;
+            GHashTableIter iter;
+            gpointer key, value;
+
+            counts = g_hash_table_new (g_str_hash, g_str_equal);
+
+            /* count duplicates */
+            for (uint i = 0; i != info->ncpu; ++i) {
+                const char* const keys[] = { "model name", "cpu", "Processor" };
+                char* model;
+                int* count;
+
+                model = NULL;
+
+                for (int j = 0; model == NULL && j != G_N_ELEMENTS (keys); ++j) {
+                    model = static_cast<char*>(g_hash_table_lookup (info->cpuinfo[i].values,
+                                                 keys[j]));
+                }
+
+                if (model == NULL)
+                    continue;
+
+                count = static_cast<int*>(g_hash_table_lookup (counts, model));
+                if (count == NULL)
+                    g_hash_table_insert (counts, model, GINT_TO_POINTER (1));
+                else
+                    g_hash_table_replace (counts, model, GINT_TO_POINTER (GPOINTER_TO_INT (count) + 1));
+            }
+
+            cpu = g_string_new (NULL);
+            g_hash_table_iter_init (&iter, counts);
+            while (g_hash_table_iter_next (&iter, &key, &value)) {
+                char* stripped;
+                int   count;
+
+                count = GPOINTER_TO_INT (value);
+                stripped = remove_duplicate_whitespace ((const char *)key);
+                if (count > 1)
+                    g_string_append_printf (cpu, "%s \303\227 %d ", stripped, count);
+                else
+                    g_string_append_printf (cpu, "%s ", stripped);
+                g_free (stripped);
+            }
+
+            g_hash_table_destroy (counts);
+            this->processors = string(prettify_info (cpu->str));
+            g_string_free (cpu, TRUE);
+        }
+
+        void load_disk_info()
+        {
+            GHashTable *devices;
+            glibtop_mountentry *entries;
+            glibtop_mountlist mountlist;
+
+            entries = glibtop_get_mountlist(&mountlist, 0);
+            devices = g_hash_table_new(g_str_hash, g_str_equal);
+            this->free_space_bytes = 0;
+
+            for (guint i = 0; i != mountlist.number; ++i) {
+                if ((string(entries[i].mountdir).compare("/") == 0) && \
+                    (string(entries[i].type).compare("zfs") == 0)) {
+                    // Root filesystem is ZFS based: Calculate usage based on "/".
+                    glibtop_fsusage usage;
+                    glibtop_get_fsusage(&usage, "/");
+                    this->free_space_bytes = usage.bavail * usage.block_size;
+                    break;
+                }
+
+                if (string(entries[i].devname).find("/dev/") != 0)
+                    continue;
+
+                if (string(entries[i].mountdir).find("/media/") == 0)
+                    continue;
+
+                /* avoid adding a device more than once such as for btrfs filesystem */
+                if (g_hash_table_contains (devices, entries[i].devname))
+                    continue;
+                else
+                    g_hash_table_insert (devices, entries[i].devname, entries[i].mountdir);
+
+                glibtop_fsusage usage;
+                glibtop_get_fsusage(&usage, entries[i].mountdir);
+                this->free_space_bytes += usage.bavail * usage.block_size;
+            }
+
+            g_hash_table_destroy (devices);
+            g_free(entries);
+        }
+
+        static const struct utsname & uname()
+        {
+            static struct utsname name;
+
+            if (!name.sysname[0]) {
+                ::uname(&name);
+            }
+
+            return name;
+        }
+
+        void load_uname_info()
+        {
+            this->hostname = uname().nodename;
+#if defined(__linux__)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().machine;
+#elif defined(__sun) && defined(__SVR4)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().version + ' ' + uname().machine;
+#else
+            this->kernel = string(uname().version) + ' ' + uname().machine;
+#endif
+        }
+
+
+        void load_mate_version()
+        {
+            xmlDocPtr document;
+            xmlXPathContextPtr context;
+            const string nodes[3] = { "string(/mate-version/platform)",
+                                      "string(/mate-version/minor)",
+                                      "string(/mate-version/micro)" };
+            string values[3];
+
+            if (not (document = xmlParseFile(DATADIR "/mate-about/mate-version.xml")))
+                return;
+
+            if (not (context = xmlXPathNewContext(document)))
+                return;
+
+            for (size_t i = 0; i != 3; ++i)
+            {
+                xmlXPathObjectPtr xpath;
+                xpath = xmlXPathEvalExpression(BAD_CAST nodes[i].c_str(), context);
+
+                if (xpath and xpath->type == XPATH_STRING)
+                    values[i] = reinterpret_cast<const char*>(xpath->stringval);
+
+                xmlXPathFreeObject(xpath);
+            }
+
+            xmlXPathFreeContext(context);
+            xmlFreeDoc(document);
+
+            if (!values[0].empty() && !values[1].empty() && !values[2].empty())
+                this->mate_version = values[0] + '.' + values[1] + '.' + values[2];
+        }
+    };
+
+    class FreeBSDSysInfo
+        : public SysInfo
+    {
+    public:
+	FreeBSDSysInfo()
+        {
+            this->load_freebsd_info();
+        }
+
+    private:
+        void load_freebsd_info()
+        {
+            this->distro_name = "FreeBSD";
+            this->distro_release = release();
+        }
+    };
+
+    class SolarisSysInfo
+        : public SysInfo
+    {
+    public:
+        SolarisSysInfo()
+        {
+            this->load_solaris_info();
+        }
+
+    private:
+        void load_solaris_info()
+        {
+            std::ifstream input("/etc/release");
+
+            if (input) {
+                std::string s;
+                std::getline(input, s);
+                std::size_t found = s.find("OpenIndiana ");
+                if (found!=std::string::npos) {
+                    this->distro_name = "OpenIndiana";
+                    this->distro_release = s.substr(found + strlen("OpenIndiana "));
+                } else if (!s.empty()) {
+                    this->distro_release = s;
+                }
+            }
+
+            if (this->distro_release.empty()) {
+                this->distro_name = "Solaris";
+            }
+        }
+    };
+
+
+    class LSBSysInfo
+        : public SysInfo
+    {
+    public:
+        LSBSysInfo()<--- Member variable 'LSBSysInfo::lsb_fd' is not initialized in the constructor.<--- Member variable 'LSBSysInfo::name' is not initialized in the constructor.<--- Member variable 'LSBSysInfo::release' is not initialized in the constructor.
+            : re(Glib::Regex::create("^.+?:\\s*(.+)\\s*$"))
+        {
+            // start();
+        }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Function in derived class
+        {
+            this->name = name;
+            this->release = release;
+
+            this->start();
+        }
+
+
+    private:
+
+        sigc::connection child_watch;
+        int lsb_fd;
+        GtkWidget* name;
+        GtkWidget* release;<--- Shadowed declaration<--- Shadowed declaration
+
+        void strip_description(string &s) const
+        {
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+            GMatchInfo* info = 0;
+
+           if (g_regex_match(this->re->gobj(), s.c_str(), flags, &info)) {
+               s = make_string(g_match_info_fetch(info, 1));
+               g_match_info_free(info);
+           }
+        }
+
+        std::istream& get_value(std::istream &is, string &s) const
+        {
+            if (std::getline(is, s))
+                this->strip_description(s);
+            return is;
+        }
+
+
+        void read_lsb(Glib::Pid pid, int status)
+        {
+            this->child_watch.disconnect();
+
+            if (!WIFEXITED(status) or WEXITSTATUS(status) != 0) {
+                g_error("Child %d failed with status %d", int(pid), status);
+                return;
+            }
+
+            Glib::RefPtr<Glib::IOChannel> channel = Glib::IOChannel::create_from_fd(this->lsb_fd);
+            Glib::ustring content;
+
+            while (channel->read_to_end(content) == Glib::IO_STATUS_AGAIN)
+                ;
+
+            channel->close();
+            Glib::spawn_close_pid(pid);
+
+            procman_debug("lsb_release output = '%s'", content.c_str());
+
+            string release, codename;<--- Shadow variable
+            std::istringstream input(content);
+
+            this->get_value(input, this->distro_name)
+                and this->get_value(input, release)
+                and this->get_value(input, codename);
+
+            this->distro_release = release;
+            if (codename != "" && codename != "n/a")
+                this->distro_release += " (" + codename + ')';
+
+            this->SysInfo::set_distro_labels(this->name, this->release);
+        }
+
+
+        void start()
+        {
+            std::vector<string> argv(2);
+            argv[0] = "lsb_release";
+            argv[1] = "-irc";
+
+            Glib::SpawnFlags flags = Glib::SPAWN_DO_NOT_REAP_CHILD
+                | Glib::SPAWN_SEARCH_PATH
+                | Glib::SPAWN_STDERR_TO_DEV_NULL;
+
+            Glib::Pid child;
+
+            try {
+                Glib::spawn_async_with_pipes("/", // wd
+                                             argv,
+                                             flags,
+                                             sigc::slot<void>(), // child setup
+                                             &child,
+                                             0, // stdin
+                                             &this->lsb_fd); // stdout
+            } catch (Glib::SpawnError &e) {
+                g_error("g_spawn_async_with_pipes error: %s", e.what().c_str());
+                return;
+            }
+
+            sigc::slot<void,GPid, int> slot = sigc::mem_fun(this, &LSBSysInfo::read_lsb);
+            this->child_watch = Glib::signal_child_watch().connect(slot, child);
+        }
+
+
+        void sync_lsb_release()<--- Unused private function: 'LSBSysInfo::sync_lsb_release'
+        {
+            char *out= 0;
+            GError *error = 0;
+            int status;
+
+            if (g_spawn_command_line_sync("lsb_release -irc",
+                                          &out,
+                                          0,
+                                          &status,
+                                          &error)) {
+                string release, codename;<--- Shadow variable
+                if (!error and WIFEXITED(status) and WEXITSTATUS(status) == 0) {
+                    std::istringstream input(out);
+                    this->get_value(input, this->distro_name)
+                        and this->get_value(input, release)
+                        and this->get_value(input, codename);
+                    this->distro_release = release;
+                if (codename != "" && codename != "n/a")
+                    this->distro_release += " (" + codename + ')';
+                }
+            }
+
+            if (error)
+                g_error_free(error);
+
+            g_free(out);
+        }
+
+    private:
+        Glib::RefPtr<Glib::Regex> re;
+    };
+
+
+    class NetBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        NetBSDSysInfo()
+        {
+            this->load_netbsd_info();
+        }
+
+    private:
+        void load_netbsd_info()
+        {
+            this->distro_name = "NetBSD";
+
+            std::ifstream input("/etc/release");
+
+            if (input)
+                std::getline(input, this->distro_release);
+        }
+    };
+
+
+    class GenericSysInfo
+        : public SysInfo
+    {
+    public:
+        GenericSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            std::ifstream input("/etc/os-release");
+
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int start;
+                    std::getline(input, s);
+                    if (s.find("NAME=") == 0) {
+                        start = strlen("NAME=");
+                        if ((s.at(start) == '\"') && (s.at(s.size() - 1) == '\"')) {
+                            this->distro_name = s.substr(start + 1, s.size() - start - 2);
+                        } else {
+                            this->distro_name = s.substr(start);
+                        }
+                    } else if (s.find("VERSION=") == 0) {
+                        start = strlen("VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    } else if (s.find("# VERSION=") == 0) {
+                        start = strlen("# VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    }
+                }
+                input.close();
+                input.clear();
+            }
+            if (this->distro_release.empty()) {
+                input.open("/etc/debian_version");
+                if (input) {
+                    getline(input, this->distro_release);
+                }
+            }
+        }
+    };
+
+    class MintSysInfo
+        : public SysInfo
+    {
+    public:
+        MintSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            this->distro_name = "Linux Mint";
+            std::ifstream input("/etc/linuxmint/info");
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int len;
+                    std::getline(input, s);
+                    if (s.find("DESCRIPTION=") == 0) {
+                        len = strlen("DESCRIPTION=");
+                        // also strip the surrounding quotes
+                       this->distro_release = s.substr(len + 1, s.size() - len - 2);
+                   }
+                }
+            }
+        }
+    };
+
+    class OpenBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        OpenBSDSysInfo()
+        {
+            this->load_openbsd_info();
+        }
+
+    private:
+        void load_openbsd_info()
+        {
+            this->distro_name = "OpenBSD";
+            this->distro_release = this->kernel;
+
+            std::ifstream input("/etc/motd");
+
+            if (input)
+                std::getline(input, this->kernel);
+        }
+    };
+
+    SysInfo* get_sysinfo()
+    {
+        if (g_file_test ("/etc/linuxmint/info", G_FILE_TEST_EXISTS)) {
+            return new MintSysInfo;
+        }
+        else if (g_file_test ("/etc/os-release", G_FILE_TEST_EXISTS)) {
+            return new GenericSysInfo;
+        }
+        else if (char *p = g_find_program_in_path("lsb_release")) {
+            g_free(p);
+            return new LSBSysInfo;
+        }
+        else if (SysInfo::system() == "FreeBSD") {
+            return new FreeBSDSysInfo;
+        }
+        else if (SysInfo::system() == "SunOS") {
+            return new SolarisSysInfo;
+        }
+        else if (SysInfo::system() == "NetBSD") {
+            return new NetBSDSysInfo;
+        }
+        else if (SysInfo::system() == "OpenBSD") {
+            return new OpenBSDSysInfo;
+        }
+
+        return new SysInfo;
+    }
+}
+
+
+#define X_PAD  0
+#define Y_PAD  0
+#define LOGO_W 92
+#define LOGO_H 351
+#define RADIUS 5
+
+static gboolean sysinfo_logo_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    GtkStyle *style;
+    cairo_t *cr;
+    cairo_pattern_t *cp;
+
+    cr = gdk_cairo_create(gtk_widget_get_window(widget));
+
+    gtk_widget_get_allocation (widget, &allocation);
+    cairo_translate(cr, allocation.x, allocation.y);
+
+    cairo_move_to(cr, X_PAD + RADIUS, Y_PAD);
+    cairo_line_to(cr, X_PAD + LOGO_W - RADIUS, Y_PAD);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + RADIUS, RADIUS, -0.5 * M_PI, 0);
+    cairo_line_to(cr, X_PAD + LOGO_W, Y_PAD + LOGO_H - RADIUS);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0, 0.5 * M_PI);
+    cairo_line_to(cr, X_PAD + RADIUS, Y_PAD + LOGO_H);
+    cairo_arc(cr, X_PAD + RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0.5 * M_PI, -1.0 * M_PI);
+    cairo_line_to(cr, X_PAD, Y_PAD + RADIUS);
+    cairo_arc(cr,  X_PAD + RADIUS, Y_PAD + RADIUS, RADIUS, -1.0 * M_PI, -0.5 * M_PI);
+
+    cp = cairo_pattern_create_linear(0, Y_PAD, 0, Y_PAD + LOGO_H);
+    style = gtk_widget_get_style (widget);
+    cairo_pattern_add_color_stop_rgba(cp, 0.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      1.0);
+    cairo_pattern_add_color_stop_rgba(cp, 1.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      0.0);
+    cairo_set_source(cr, cp);
+    cairo_fill(cr);
+
+    cairo_pattern_destroy(cp);
+    cairo_destroy(cr);
+
+    return FALSE;
+}
+
+static GtkWidget*
+add_section(GtkBox *vbox , const char * title, int num_row, int num_col, GtkWidget **out_frame)
+{
+    GtkWidget *table;
+
+    GtkWidget *frame = gtk_frame_new(title);
+    gtk_frame_set_label_align(GTK_FRAME(frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
+
+    table = gtk_grid_new();
+    gtk_grid_set_row_spacing(GTK_GRID(table), 6);
+    gtk_grid_set_column_spacing(GTK_GRID(table), 6);
+    gtk_widget_set_margin_start (GTK_WIDGET(table), 12);
+    gtk_container_set_border_width(GTK_CONTAINER(table), 6);
+    gtk_container_add(GTK_CONTAINER(frame), table);
+
+    if(out_frame)
+        *out_frame = frame;
+
+    return table;
+}
+
+
+static GtkWidget*
+add_row(GtkGrid * table, const char * label, const char * value, int row)
+{
+    GtkWidget *header = gtk_label_new(NULL);
+    gtk_label_set_markup(GTK_LABEL(header), label);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        table, header,
+        0, row, 1, 1);
+
+    GtkWidget *label_widget = gtk_label_new(value);
+    gtk_label_set_selectable(GTK_LABEL(label_widget), TRUE);
+    gtk_widget_set_can_focus(label_widget, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (label_widget), 0.0);
+    gtk_grid_attach(
+        table, label_widget,
+        1, row, 1, 1);
+
+    return label_widget;
+}
+
+
+static GtkWidget *
+procman_create_sysinfo_view(void)
+{
+    GtkWidget *hbox;
+    GtkWidget *vbox;
+
+    SysInfo *data = get_sysinfo();;
+
+    GtkWidget * logo;
+
+    GtkWidget *distro_frame;
+    GtkWidget *distro_release_label;
+    GtkWidget *distro_table;
+
+    GtkWidget *hardware_table;
+    GtkWidget *disk_space_table;
+
+    GtkWidget *header;
+
+    gchar *markup;
+
+    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);
+
+    /* left-side logo */
+    if (g_file_test (DATADIR "/pixmaps/mate-system-monitor/distribution/side.png", G_FILE_TEST_EXISTS)) {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/distribution/side.png");
+    }
+    else {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/side.png");
+    }
+    gtk_widget_set_valign (logo, GTK_ALIGN_START);
+    gtk_widget_set_margin_start (logo, 5);
+    gtk_widget_set_margin_end (logo, 5);
+    gtk_widget_set_margin_top (logo, 12);
+    gtk_widget_set_margin_bottom (logo, 12);
+    gtk_box_pack_start(GTK_BOX(hbox), logo, FALSE, FALSE, 0);
+
+    g_signal_connect(G_OBJECT(logo), "draw", G_CALLBACK(sysinfo_logo_draw), NULL);
+
+    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
+    gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
+
+    // hostname
+
+    markup = g_strdup_printf("<big><big><b><u>%s</u></b></big></big>",
+                             data->hostname.c_str());
+    GtkWidget *hostname_frame = gtk_frame_new(markup);
+    g_free(markup);
+    gtk_frame_set_label_align(GTK_FRAME(hostname_frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(hostname_frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(hostname_frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), hostname_frame, FALSE, FALSE, 0);
+
+
+    /* distro section */
+
+    unsigned table_size = 2;
+    if (data->mate_version != "")
+        table_size++;
+    distro_table = add_section(GTK_BOX(vbox), "???", table_size, 1, &distro_frame);
+
+    unsigned table_count = 0;
+
+    distro_release_label = gtk_label_new("???");
+    gtk_label_set_selectable(GTK_LABEL(distro_release_label), TRUE);
+    gtk_widget_set_can_focus(distro_release_label, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (distro_release_label), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), distro_release_label,
+        0, table_count, 1, 1);
+    table_count++;
+    data->set_distro_labels(gtk_frame_get_label_widget(GTK_FRAME(distro_frame)), distro_release_label);
+
+    markup = g_strdup_printf(_("Kernel %s"), data->kernel.c_str());
+    header = gtk_label_new(markup);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    g_free(markup);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), header,
+        0, table_count, 1, 1);
+    table_count++;
+
+    if (data->mate_version != "")
+    {
+        markup = g_strdup_printf(_("MATE %s"), data->mate_version.c_str());
+        header = gtk_label_new(markup);
+        gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+        gtk_widget_set_can_focus(header, FALSE);
+        g_free(markup);
+        gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+        gtk_grid_attach(
+            GTK_GRID(distro_table), header,
+            0, table_count, 1, 1);
+        table_count++;<--- Variable 'table_count' is assigned a value that is never used.
+    }
+
+    /* hardware section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("Hardware"));
+    hardware_table = add_section(GTK_BOX(vbox), markup, 1, 3, NULL);
+    g_free(markup);
+
+    markup = g_format_size_full(data->memory_bytes, G_FORMAT_SIZE_IEC_UNITS);
+    add_row(GTK_GRID(hardware_table), _("Memory:"), markup, 0);
+    g_free(markup);
+
+    add_row(GTK_GRID(hardware_table), _("Processor:"),
+            data->processors.c_str(), 1);
+    add_row(GTK_GRID(hardware_table), _("Graphics:"),
+            data->graphics.c_str(), 2);
+
+    /* disk space section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("System Status"));
+    disk_space_table = add_section(GTK_BOX(vbox), markup, 1, 2, NULL);
+    g_free(markup);
+
+    markup = g_format_size(data->free_space_bytes);
+    add_row(GTK_GRID(disk_space_table), _("Available disk space:"), markup, 0);
+    g_free(markup);
+
+    return hbox;
+}
+
+
+
+namespace procman
+{
+    void build_sysinfo_ui()
+    {
+        static GtkWidget* ui;
+
+        if (!ui) {
+            ProcData* procdata = ProcData::get_instance();
+            ui = procman_create_sysinfo_view();
+            GtkBox* box = GTK_BOX(gtk_notebook_get_nth_page(GTK_NOTEBOOK(procdata->notebook),
+                                                            PROCMAN_TAB_SYSINFO));
+            gtk_box_pack_start(box, ui, TRUE, TRUE, 0);
+            gtk_widget_show_all(ui);
+        }
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/2.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/2.html new file mode 100644 index 00000000..0154b48f --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/2.html @@ -0,0 +1,489 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
#ifndef _PROCMAN_LOAD_GRAPH_H_
+#define _PROCMAN_LOAD_GRAPH_H_
+
+#include <glib.h>
+#include <glibtop/cpu.h>
+
+enum
+{
+    LOAD_GRAPH_CPU,
+    LOAD_GRAPH_MEM,
+    LOAD_GRAPH_NET
+};
+
+enum {
+    CPU_TOTAL,
+    CPU_USED,
+    N_CPU_STATES
+};
+
+struct LoadGraphLabels
+{
+    GtkWidget *cpu[GLIBTOP_NCPU];
+    GtkWidget *memory;
+    GtkWidget *swap;
+    GtkWidget *net_in;
+    GtkWidget *net_in_total;
+    GtkWidget *net_out;
+    GtkWidget *net_out_total;
+};
+
+struct LoadGraph {
+
+    static const unsigned NUM_POINTS = 60 + 2;
+    static const unsigned GRAPH_MIN_HEIGHT = 40;
+
+    LoadGraph(guint type);
+    ~LoadGraph();
+
+    unsigned num_bars() const;
+    void clear_background();
+
+    double fontsize;
+    double rmargin;
+    double indent;
+
+    guint n;
+    gint type;
+    guint speed;
+    guint draw_width, draw_height;
+    guint render_counter;
+    guint frames_per_unit;
+    guint graph_dely;
+    guint real_draw_height;
+    double graph_delx;
+    guint graph_buffer_offset;
+
+    std::vector<GdkRGBA> colors;
+
+    std::vector<float> data_block;
+    gfloat* data[NUM_POINTS];
+
+    GtkWidget *main_widget;
+    GtkWidget *disp;
+
+    cairo_pattern_t *background;
+
+    guint timer_index;
+
+    gboolean draw;
+
+    LoadGraphLabels labels;
+    GtkWidget *mem_color_picker;
+    GtkWidget *swap_color_picker;
+
+    /* union { */
+        struct {
+            guint now; /* 0 -> current, 1 -> last
+                    now ^ 1 each time */
+            /* times[now], times[now ^ 1] is last */
+            guint64 times[2][GLIBTOP_NCPU][N_CPU_STATES];
+        } cpu;
+
+        struct {
+            guint64 last_in, last_out;
+#if GLIB_CHECK_VERSION(2,61,2)
+            gint64 time;
+#else
+            GTimeVal time;
+#endif
+            guint64 max;
+            unsigned values[NUM_POINTS];
+            size_t cur;
+        } net;
+    /* }; */
+};
+
+/* Force a drawing update */
+void
+load_graph_queue_draw (LoadGraph *g);
+
+/* Start load graph. */
+void
+load_graph_start (LoadGraph *g);
+
+/* Stop load graph. */
+void
+load_graph_stop (LoadGraph *g);
+
+/* Change load graph speed and restart it if it has been previously started */
+void
+load_graph_change_speed (LoadGraph *g,
+                         guint new_speed);
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+#endif /* _PROCMAN_LOAD_GRAPH_H_ */
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/3.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/3.html new file mode 100644 index 00000000..e0d59e5d --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/3.html @@ -0,0 +1,645 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
#include <config.h>
+
+#include <cstring>
+#include <glib/gi18n.h>
+
+#include "cgroups.h"
+#include "util.h"
+
+gboolean
+cgroups_enabled(void)
+{
+    static gboolean initialized = FALSE;
+    static gboolean has_cgroups;
+
+    if (!initialized) {
+        initialized = TRUE;
+        has_cgroups = g_file_test("/proc/cgroups", G_FILE_TEST_EXISTS);
+    }
+
+    return has_cgroups;
+}
+
+static void
+append_cgroup_name(char *line, gchar **current_cgroup_name)
+{
+    gchar *controller, *path, *tmp, *path_plus_space;
+    int paren_offset, off, tmp_size;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return;
+
+    *(path - 1) = '\0';
+    g_strdelimit(controller, ",", '/');
+
+    if ((std::strcmp(path, "/") == 0) || (std::strncmp(controller, "name=", 5) == 0))
+        return;
+
+    if (*current_cgroup_name == NULL) {
+        *current_cgroup_name = g_strdup_printf("%s (%s)", path, controller);
+        return;
+    }
+
+    /* add a space to the end of the path string */
+    path_plus_space = g_strdup_printf("%s ", path);
+
+    if ((tmp = g_strstr_len(*current_cgroup_name, -1, path_plus_space))) {
+        tmp_size = strlen(*current_cgroup_name) + strlen(controller) + 1;
+        paren_offset = g_strstr_len(tmp + strlen(path), -1, ")") - *current_cgroup_name;
+        *(*current_cgroup_name + paren_offset) = '\0';
+        tmp = (gchar *)g_strnfill(tmp_size, '\0');
+        off = g_strlcat(tmp, *current_cgroup_name, tmp_size);
+        *(tmp + off) = '/';
+        off++;
+        off += g_strlcat(tmp + off, controller, tmp_size);
+        *(tmp + off) = ')';
+        off++;
+        g_strlcat(tmp + off, *current_cgroup_name + paren_offset + 1, tmp_size);
+    } else
+        tmp = g_strdup_printf("%s, %s(%s)", *current_cgroup_name, path_plus_space, controller);
+
+    g_free(path_plus_space);
+    g_free(*current_cgroup_name);
+    *current_cgroup_name = tmp;
+}
+
+static int
+check_cgroup_changed(gchar *line, gchar *current_cgroup_set)
+{
+    /* check if line is contained in current_cgroup_set */
+    gchar *controller, *path, *tmp, *found, *close_paren, *open_paren;
+    int ret = 0;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return 1;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return 1;
+
+    *(path - 1) = '\0';
+
+    if (std::strncmp(controller, "name=", 5) == 0)
+        goto out;
+
+    /* if there are multiple controllers just report string has changed */
+    if (g_strstr_len(controller, -1, ",")) {
+        ret = 1;
+        goto out;
+    }
+
+    if (!current_cgroup_set) {
+        if (std::strcmp(path, "/") != 0)
+            ret = 1;
+        goto out;
+    }
+
+    /* special case for root cgroup */
+    tmp = current_cgroup_set;
+    if (std::strcmp(path, "/") == 0) {
+        while ((found = g_strstr_len(tmp, -1, controller))) {
+            close_paren = g_strstr_len(found, -1, ")");
+            open_paren = g_strstr_len(found, -1, "(");
+            if (close_paren) {
+                if (!open_paren || (close_paren < open_paren)) {
+                    ret = 1;
+                    goto out;
+                }
+            }
+            tmp = found + strlen(controller);
+        }
+        goto out;
+    }
+
+    tmp = current_cgroup_set;
+    while ((found = g_strstr_len(tmp, -1, path))) {
+            found = found + strlen(path);
+            close_paren = g_strstr_len(found, -1, ")");
+            if (*found == ' ') {
+                if (g_strstr_len(found + 1, close_paren - found, controller))
+                    goto out;
+            }
+            tmp = close_paren + 1;
+    }
+    ret = 1;
+out:
+    *(path - 1) = ':';
+    return ret;
+}
+
+void
+get_process_cgroup_info(ProcInfo *info)
+{
+    gchar *path;
+    gchar *cgroup_name = NULL;
+    int cgroups_changed = 0;
+    gchar *text;
+    char **lines;
+    int i;
+
+    if (!cgroups_enabled())
+        return;
+
+    /* read out of /proc/pid/cgroup */
+    path = g_strdup_printf("/proc/%d/cgroup", info->pid);
+    if (!path)
+        return;
+    if(!g_file_get_contents(path, &text, NULL, NULL))
+        goto out;
+    lines = g_strsplit(text, "\n", -1);
+    g_free(text);
+    if (!lines)
+        goto out;
+
+    for (i = 0; lines[i] != NULL; i++) {
+        if (lines[i][0] == '\0')
+            continue;
+        if (check_cgroup_changed(lines[i], info->cgroup_name)) {
+            cgroups_changed = 1;
+            break;
+        }
+    }
+
+    if (cgroups_changed) {
+        for (i = 0; lines[i] != NULL; i++) {
+            if (lines[i][0] == '\0')
+                continue;
+            append_cgroup_name(lines[i], &cgroup_name);
+        }
+        if (info->cgroup_name)
+            g_free(info->cgroup_name);
+        if (!cgroup_name)
+            info->cgroup_name = g_strdup("");
+        else
+            info->cgroup_name = cgroup_name;
+    }
+
+    g_strfreev(lines);
+out:
+    g_free(path);
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/4.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/4.html new file mode 100644 index 00000000..cc9dbf88 --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/4.html @@ -0,0 +1,1277 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
#include <config.h>
+
+#ifdef __linux__
+#include <mntent.h>
+#endif // __linux__
+
+#include <giomm.h>
+#include <giomm/themedicon.h>
+#include <gtk/gtk.h>
+#include <glibtop/mountlist.h>
+#include <glibtop/fsusage.h>
+#include <glib/gi18n.h>
+
+#include "procman.h"
+#include "disks.h"
+#include "util.h"
+#include "interface.h"
+#include "iconthemewrapper.h"
+
+namespace
+{
+  const unsigned DISK_ICON_SIZE = 24;
+}
+
+enum DiskColumns
+{
+    /* string columns* */
+    DISK_DEVICE,
+    DISK_DIR,
+    DISK_TYPE,
+    DISK_SUBVOLUME,
+    DISK_TOTAL,
+    DISK_FREE,
+    DISK_AVAIL,
+    /* USED has to be the last column */
+    DISK_USED,
+    // then unvisible columns
+    /* Surface column */
+    DISK_ICON,
+    /* numeric columns */
+    DISK_USED_PERCENTAGE,
+    DISK_N_COLUMNS
+};
+
+
+
+static void
+fsusage_stats(const glibtop_fsusage *buf,
+              guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
+              gint *percentage)
+{
+    guint64 total = buf->blocks * buf->block_size;
+
+    if (!total) {
+        /* not a real device */
+        *btotal = *bfree = *bavail = *bused = 0ULL;
+        *percentage = 0;
+    } else {
+        int percent;
+        *btotal = total;
+        *bfree = buf->bfree * buf->block_size;
+        *bavail = buf->bavail * buf->block_size;
+        *bused = *btotal - *bfree;
+        /* percent = 100.0f * *bused / *btotal; */
+        percent = 100 * *bused / (*bused + *bavail);
+        *percentage = CLAMP(percent, 0, 100);
+    }
+}
+
+
+namespace
+{
+    string get_icon_for_path(const std::string& path)
+    {
+        using namespace Glib;
+        using namespace Gio;
+
+        // FIXME: I don't know whether i should use Volume or Mount or UnixMount
+        // all i need an icon name.
+        RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+        std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
+
+        for (size_t i = 0; i != mounts.size(); ++i) {
+            if (mounts[i]->get_name() != path)
+                continue;
+
+            RefPtr<Icon> icon = mounts[i]->get_icon();
+            RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
+
+            if (themed_icon) {
+                char* name = 0;
+                // FIXME: not wrapped yet
+                g_object_get(G_OBJECT(themed_icon->gobj()), "name", &name, NULL);
+                return make_string(name);
+            }
+        }
+
+        return "";
+    }
+}
+
+
+static Glib::RefPtr<Gdk::Pixbuf>
+get_icon_for_device(const char *mountpoint)
+{
+    procman::IconThemeWrapper icon_theme;
+    string icon_name = get_icon_for_path(mountpoint);
+    if (icon_name == "")
+        // FIXME: defaults to a safe value
+        icon_name = "drive-harddisk"; // get_icon_for_path("/");
+    return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
+}
+
+
+static gboolean
+find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
+                   GtkTreeIter *result)
+{
+    GtkTreeIter iter;
+    gboolean found = FALSE;
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        do {
+            char *dir;
+
+            gtk_tree_model_get(model, &iter,
+                               DISK_DIR, &dir,
+                               -1);
+
+            if (dir && !strcmp(dir, mountpoint)) {
+                *result = iter;
+                found = TRUE;
+            }
+
+            g_free(dir);
+
+        } while (!found && gtk_tree_model_iter_next(model, &iter));
+    }
+
+    return found;
+}
+
+
+
+static void
+remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
+{
+    GtkTreeIter iter;
+
+    if (!gtk_tree_model_get_iter_first(model, &iter))
+        return;
+
+    while (true) {
+        char *dir;
+        guint i;
+        gboolean found = FALSE;
+
+        gtk_tree_model_get(model, &iter,
+                           DISK_DIR, &dir,
+                           -1);
+
+        for (i = 0; i != n; ++i) {
+            if (!strcmp(dir, entries[i].mountdir)) {
+                found = TRUE;
+                break;
+            }
+        }
+
+        g_free(dir);
+
+        if (!found) {
+            if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                break;
+            else
+                continue;
+        }
+
+        if (!gtk_tree_model_iter_next(model, &iter))
+            break;
+    }
+}
+
+#ifdef __linux__
+static char *
+get_mount_opt(const glibtop_mountentry *entry, const char* opt)
+{
+    char *opt_value = NULL;
+    const struct mntent *mnt;
+    FILE *fp;
+
+    if (!(fp = setmntent(MOUNTED, "r"))) {
+        goto out;
+    }
+
+    while ((mnt = getmntent(fp))) {
+        if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
+            (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
+            char *res;
+
+            res = hasmntopt(mnt, "subvol");<--- res is assigned
+            if ((res = hasmntopt(mnt, "subvol")) != NULL) {<--- res is overwritten
+                char **strs = g_strsplit_set(res, "=", 2);
+
+                if (g_strv_length(strs) == 2) {
+                    char *value = strs[1];
+                    if (g_strcmp0 (value,"/root") == 0)
+                       opt_value = g_strdup("/");
+                    else
+                        opt_value = g_strdup(strs[1]);
+                    g_strfreev(strs);
+                }
+            }
+            break;
+        }
+    }
+
+    endmntent(fp);
+
+  out:
+     return opt_value;
+}
+#endif // __linux__
+
+
+static void
+add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
+{
+    Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+    cairo_surface_t *surface;
+    GtkTreeIter iter;
+    glibtop_fsusage usage;
+    guint64 bused, bfree, bavail, btotal;
+    gint percentage;
+#ifdef __linux__
+    char *subvol = NULL;
+#endif // __linux__
+
+    glibtop_get_fsusage(&usage, entry->mountdir);
+
+    if (not show_all_fs and usage.blocks == 0) {
+        if (find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+            gtk_list_store_remove(list, &iter);
+        return;
+    }
+
+    fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
+#ifdef __linux__
+    subvol = get_mount_opt(entry, "subvol");
+#endif // __linux__
+    pixbuf = get_icon_for_device(entry->mountdir);
+    surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL);
+
+    /* if we can find a row with the same mountpoint, we get it but we
+       still need to update all the fields.
+       This makes selection persistent.
+    */
+    if (!find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+        gtk_list_store_append(list, &iter);
+
+    gtk_list_store_set(list, &iter,
+                       DISK_ICON, surface,
+                       DISK_DEVICE, entry->devname,
+                       DISK_DIR, entry->mountdir,
+                       DISK_TYPE, entry->type,
+#ifdef __linux__
+
+                       DISK_SUBVOLUME, subvol != NULL ? subvol : "",
+#else
+                       DISK_SUBVOLUME, "",
+#endif // __linux__
+                       DISK_USED_PERCENTAGE, percentage,
+                       DISK_TOTAL, btotal,
+                       DISK_FREE, bfree,
+                       DISK_AVAIL, bavail,
+                       DISK_USED, bused,
+                       -1);
+#ifdef __linux__
+    g_free (subvol);
+#endif // __linux__
+}
+
+
+
+int
+cb_update_disks(gpointer data)
+{
+    ProcData *const procdata = static_cast<ProcData*>(data);
+
+    GtkListStore *list;
+    glibtop_mountentry * entries;
+    glibtop_mountlist mountlist;
+    guint i;
+
+    list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)));
+
+    entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
+
+    remove_old_disks(GTK_TREE_MODEL(list), entries, mountlist.number);
+
+    for (i = 0; i < mountlist.number; i++)
+        add_disk(list, &entries[i], procdata->config.show_all_fs);
+
+    g_free(entries);
+
+    return TRUE;
+}
+
+
+static void
+cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "disktreenew");
+}
+
+
+static void
+open_dir(GtkTreeView       *tree_view,
+         GtkTreePath       *path,
+         GtkTreeViewColumn *column,
+         gpointer           user_data)
+{
+    GtkTreeIter iter;
+    GtkTreeModel *model;
+    char *dir, *url;
+
+    model = gtk_tree_view_get_model(tree_view);
+
+    if (!gtk_tree_model_get_iter(model, &iter, path)) {
+        char *p;
+        p = gtk_tree_path_to_string(path);
+        g_warning("Cannot get iter for path '%s'\n", p);
+        g_free(p);
+        return;
+    }
+
+    gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
+
+    url = g_strdup_printf("file://%s", dir);
+
+    GError* error = 0;
+    if (!g_app_info_launch_default_for_uri(url, NULL, &error)) {
+        g_warning("Cannot open '%s' : %s\n", url, error->message);
+        g_error_free(error);
+    }
+
+    g_free(url);
+    g_free(dir);
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "disktreenew");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+void
+create_disk_view(ProcData *procdata, GtkBuilder *builder)
+{
+    GtkWidget *scrolled;
+    GtkWidget *disk_tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *col;
+    GtkCellRenderer *cell;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Device"),
+        N_("Directory"),
+        N_("Type"),
+        N_("SubVolume"),
+        N_("Total"),
+        N_("Free"),
+        N_("Available"),
+        N_("Used")
+    };
+
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"));
+
+    model = gtk_list_store_new(DISK_N_COLUMNS,             /* n columns */
+                               G_TYPE_STRING,              /* DISK_DEVICE */
+                               G_TYPE_STRING,              /* DISK_DIR */
+                               G_TYPE_STRING,              /* DISK_TYPE */
+                               G_TYPE_STRING,              /* DISK_SUBVOLUME */
+                               G_TYPE_UINT64,              /* DISK_TOTAL */
+                               G_TYPE_UINT64,              /* DISK_FREE */
+                               G_TYPE_UINT64,              /* DISK_AVAIL */
+                               G_TYPE_UINT64,              /* DISK_USED */
+                               CAIRO_GOBJECT_TYPE_SURFACE, /* DISK_ICON */
+                               G_TYPE_INT);                /* DISK_USED_PERCENTAGE */
+
+    disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL);
+    procdata->disk_list = disk_tree;
+    gtk_container_add(GTK_CONTAINER(scrolled), disk_tree);
+    g_object_unref(G_OBJECT(model));
+
+    /* icon + device */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
+                                        NULL);
+
+    cell = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
+                                        NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 30);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* sizes - used */
+
+    for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_min_width (col, 30);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+        switch (i) {
+            case DISK_TOTAL:
+            case DISK_FREE:
+            case DISK_AVAIL:
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+        default:
+            gtk_tree_view_column_set_attributes(col, cell,
+                                                "text", i,
+                                                NULL);
+            break;
+        }
+    }
+
+    /* used + percentage */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_text_new();
+    g_object_set(cell, "xalign", 1.0f, NULL);
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_cell_data_func(col, cell,
+                                            &procman::storage_size_cell_data_func,
+                                            GUINT_TO_POINTER(DISK_USED),
+                                            NULL);
+
+    cell = gtk_cell_renderer_progress_new();
+    gtk_tree_view_column_pack_start(col, cell, TRUE);
+    gtk_tree_view_column_set_attributes(col, cell, "value",
+                                        DISK_USED_PERCENTAGE, NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_USED]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 150);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* numeric sort */
+
+    procman_get_tree_state(procdata->settings, disk_tree,
+                   "disktreenew");
+
+    g_signal_connect (G_OBJECT(disk_tree), "columns-changed",
+                      G_CALLBACK(cb_disk_columns_changed), procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/5.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/5.html new file mode 100644 index 00000000..17de817b --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/5.html @@ -0,0 +1,2141 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
+852
+853
+854
+855
+856
+857
+858
+859
+860
+861
+862
+863
+864
+865
+866
+867
+868
+869
+870
+871
+872
+873
+874
+875
+876
+877
+878
+879
+880
+881
+882
+883
+884
+885
+886
+887
+888
+889
+890
+891
+892
+893
+894
+895
+896
+897
+898
+899
+900
+901
+902
+903
+904
+905
+906
+907
+908
+909
+910
+911
+912
+913
+914
+915
+916
+917
+918
+919
+920
+921
+922
+923
+924
+925
+926
+927
+928
+929
+930
+931
+932
+933
+934
+935
+936
+937
+938
+939
+940
+941
+942
+943
+944
+945
+946
/*
+ * Mate system monitor color pickers
+ * Copyright (C) 2007 Karl Lattimer <karl@qdh.org.uk>
+ * Copyright (C) 2012-2021 MATE Developers
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with the software; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <gdk/gdkkeysyms.h>
+#include <math.h>
+#include <cairo.h>
+#include <librsvg/rsvg.h>
+
+#include "gsm_color_button.h"
+
+typedef struct {
+    GtkWidget *cc_dialog;		/* Color chooser dialog */
+
+    gchar *title;            /* Title for the color selection window */
+
+    GdkRGBA color;
+
+    gdouble fraction;        /* Only used by GSMCP_TYPE_PIE */
+    guint type;
+    cairo_surface_t *image_buffer;
+    gdouble highlight;
+    gboolean button_down;
+    gboolean in_button;
+} GSMColorButtonPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GSMColorButton, gsm_color_button, GTK_TYPE_DRAWING_AREA)
+
+/* Properties */
+enum
+{
+    PROP_0,
+    PROP_PERCENTAGE,
+    PROP_TITLE,
+    PROP_COLOR,
+    PROP_TYPE
+};
+
+/* Signals */
+enum
+{
+    COLOR_SET,
+    LAST_SIGNAL
+};
+
+#define GSMCP_MIN_WIDTH 15
+#define GSMCP_MIN_HEIGHT 15
+
+static void gsm_color_button_finalize (GObject * object);
+static void gsm_color_button_set_property (GObject * object, guint param_id,
+                                           const GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_get_property (GObject * object, guint param_id,
+                                           GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_realize (GtkWidget * widget);
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width);
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height);
+static void gsm_color_button_size_allocate (GtkWidget * widget,
+                                            GtkAllocation * allocation);
+static void gsm_color_button_unrealize (GtkWidget * widget);
+static void gsm_color_button_state_changed (GtkWidget * widget,
+                                            GtkStateType previous_state);
+static void gsm_color_button_style_set (GtkWidget * widget,
+                                        GtkStyle * previous_style);
+static gint gsm_color_button_pressed (GtkWidget * widget,
+                                      GdkEventButton * event);
+static gint gsm_color_button_released (GtkWidget * widget,
+                                       GdkEventButton * event);
+static gboolean gsm_color_button_enter_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+static gboolean gsm_color_button_leave_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+/* source side drag signals */
+static void gsm_color_button_drag_begin (GtkWidget * widget,
+                                         GdkDragContext * context,
+                                         gpointer data);
+static void gsm_color_button_drag_data_get (GtkWidget * widget,
+                                            GdkDragContext * context,
+                                            GtkSelectionData * selection_data,
+                                            guint info, guint time,
+                                            GSMColorButton * color_button);
+
+/* target side drag signals */
+static void gsm_color_button_drag_data_received (GtkWidget * widget,
+                                                 GdkDragContext * context,
+                                                 gint x,
+                                                 gint y,
+                                                 GtkSelectionData *
+                                                 selection_data, guint info,
+                                                 guint32 time,
+                                                 GSMColorButton *
+                                                 color_button);
+
+static guint color_button_signals[LAST_SIGNAL] = { 0 };
+
+static const GtkTargetEntry drop_types[] = { {"application/x-color", 0, 0} };
+
+static void
+gsm_color_button_class_init (GSMColorButtonClass * klass)
+{
+    GObjectClass *gobject_class;
+    GtkWidgetClass *widget_class;
+
+    gobject_class = G_OBJECT_CLASS (klass);
+    widget_class = GTK_WIDGET_CLASS (klass);
+
+    gobject_class->get_property = gsm_color_button_get_property;
+    gobject_class->set_property = gsm_color_button_set_property;
+    gobject_class->finalize = gsm_color_button_finalize;
+    widget_class->state_changed = gsm_color_button_state_changed;
+    widget_class->get_preferred_width = gsm_color_button_get_preferred_width;
+    widget_class->get_preferred_height = gsm_color_button_get_preferred_height;
+    widget_class->size_allocate = gsm_color_button_size_allocate;
+    widget_class->realize = gsm_color_button_realize;
+    widget_class->unrealize = gsm_color_button_unrealize;
+    widget_class->style_set = gsm_color_button_style_set;
+    widget_class->button_release_event = gsm_color_button_released;
+    widget_class->button_press_event = gsm_color_button_pressed;
+    widget_class->enter_notify_event = gsm_color_button_enter_notify;
+    widget_class->leave_notify_event = gsm_color_button_leave_notify;
+
+    klass->color_set = NULL;
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_PERCENTAGE,
+                                     g_param_spec_double ("fraction",
+                                                          _("Fraction"),
+                                     // TRANSLATORS: description of the pie color picker's (mem, swap) filled percentage property
+                                                          _("Percentage full for pie color pickers"),
+                                                          0, 1, 0.5,
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TITLE,
+                                     g_param_spec_string ("title",
+                                                          _("Title"),
+                                                          _("The title of the color selection dialog"),
+                                                          _("Pick a Color"),
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_COLOR,
+                                     g_param_spec_boxed ("color",
+                                                         _("Current Color"),
+                                                         _("The selected color"),
+                                                         GDK_TYPE_RGBA,
+                                                         G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TYPE,
+                                     g_param_spec_uint ("type", _("Type"),
+                                                        _("Type of color picker"),
+                                                        0, 4, 0,
+                                                        G_PARAM_READWRITE));
+
+    color_button_signals[COLOR_SET] = g_signal_new ("color_set",
+                                                    G_TYPE_FROM_CLASS
+                                                    (gobject_class),
+                                                    G_SIGNAL_RUN_FIRST,
+                                                    G_STRUCT_OFFSET
+                                                    (GSMColorButtonClass,
+                                                    color_set), NULL, NULL,
+                                                    g_cclosure_marshal_VOID__VOID,
+                                                    G_TYPE_NONE, 0);
+
+}
+
+static cairo_surface_t *
+fill_image_buffer_from_file (cairo_t *cr, const char *filePath)
+{
+    GError *error = NULL;
+    RsvgHandle *handle;
+    cairo_surface_t *tmp_surface;
+    cairo_t *tmp_cr;
+
+    handle = rsvg_handle_new_from_file (filePath, &error);
+
+    if (handle == NULL) {
+        g_warning("rsvg_handle_new_from_file(\"%s\") failed: %s",
+              filePath, (error ? error->message : "unknown error"));
+    if (error)
+          g_error_free(error);
+    return NULL;
+    }
+
+    tmp_surface = cairo_surface_create_similar (cairo_get_target (cr),
+                                                CAIRO_CONTENT_COLOR_ALPHA,
+                                                32, 32);
+    tmp_cr = cairo_create (tmp_surface);
+    rsvg_handle_render_cairo (handle, tmp_cr);
+    cairo_destroy (tmp_cr);
+    g_object_unref (handle);
+    return tmp_surface;
+}
+
+static void
+render (GtkWidget * widget)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GdkRGBA *color;
+    GdkRGBA tmp_color = priv->color;
+    color = &tmp_color;
+    cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
+    cairo_path_t *path = NULL;
+    gint width, height;
+    gdouble radius, arc_start, arc_end;
+    gdouble highlight_factor;
+
+    if (priv->highlight > 0) {
+        highlight_factor = 0.125 * priv->highlight;
+
+    if (color->red + highlight_factor > 1.0)
+        color->red = 1.0;
+    else
+        color->red = color->red + highlight_factor;
+
+    if (color->blue + highlight_factor > 1.0)
+        color->blue = 1.0;
+    else
+      color->blue = color->blue + highlight_factor;
+
+    if (color->green + highlight_factor > 1.0)
+        color->green = 1.0;
+    else
+        color->green = color->green + highlight_factor;
+    }
+    gdk_cairo_set_source_rgba (cr, color);
+
+    width = gdk_window_get_width(gtk_widget_get_window(widget));
+    height = gdk_window_get_height(gtk_widget_get_window(widget));
+
+    switch (priv->type)
+        {
+        case GSMCP_TYPE_CPU:
+            //gtk_widget_set_size_request (widget, GSMCP_MIN_WIDTH, GSMCP_MIN_HEIGHT);
+            cairo_paint (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1);
+            cairo_stroke (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.4);
+            cairo_rectangle (cr, 1.5, 1.5, width - 3, height - 3);
+            cairo_stroke (cr);
+            break;
+        case GSMCP_TYPE_PIE:
+            if (width < 32)        // 32px minimum size
+                gtk_widget_set_size_request (widget, 32, 32);
+            if (width < height)
+                radius = width / 2;
+            else
+                radius = height / 2;
+
+            arc_start = -G_PI_2 + 2 * G_PI * priv->fraction;
+            arc_end = -G_PI_2;
+
+            cairo_set_line_width (cr, 1);
+
+            // Draw external stroke and fill
+            if (priv->fraction < 0.01) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_end);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    arc_end, arc_start);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_start);
+            }
+            cairo_fill_preserve (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.7);
+            cairo_stroke (cr);
+
+            // Draw internal highlight
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.45);
+            cairo_set_line_width (cr, 1);
+
+            if (priv->fraction < 0.03) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_end - (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    arc_end - (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+            }
+            cairo_stroke (cr);
+
+            // Draw external shape
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.2);
+            cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 1.25, 0,
+                G_PI * 2);
+            cairo_stroke (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_IN:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                    fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/download.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 8.5, 1.5);
+            cairo_line_to (cr, 23.5, 1.5);
+            cairo_line_to (cr, 23.5, 11.5);
+            cairo_line_to (cr, 29.5, 11.5);
+            cairo_line_to (cr, 16.5, 27.5);
+            cairo_line_to (cr, 15.5, 27.5);
+            cairo_line_to (cr, 2.5, 11.5);
+            cairo_line_to (cr, 8.5, 11.5);
+            cairo_line_to (cr, 8.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_OUT:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/upload.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 16.5, 1.5);
+            cairo_line_to (cr, 29.5, 17.5);
+            cairo_line_to (cr, 23.5, 17.5);
+            cairo_line_to (cr, 23.5, 27.5);
+            cairo_line_to (cr, 8.5, 27.5);
+            cairo_line_to (cr, 8.5, 17.5);
+            cairo_line_to (cr, 2.5, 17.5);
+            cairo_line_to (cr, 15.5, 1.5);
+            cairo_line_to (cr, 16.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        }
+    cairo_destroy (cr);
+}
+
+/* Handle exposure events for the color picker's drawing area */
+static gboolean draw (GtkWidget * widget, cairo_t * cr, gpointer data)
+{
+    render (GTK_WIDGET (data));
+
+    return FALSE;
+}
+
+static void
+gsm_color_button_realize (GtkWidget * widget)
+{
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->realize (widget);
+    render (widget);
+}
+
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width)
+{
+    g_return_if_fail (widget != NULL && minimum_width != NULL && natural_width != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_width = GSMCP_MIN_WIDTH;
+    *natural_width = GSMCP_MIN_WIDTH;
+}
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height)
+{
+    g_return_if_fail (widget != NULL && minimum_height != NULL && natural_height != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_height = GSMCP_MIN_HEIGHT;
+    *natural_height = GSMCP_MIN_HEIGHT;
+}
+
+static void
+gsm_color_button_size_allocate (GtkWidget * widget,
+                                GtkAllocation * allocation)
+{
+    g_return_if_fail (widget != NULL || allocation != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    gtk_widget_set_allocation (widget, allocation);
+
+    if (gtk_widget_get_realized (widget))
+    {
+        gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y,
+                                allocation->width, allocation->height);
+    }
+}
+
+static void
+gsm_color_button_unrealize (GtkWidget * widget)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->unrealize (widget);
+}
+
+static void
+gsm_color_button_style_set (GtkWidget * widget, GtkStyle * previous_style)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->style_set (widget,
+                                                                 previous_style);
+
+}
+
+static void
+gsm_color_button_state_changed (GtkWidget * widget,
+                                GtkStateType previous_state)
+{
+}
+
+static void
+gsm_color_button_drag_data_received (GtkWidget * widget,
+                                     GdkDragContext * context,
+                                     gint x,
+                                     gint y,
+                                     GtkSelectionData * selection_data,
+                                     guint info,
+                                     guint32 time,
+                                     GSMColorButton * color_button)
+{
+    gint length;
+    guint16 *dropped;
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    length = gtk_selection_data_get_length (selection_data);
+
+    if (length < 0)
+        return;
+
+    /* We accept drops with the wrong format, since the KDE color
+     * chooser incorrectly drops application/x-color with format 8.
+     */
+    if (length != 8)
+    {
+        g_warning (_("Received invalid color data\n"));
+        return;
+    }
+
+    dropped = (guint16 *) gtk_selection_data_get_data (selection_data);
+
+    priv->color.red =   ((double) dropped[0]) / 65535.0;
+    priv->color.green = ((double) dropped[1]) / 65535.0;
+    priv->color.blue =  ((double) dropped[2]) / 65535.0;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+    g_object_freeze_notify (G_OBJECT (color_button));
+    g_object_notify (G_OBJECT (color_button), "color");
+    g_object_thaw_notify (G_OBJECT (color_button));
+}
+
+static void
+set_color_icon (GdkDragContext * context, GdkRGBA * color)
+{
+    GdkPixbuf *pixbuf;
+    guint32 pixel;
+
+    pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 48, 32);
+
+    pixel = ((guint32)(color->red * 0xff) << 24) |
+            ((guint32)(color->green * 0xff) << 16) |
+            ((guint32)(color->blue * 0xff) << 8);
+
+    gdk_pixbuf_fill (pixbuf, pixel);
+
+    gtk_drag_set_icon_pixbuf (context, pixbuf, -2, -2);
+    g_object_unref (pixbuf);
+}
+
+static void
+gsm_color_button_drag_begin (GtkWidget * widget,
+                             GdkDragContext * context, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = data;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    set_color_icon (context, &priv->color);
+}
+
+static void
+gsm_color_button_drag_data_get (GtkWidget * widget,
+                                GdkDragContext * context,
+                                GtkSelectionData * selection_data,
+                                guint info,
+                                guint time, GSMColorButton * color_button)
+{
+    guint16 dropped[4];
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    dropped[0] = (guint16) (65535.0 * priv->color.red);
+    dropped[1] = (guint16) (65535.0 * priv->color.green);
+    dropped[2] = (guint16) (65535.0 * priv->color.blue);
+    dropped[3] = 65535;        // This widget doesn't care about alpha
+
+    gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data),
+                            16, (guchar *) dropped, 8);
+}
+
+static void
+gsm_color_button_init (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = 0;
+    priv->color.green = 0;
+    priv->color.blue = 0;
+    priv->fraction = 0.5;
+    priv->type = GSMCP_TYPE_CPU;
+    priv->image_buffer = NULL;
+    priv->title = g_strdup (_("Pick a Color"));     /* default title */
+    priv->in_button = FALSE;
+    priv->button_down = FALSE;
+
+    gtk_drag_dest_set (GTK_WIDGET (color_button),
+                       GTK_DEST_DEFAULT_MOTION |
+                       GTK_DEST_DEFAULT_HIGHLIGHT |
+                       GTK_DEST_DEFAULT_DROP, drop_types, 1, GDK_ACTION_COPY);
+    gtk_drag_source_set (GTK_WIDGET (color_button),
+                         GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
+                         drop_types, 1, GDK_ACTION_COPY);
+    g_signal_connect (color_button, "drag_begin",
+                      G_CALLBACK (gsm_color_button_drag_begin), color_button);
+    g_signal_connect (color_button, "drag_data_received",
+                      G_CALLBACK (gsm_color_button_drag_data_received),
+                      color_button);
+    g_signal_connect (color_button, "drag_data_get",
+                      G_CALLBACK (gsm_color_button_drag_data_get),
+                      color_button);
+
+    gtk_widget_add_events (GTK_WIDGET(color_button), GDK_ENTER_NOTIFY_MASK
+                              | GDK_LEAVE_NOTIFY_MASK);
+
+    gtk_widget_set_tooltip_text (GTK_WIDGET(color_button), _("Click to set graph colors"));
+
+    g_signal_connect (color_button, "draw", G_CALLBACK (draw), color_button);
+}
+
+static void
+gsm_color_button_finalize (GObject * object)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    if (priv->cc_dialog != NULL)
+        gtk_widget_destroy (priv->cc_dialog);
+    priv->cc_dialog = NULL;
+
+    g_free (priv->title);
+    priv->title = NULL;
+
+    cairo_surface_destroy (priv->image_buffer);
+    priv->image_buffer = NULL;
+
+    G_OBJECT_CLASS (gsm_color_button_parent_class)->finalize (object);
+}
+
+GtkWidget *
+gsm_color_button_new (const GdkRGBA * color, guint type)
+{
+    return g_object_new (GSM_TYPE_COLOR_BUTTON, "color", color, "type", type,
+                         NULL);
+}
+
+static void
+dialog_response (GtkWidget * widget, GtkResponseType response, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GtkColorChooser *color_chooser;
+
+    if (response == GTK_RESPONSE_OK) {
+        color_chooser = GTK_COLOR_CHOOSER (priv->cc_dialog);
+
+        gtk_color_chooser_get_rgba (color_chooser, &priv->color);
+
+        gtk_widget_hide (priv->cc_dialog);
+
+        gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+        g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+        g_object_freeze_notify (G_OBJECT (color_button));
+        g_object_notify (G_OBJECT (color_button), "color");
+        g_object_thaw_notify (G_OBJECT (color_button));
+    }
+    else  /* (response == GTK_RESPONSE_CANCEL) */
+        gtk_widget_hide (priv->cc_dialog);
+}
+
+static gboolean
+dialog_destroy (GtkWidget * widget, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->cc_dialog = NULL;
+
+    return FALSE;
+}
+
+static gint
+gsm_color_button_clicked (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    /* if dialog already exists, make sure it's shown and raised */
+    if (!priv->cc_dialog)
+    {
+        /* Create the dialog and connects its buttons */
+        GtkWidget *cc_dialog;
+        GtkWidget *parent;
+
+        parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));
+        if (!gtk_widget_is_toplevel (parent))
+            parent = NULL;
+
+        cc_dialog = gtk_color_chooser_dialog_new (priv->title, GTK_WINDOW (parent));
+
+        gtk_window_set_modal (GTK_WINDOW (cc_dialog), TRUE);
+
+        g_signal_connect (cc_dialog, "response",
+                          G_CALLBACK (dialog_response), color_button);
+
+        g_signal_connect (cc_dialog, "destroy",
+                          G_CALLBACK (dialog_destroy), color_button);
+
+        priv->cc_dialog = cc_dialog;
+    }
+
+    gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (priv->cc_dialog),
+                                &priv->color);
+
+    gtk_window_present (GTK_WINDOW (priv->cc_dialog));
+
+    return 0;
+}
+
+static gint
+gsm_color_button_pressed (GtkWidget * widget, GdkEventButton * event)
+{
+    if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) )
+    {
+	GSMColorButtonPrivate *priv;
+        GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+	priv = gsm_color_button_get_instance_private (color_button);
+	priv->button_down = TRUE;
+    }
+  return 0;
+}
+
+static gint
+gsm_color_button_released (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    if (priv->button_down && priv->in_button)
+        gsm_color_button_clicked (widget, event);
+    priv->button_down = FALSE;
+    return 0;
+}
+
+static gboolean
+gsm_color_button_enter_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 1.0;
+    priv->in_button = TRUE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+static gboolean
+gsm_color_button_leave_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 0;
+    priv->in_button = FALSE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+guint
+gsm_color_button_get_cbtype (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->type;
+}
+
+void
+gsm_color_button_set_cbtype (GSMColorButton * color_button, guint type)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->type = type;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "type");
+}
+
+gdouble
+gsm_color_button_get_fraction (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->fraction;
+}
+
+void
+gsm_color_button_set_fraction (GSMColorButton * color_button,
+                               gdouble fraction)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->fraction = fraction;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "fraction");
+}
+
+void
+gsm_color_button_get_color (GSMColorButton * color_button, GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    color->red = priv->color.red;
+    color->green = priv->color.green;
+    color->blue = priv->color.blue;
+    color->alpha = priv->color.alpha;
+}
+
+void
+gsm_color_button_set_color (GSMColorButton * color_button,
+                            const GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    g_return_if_fail (color != NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = color->red;
+    priv->color.green = color->green;
+    priv->color.blue = color->blue;
+    priv->color.alpha = color->alpha;
+
+    gtk_widget_queue_draw (GTK_WIDGET (color_button));
+
+    g_object_notify (G_OBJECT (color_button), "color");
+}
+
+void
+gsm_color_button_set_title (GSMColorButton * color_button,
+                            const gchar * title)
+{
+    gchar *old_title;
+    GSMColorButtonPrivate *priv;
+
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    old_title = priv->title;
+    priv->title = g_strdup (title);
+    g_free (old_title);
+
+    if (priv->cc_dialog)
+        gtk_window_set_title (GTK_WINDOW (priv->cc_dialog),
+                              priv->title);
+
+    g_object_notify (G_OBJECT (color_button), "title");
+}
+
+const gchar* gsm_color_button_get_title(GSMColorButton* color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail(GSM_IS_COLOR_BUTTON(color_button), NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->title;
+}
+
+static void
+gsm_color_button_set_property (GObject * object,
+                               guint param_id,
+                               const GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            gsm_color_button_set_fraction (color_button,
+                                           g_value_get_double (value));
+            break;
+        case PROP_TITLE:
+            gsm_color_button_set_title (color_button, g_value_get_string (value));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_set_color (color_button, g_value_get_boxed (value));
+            break;
+        case PROP_TYPE:
+            gsm_color_button_set_cbtype (color_button, g_value_get_uint (value));
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+static void
+gsm_color_button_get_property (GObject * object,
+                               guint param_id,
+                               GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+    GdkRGBA color;
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            g_value_set_double (value,
+                                gsm_color_button_get_fraction (color_button));
+            break;
+        case PROP_TITLE:
+            g_value_set_string (value, gsm_color_button_get_title (color_button));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_get_color (color_button, &color);
+                                        g_value_set_boxed (value, &color);
+            break;
+        case PROP_TYPE:
+            g_value_set_uint (value, gsm_color_button_get_cbtype (color_button));
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/6.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/6.html new file mode 100644 index 00000000..f73c90ba --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/6.html @@ -0,0 +1,1599 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
/* Procman - main window
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <gdk/gdkkeysyms.h>
+#include <math.h>
+
+#include "procman.h"
+#include "callbacks.h"
+#include "interface.h"
+#include "proctable.h"
+#include "procactions.h"
+#include "load-graph.h"
+#include "util.h"
+#include "disks.h"
+#include "sysinfo.h"
+#include "gsm_color_button.h"
+
+static void    cb_toggle_tree (GtkAction *action, gpointer data);
+static void    cb_proc_goto_tab (gint tab);
+
+static const GtkActionEntry menu_entries[] =
+{
+    // xgettext: noun, top level menu.
+    // "File" did not make sense for system-monitor
+    { "Monitor", NULL, N_("_Monitor") },
+    { "Edit", NULL, N_("_Edit") },
+    { "View", NULL, N_("_View") },
+    { "Help", NULL, N_("_Help") },
+
+    { "Lsof", "edit-find", N_("Search for _Open Files"), "<control>O",
+      N_("Search for open files"), G_CALLBACK(cb_show_lsof) },
+    { "Quit", "application-exit", N_("_Quit"), "<control>Q",
+      N_("Quit the program"), G_CALLBACK (cb_app_exit) },
+
+
+    { "StopProcess", NULL, N_("_Stop Process"), "<control>S",
+      N_("Stop process"), G_CALLBACK(cb_kill_sigstop) },
+    { "ContProcess", NULL, N_("_Continue Process"), "<control>C",
+      N_("Continue process if stopped"), G_CALLBACK(cb_kill_sigcont) },
+
+    { "EndProcess", NULL, N_("_End Process"), "<control>E",
+      N_("Force process to finish normally"), G_CALLBACK (cb_end_process) },
+    { "KillProcess", NULL, N_("_Kill Process"), "<control>K",
+      N_("Force process to finish immediately"), G_CALLBACK (cb_kill_process) },
+    { "ChangePriority", NULL, N_("_Change Priority"), NULL,
+      N_("Change the order of priority of process"), NULL },
+    { "Preferences", "preferences-desktop", N_("_Preferences"), NULL,
+      N_("Configure the application"), G_CALLBACK (cb_edit_preferences) },
+
+    { "Refresh", "view-refresh", N_("_Refresh"), "<control>R",
+      N_("Refresh the process list"), G_CALLBACK(cb_user_refresh) },
+
+    { "MemoryMaps", NULL, N_("_Memory Maps"), "<control>M",
+      N_("Open the memory maps associated with a process"), G_CALLBACK (cb_show_memory_maps) },
+    // Translators: this means 'Files that are open' (open is no verb here
+    { "OpenFiles", NULL, N_("Open _Files"), "<control>F",
+      N_("View the files opened by a process"), G_CALLBACK (cb_show_open_files) },
+    { "ProcessProperties", NULL, N_("_Properties"), NULL,
+      N_("View additional information about a process"), G_CALLBACK (cb_show_process_properties) },
+
+
+    { "HelpContents", "help-browser", N_("_Contents"), "F1",
+      N_("Open the manual"), G_CALLBACK (cb_help_contents) },
+    { "About", "help-about", N_("_About"), NULL,
+      N_("About this application"), G_CALLBACK (cb_about) }
+};
+
+static const GtkToggleActionEntry toggle_menu_entries[] =
+{
+    { "ShowDependencies", NULL, N_("_Dependencies"), "<control>D",
+      N_("Show parent/child relationship between processes"),
+      G_CALLBACK (cb_toggle_tree), TRUE },
+};
+
+
+static const GtkRadioActionEntry radio_menu_entries[] =
+{
+  { "ShowActiveProcesses", NULL, N_("_Active Processes"), NULL,
+    N_("Show active processes"), ACTIVE_PROCESSES },
+  { "ShowAllProcesses", NULL, N_("A_ll Processes"), NULL,
+    N_("Show all processes"), ALL_PROCESSES },
+  { "ShowMyProcesses", NULL, N_("M_y Processes"), NULL,
+    N_("Show only user-owned processes"), MY_PROCESSES }
+};
+
+static const GtkRadioActionEntry priority_menu_entries[] =
+{
+    { "VeryHigh", NULL, N_("Very High"), NULL,
+      N_("Set process priority to very high"), VERY_HIGH_PRIORITY },
+    { "High", NULL, N_("High"), NULL,
+      N_("Set process priority to high"), HIGH_PRIORITY },
+    { "Normal", NULL, N_("Normal"), NULL,
+      N_("Set process priority to normal"), NORMAL_PRIORITY },
+    { "Low", NULL, N_("Low"), NULL,
+      N_("Set process priority to low"), LOW_PRIORITY },
+    { "VeryLow", NULL, N_("Very Low"), NULL,
+      N_("Set process priority to very low"), VERY_LOW_PRIORITY },
+    { "Custom", NULL, N_("Custom"), NULL,
+      N_("Set process priority manually"), CUSTOM_PRIORITY }
+};
+
+
+static const char ui_info[] =
+    "  <menubar name=\"MenuBar\">"
+    "    <menu name=\"MonitorMenu\" action=\"Monitor\">"
+    "      <menuitem name=\"MonitorLsofMenu\" action=\"Lsof\" />"
+    "      <menuitem name=\"MonitorQuitMenu\" action=\"Quit\" />"
+    "    </menu>"
+    "    <menu name=\"EditMenu\" action=\"Edit\">"
+    "      <menuitem name=\"EditStopProcessMenu\" action=\"StopProcess\" />"
+    "      <menuitem name=\"EditContProcessMenu\" action=\"ContProcess\" />"
+    "      <separator />"
+    "      <menuitem name=\"EditEndProcessMenu\" action=\"EndProcess\" />"
+    "      <menuitem name=\"EditKillProcessMenu\" action=\"KillProcess\" />"
+    "      <separator />"
+    "      <menu name=\"EditChangePriorityMenu\" action=\"ChangePriority\" >"
+    "        <menuitem action=\"VeryHigh\" />"
+    "        <menuitem action=\"High\" />"
+    "        <menuitem action=\"Normal\" />"
+    "        <menuitem action=\"Low\" />"
+    "        <menuitem action=\"VeryLow\" />"
+    "        <separator />"
+    "        <menuitem action=\"Custom\"/>"
+    "      </menu>"
+    "      <separator />"
+    "      <menuitem name=\"EditPreferencesMenu\" action=\"Preferences\" />"
+    "    </menu>"
+    "    <menu name=\"ViewMenu\" action=\"View\">"
+    "      <menuitem name=\"ViewActiveProcesses\" action=\"ShowActiveProcesses\" />"
+    "      <menuitem name=\"ViewAllProcesses\" action=\"ShowAllProcesses\" />"
+    "      <menuitem name=\"ViewMyProcesses\" action=\"ShowMyProcesses\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewDependenciesMenu\" action=\"ShowDependencies\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewMemoryMapsMenu\" action=\"MemoryMaps\" />"
+    "      <menuitem name=\"ViewOpenFilesMenu\" action=\"OpenFiles\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewProcessPropertiesMenu\" action=\"ProcessProperties\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewRefresh\" action=\"Refresh\" />"
+    "    </menu>"
+    "    <menu name=\"HelpMenu\" action=\"Help\">"
+    "      <menuitem name=\"HelpContentsMenu\" action=\"HelpContents\" />"
+    "      <menuitem name=\"HelpAboutMenu\" action=\"About\" />"
+    "    </menu>"
+    "  </menubar>"
+    "  <popup name=\"PopupMenu\" action=\"Popup\">"
+    "    <menuitem action=\"StopProcess\" />"
+    "    <menuitem action=\"ContProcess\" />"
+    "    <separator />"
+    "    <menuitem action=\"EndProcess\" />"
+    "    <menuitem action=\"KillProcess\" />"
+    "    <separator />"
+    "    <menu name=\"ChangePriorityMenu\" action=\"ChangePriority\" >"
+    "      <menuitem action=\"VeryHigh\" />"
+    "      <menuitem action=\"High\" />"
+    "      <menuitem action=\"Normal\" />"
+    "      <menuitem action=\"Low\" />"
+    "      <menuitem action=\"VeryLow\" />"
+    "      <separator />"
+    "      <menuitem action=\"Custom\"/>"
+    "    </menu>"
+    "    <separator />"
+    "    <menuitem action=\"MemoryMaps\" />"
+    "    <menuitem action=\"OpenFiles\" />"
+    "    <separator />"
+    "    <menuitem action=\"ProcessProperties\" />"
+
+    "  </popup>";
+
+
+static void
+create_proc_view(ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *proctree;
+    GtkWidget *scrolled;
+    char* string;
+
+    /* create the processes tab */
+    string = make_loadavg_string ();
+    procdata->loadavg = GTK_WIDGET (gtk_builder_get_object (builder, "load_avg_label"));
+    gtk_label_set_text (GTK_LABEL (procdata->loadavg), string);
+    g_free (string);
+
+    proctree = proctable_new (procdata);
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "processes_scrolled"));
+
+    gtk_container_add (GTK_CONTAINER (scrolled), proctree);
+
+    procdata->endprocessbutton = GTK_WIDGET (gtk_builder_get_object (builder, "endprocessbutton"));
+    g_signal_connect (G_OBJECT (procdata->endprocessbutton), "clicked",
+                      G_CALLBACK (cb_end_process_button_pressed), procdata);
+
+    /* create popup_menu for the processes tab */
+    procdata->popup_menu = gtk_ui_manager_get_widget (procdata->uimanager, "/PopupMenu");
+}
+
+
+GtkWidget *
+make_title_label (const char *text)
+{
+    GtkWidget *label;
+    char *full;
+
+    full = g_strdup_printf ("<span weight=\"bold\">%s</span>", text);
+    label = gtk_label_new (full);
+    g_free (full);
+
+    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+
+    return label;
+}
+
+
+static void
+create_sys_view (ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *cpu_graph_box, *mem_graph_box, *net_graph_box;
+    GtkWidget *label,*cpu_label;
+    GtkWidget *table;
+    GtkWidget *color_picker;
+    GtkWidget *picker_alignment;
+    LoadGraph *cpu_graph, *mem_graph, *net_graph;
+
+    gint i;
+    gchar *title_text;
+    gchar *label_text;
+    gchar *title_template;
+
+    // Translators: color picker title, %s is CPU, Memory, Swap, Receiving, Sending
+    title_template = g_strdup(_("Pick a Color for '%s'"));
+
+    /* The CPU BOX */
+
+    cpu_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_graph_box"));
+
+    cpu_graph = new LoadGraph(LOAD_GRAPH_CPU);
+    gtk_box_pack_start (GTK_BOX (cpu_graph_box),
+                        load_graph_get_widget(cpu_graph),
+                        TRUE,
+                        TRUE,
+                         0);
+
+    GtkWidget* flowbox = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_flow_box"));
+    gtk_box_reorder_child (GTK_BOX (cpu_graph_box), flowbox, 1);
+    for (i=0;i<procdata->config.num_cpus; i++) {
+        GtkWidget *temp_hbox;
+
+        temp_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
+        gtk_container_add (GTK_CONTAINER (flowbox), temp_hbox);
+
+        color_picker = gsm_color_button_new (&cpu_graph->colors.at(i), GSMCP_TYPE_CPU);
+        g_signal_connect (G_OBJECT (color_picker), "color_set",
+                          G_CALLBACK (cb_cpu_color_changed), GINT_TO_POINTER (i));
+        gtk_box_pack_start (GTK_BOX (temp_hbox), color_picker, FALSE, TRUE, 0);
+        gtk_widget_set_size_request(GTK_WIDGET(color_picker), 32, -1);
+        if(procdata->config.num_cpus == 1) {
+            label_text = g_strdup (_("CPU"));
+        } else {
+            label_text = g_strdup_printf (_("CPU%d"), i+1);
+        }
+        title_text = g_strdup_printf(title_template, label_text);
+        label = gtk_label_new (label_text);
+        gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+        g_free(title_text);
+        gtk_box_pack_start (GTK_BOX (temp_hbox), label, FALSE, FALSE, 6);
+        g_free (label_text);
+
+        cpu_label = gtk_label_new (NULL);
+        gtk_label_set_width_chars (GTK_LABEL (cpu_label), 7);
+        gtk_label_set_xalign (GTK_LABEL (cpu_label), 0.0);
+
+        gtk_box_pack_start (GTK_BOX (temp_hbox), cpu_label, TRUE, TRUE, 0);
+        load_graph_get_labels(cpu_graph)->cpu[i] = cpu_label;
+
+    }
+
+    procdata->cpu_graph = cpu_graph;
+
+    /** The memory box */
+    mem_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "mem_graph_box"));
+
+    mem_graph = new LoadGraph(LOAD_GRAPH_MEM);
+    gtk_box_pack_start (GTK_BOX (mem_graph_box),
+                        load_graph_get_widget(mem_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "mem_table"));
+
+    color_picker = load_graph_get_mem_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_mem_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Memory"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 0, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->memory;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 1, 1, 1, 1);
+
+    color_picker = load_graph_get_swap_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_swap_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Swap"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 2, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->swap;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 3, 1, 1, 1);
+
+    procdata->mem_graph = mem_graph;
+
+    /* The net box */
+    net_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "net_graph_box"));
+
+    net_graph = new LoadGraph(LOAD_GRAPH_NET);
+    gtk_box_pack_start (GTK_BOX (net_graph_box),
+                        load_graph_get_widget(net_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "net_table"));
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(0), GSMCP_TYPE_NETWORK_IN);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_in_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Receiving"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "receiving_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_in;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_in_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 1, 1, 1);
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(1), GSMCP_TYPE_NETWORK_OUT);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_out_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Sending"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "sending_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_out;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_out_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 1, 1, 1);
+
+    procdata->net_graph = net_graph;
+    g_free(title_template);
+}
+
+static void
+menu_item_select_cb (GtkMenuItem *proxy,
+                     ProcData *procdata)
+{
+    GtkAction *action;
+    char *message;
+
+    action = gtk_activatable_get_related_action (GTK_ACTIVATABLE(proxy));
+    g_assert(action);
+
+    g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
+    if (message)
+    {
+        gtk_statusbar_push (GTK_STATUSBAR (procdata->statusbar),
+                    procdata->tip_message_cid, message);
+        g_free (message);
+    }
+}
+
+static void
+menu_item_deselect_cb (GtkMenuItem *proxy,
+                       ProcData *procdata)
+{
+    gtk_statusbar_pop (GTK_STATUSBAR (procdata->statusbar),
+               procdata->tip_message_cid);
+}
+
+static void
+connect_proxy_cb (GtkUIManager *manager,
+                  GtkAction *action,
+                  GtkWidget *proxy,
+                  ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_connect (proxy, "select",
+                          G_CALLBACK (menu_item_select_cb), procdata);
+        g_signal_connect (proxy, "deselect",
+                          G_CALLBACK (menu_item_deselect_cb), procdata);
+    }
+}
+
+static void
+disconnect_proxy_cb (GtkUIManager *manager,
+                     GtkAction *action,
+                     GtkWidget *proxy,
+                     ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_select_cb)), procdata);
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_deselect_cb)), procdata);
+    }
+}
+
+void
+create_main_window (ProcData *procdata)
+{
+    gint i;
+    gint width, height, xpos, ypos;
+    GtkWidget *app;
+    GtkAction *action;
+    GtkWidget *menubar;
+    GtkWidget *main_box;
+    GtkWidget *notebook;
+    GtkBuilder *builder;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/interface.ui");
+
+    app = GTK_WIDGET (gtk_builder_get_object (builder, "main_window"));
+    main_box = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
+
+    GdkScreen* screen = gtk_widget_get_screen(app);
+    /* use visual, if available */
+    GdkVisual* visual = gdk_screen_get_rgba_visual(screen);
+    if (visual)
+        gtk_widget_set_visual(app, visual);
+
+    width = procdata->config.width;
+    height = procdata->config.height;
+    xpos = procdata->config.xpos;
+    ypos = procdata->config.ypos;
+    gtk_window_set_default_size (GTK_WINDOW (app), width, height);
+    gtk_window_move(GTK_WINDOW (app), xpos, ypos);
+
+    if (procdata->config.maximized) {
+        gtk_window_maximize(GTK_WINDOW(app));
+    }
+
+    /* create the menubar */
+    procdata->uimanager = gtk_ui_manager_new ();
+
+    /* show tooltips in the statusbar */
+    g_signal_connect (procdata->uimanager, "connect_proxy",
+                      G_CALLBACK (connect_proxy_cb), procdata);
+    g_signal_connect (procdata->uimanager, "disconnect_proxy",
+                      G_CALLBACK (disconnect_proxy_cb), procdata);
+
+    gtk_window_add_accel_group (GTK_WINDOW (app),
+                                gtk_ui_manager_get_accel_group (procdata->uimanager));
+
+    if (!gtk_ui_manager_add_ui_from_string (procdata->uimanager,
+                                            ui_info,
+                                            -1,
+                                            NULL)) {
+        g_error("building menus failed");
+    }
+
+    procdata->action_group = gtk_action_group_new ("ProcmanActions");
+    gtk_action_group_set_translation_domain (procdata->action_group, NULL);
+    gtk_action_group_add_actions (procdata->action_group,
+                                  menu_entries,
+                                  G_N_ELEMENTS (menu_entries),
+                                  procdata);
+    gtk_action_group_add_toggle_actions (procdata->action_group,
+                                         toggle_menu_entries,
+                                         G_N_ELEMENTS (toggle_menu_entries),
+                                         procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                        radio_menu_entries,
+                        G_N_ELEMENTS (radio_menu_entries),
+                        procdata->config.whose_process,
+                        G_CALLBACK(cb_radio_processes),
+                        procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                                        priority_menu_entries,
+                                        G_N_ELEMENTS (priority_menu_entries),
+                                        NORMAL_PRIORITY,
+                                        G_CALLBACK(cb_renice),
+                                        procdata);
+
+    gtk_ui_manager_insert_action_group (procdata->uimanager,
+                                        procdata->action_group,
+                                        0);
+
+    menubar = gtk_ui_manager_get_widget (procdata->uimanager, "/MenuBar");
+    gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0);
+    gtk_box_reorder_child (GTK_BOX (main_box), menubar, 0);
+
+    /* create the main notebook */
+    procdata->notebook = notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
+
+    create_proc_view(procdata, builder);
+    create_sys_view (procdata, builder);
+    create_disk_view (procdata, builder);
+
+    g_signal_connect (G_OBJECT (notebook), "switch-page",
+              G_CALLBACK (cb_switch_page), procdata);
+    g_signal_connect (G_OBJECT (notebook), "change-current-page",
+              G_CALLBACK (cb_change_current_page), procdata);
+
+    gtk_widget_show_all(notebook); // need to make page switch work
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab);
+    cb_change_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab, procdata);
+    g_signal_connect (G_OBJECT (app), "delete_event",
+                      G_CALLBACK (cb_app_delete),
+                      procdata);
+
+    GtkAccelGroup *accel_group;
+    GClosure *goto_tab_closure[4];
+    accel_group = gtk_accel_group_new ();
+    gtk_window_add_accel_group (GTK_WINDOW(app), accel_group);
+    for (i = 0; i < 4; ++i) {
+        goto_tab_closure[i] = g_cclosure_new_swap (G_CALLBACK (cb_proc_goto_tab),
+                                                   GINT_TO_POINTER (i), NULL);
+        gtk_accel_group_connect (accel_group, '0'+(i+1),
+                                 GDK_MOD1_MASK, GTK_ACCEL_VISIBLE,
+                                 goto_tab_closure[i]);
+    }
+
+    /* create the statusbar */
+    procdata->statusbar = GTK_WIDGET (gtk_builder_get_object (builder, "statusbar"));
+    procdata->tip_message_cid = gtk_statusbar_get_context_id
+        (GTK_STATUSBAR (procdata->statusbar), "tip_message");
+
+    action = gtk_action_group_get_action (procdata->action_group, "ShowDependencies");
+    gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+                      procdata->config.show_tree);
+
+    gtk_builder_connect_signals (builder, NULL);
+
+    gtk_widget_show_all(app);
+    procdata->app = app;
+
+    g_object_unref (G_OBJECT (builder));
+}
+
+void
+do_popup_menu (ProcData *procdata, GdkEventButton *event)
+{
+    gtk_menu_popup_at_pointer (GTK_MENU (procdata->popup_menu), NULL);
+}
+
+void
+update_sensitivity(ProcData *data)
+{
+    const char * const selected_actions[] = { "StopProcess",
+                                              "ContProcess",
+                                              "EndProcess",
+                                              "KillProcess",
+                                              "ChangePriority",
+                                              "MemoryMaps",
+                                              "OpenFiles",
+                                              "ProcessProperties" };
+
+    const char * const processes_actions[] = { "ShowActiveProcesses",
+                                               "ShowAllProcesses",
+                                               "ShowMyProcesses",
+                                               "ShowDependencies",
+                                               "Refresh"
+    };
+
+    size_t i;
+    gboolean processes_sensitivity, selected_sensitivity;
+    GtkAction *action;
+
+    processes_sensitivity = (data->config.current_tab == PROCMAN_TAB_PROCESSES);
+    selected_sensitivity = (processes_sensitivity && data->selection && gtk_tree_selection_count_selected_rows (data->selection) > 0);
+
+    if(data->endprocessbutton) {
+        /* avoid error on startup if endprocessbutton
+           has not been built yet */
+        gtk_widget_set_sensitive(data->endprocessbutton, selected_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(processes_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             processes_actions[i]);
+        gtk_action_set_sensitive(action, processes_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(selected_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             selected_actions[i]);
+        gtk_action_set_sensitive(action, selected_sensitivity);
+    }
+}
+
+void
+block_priority_changed_handlers(ProcData *data, bool block)
+{
+    gint i;
+    if (block) {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_block_by_func(action, (gpointer)cb_renice, data);
+        }
+    } else {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_unblock_by_func(action, (gpointer)cb_renice, data);
+        }
+    }
+}
+
+static void
+cb_toggle_tree (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GSettings *settings = procdata->settings;
+    gboolean show;
+
+    show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+    if (show == procdata->config.show_tree)
+        return;
+
+    g_settings_set_boolean (settings, "show-tree", show);
+}
+
+static void
+cb_proc_goto_tab (gint tab)
+{
+    ProcData *data = ProcData::get_instance ();
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (data->notebook), tab);
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/7.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/7.html new file mode 100644 index 00000000..8b385037 --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/7.html @@ -0,0 +1,1939 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
#include <config.h>
+
+#include <gdkmm/pixbuf.h>
+
+#include <stdio.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <signal.h>
+#include <dirent.h>
+#include <string.h>
+#include <time.h>
+
+#include <glib/gi18n.h>
+
+#include <glibtop.h>
+#include <glibtop/cpu.h>
+#include <glibtop/mem.h>
+#include <glibtop/swap.h>
+#include <glibtop/netload.h>
+#include <glibtop/netlist.h>
+#include <math.h>
+
+#include <algorithm>
+
+#include "procman.h"
+#include "load-graph.h"
+#include "util.h"
+#include "gsm_color_button.h"
+
+void LoadGraph::clear_background()
+{
+    if (background) {
+        cairo_pattern_destroy (background);
+        this->background = NULL;
+    }
+}
+
+
+unsigned LoadGraph::num_bars() const
+{
+    unsigned n;<--- Shadow variable
+
+    // keep 100 % num_bars == 0
+    switch (static_cast<int>(this->draw_height / (fontsize + 14)))
+    {
+    case 0:
+    case 1:
+        n = 1;
+        break;
+    case 2:
+    case 3:
+        n = 2;
+        break;
+    case 4:
+        n = 4;
+        break;
+    default:
+        n = 5;
+    }
+
+    return n;
+}
+
+
+
+#define FRAME_WIDTH 4
+static void draw_background(LoadGraph *graph) {
+    GtkAllocation allocation;
+    cairo_t *cr;
+    guint i;<--- Shadowed declaration
+    unsigned num_bars;
+    g_autofree gchar *caption;
+    PangoLayout* layout;
+    PangoFontDescription* font_desc;
+    PangoRectangle extents;
+    cairo_surface_t *surface;
+    GdkRGBA fg, bg;
+
+    num_bars = graph->num_bars();
+    graph->graph_dely = (graph->draw_height - 15) / num_bars; /* round to int to avoid AA blur */
+    graph->real_draw_height = graph->graph_dely * num_bars;
+    graph->graph_delx = (graph->draw_width - 2.0 - graph->rmargin - graph->indent) / (LoadGraph::NUM_POINTS - 3);
+    graph->graph_buffer_offset = (int) (1.5 * graph->graph_delx) + FRAME_WIDTH ;
+
+    gtk_widget_get_allocation (graph->disp, &allocation);
+    surface = gdk_window_create_similar_surface (gtk_widget_get_window (graph->disp), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height);
+    cr = cairo_create (surface);
+
+    GtkStyleContext *context = gtk_widget_get_style_context (ProcData::get_instance()->notebook);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get_background_color (context, gtk_style_context_get_state (context), &bg);
+    gtk_style_context_get_color (context, gtk_style_context_get_state (context), &fg);
+    gtk_style_context_restore (context);
+
+    // set the background color
+    gdk_cairo_set_source_rgba (cr, &bg);
+    cairo_paint (cr);
+
+    layout = pango_cairo_create_layout (cr);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get (context,
+                           gtk_style_context_get_state (context),
+                           GTK_STYLE_PROPERTY_FONT,
+                           &font_desc, NULL);
+    gtk_style_context_restore (context);
+    pango_font_description_set_size (font_desc, 0.8 * graph->fontsize * PANGO_SCALE);
+    pango_layout_set_font_description (layout, font_desc);
+    pango_font_description_free (font_desc);
+
+    /* draw frame */
+    cairo_translate (cr, FRAME_WIDTH, FRAME_WIDTH);
+
+    /* Draw background rectangle */
+    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+    cairo_rectangle (cr, graph->rmargin + graph->indent, 0,
+                     graph->draw_width - graph->rmargin - graph->indent, graph->real_draw_height);
+    cairo_fill(cr);
+
+    cairo_set_line_width (cr, 1.0);
+    cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    for (i = 0; i <= num_bars; ++i) {
+        double y;
+
+        if (i == 0)
+            y = 0.5 + graph->fontsize / 2.0;
+        else if (i == num_bars)
+            y = i * graph->graph_dely + 0.5;
+        else
+            y = i * graph->graph_dely + graph->fontsize / 2.0;
+
+        gdk_cairo_set_source_rgba (cr, &fg);
+        if (graph->type == LOAD_GRAPH_NET) {
+            // operation orders matters so it's 0 if i == num_bars
+            guint64 rate = graph->net.max - (i * graph->net.max / num_bars);
+            caption = g_format_size_full (network_in_bits ? rate*8 : rate, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        } else {
+            // operation orders matters so it's 0 if i == num_bars
+            caption = g_strdup_printf("%d%%", 100 - i * (100 / num_bars));
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        }
+
+        if (i==0 || i==num_bars)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, graph->rmargin + graph->indent - 3, i * graph->graph_dely + 0.5);
+        cairo_line_to (cr, graph->draw_width - 0.5, i * graph->graph_dely + 0.5);
+        cairo_stroke (cr);
+    }
+
+    const unsigned total_seconds = graph->speed * (LoadGraph::NUM_POINTS - 2) / 1000;
+
+    for (unsigned int i = 0; i < 7; i++) {<--- Shadow variable
+        double x = (i) * (graph->draw_width - graph->rmargin - graph->indent) / 6;
+        if (i==0 || i==6)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, 0.5);
+        cairo_line_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, graph->real_draw_height + 4.5);
+        cairo_stroke(cr);
+        unsigned seconds = total_seconds - i * total_seconds / 6;
+        const char* format;
+        if (i == 0)
+            format = dngettext(GETTEXT_PACKAGE, "%u second", "%u seconds", seconds);
+        else
+            format = "%u";
+        caption = g_strdup_printf(format, seconds);
+        pango_layout_set_text (layout, caption, -1);
+        pango_layout_get_extents (layout, NULL, &extents);
+        cairo_move_to (cr, ((ceil(x) + 0.5) + graph->rmargin + graph->indent) - (1.0 * extents.width / PANGO_SCALE/2), graph->draw_height - 1.0 * extents.height / PANGO_SCALE);
+        gdk_cairo_set_source_rgba (cr, &fg);
+        pango_cairo_show_layout (cr, layout);
+    }
+    g_object_unref(layout);
+    cairo_stroke (cr);
+    cairo_destroy (cr);
+    graph->background = cairo_pattern_create_for_surface (surface);
+    cairo_surface_destroy (surface);
+}
+
+/* Redraws the backing buffer for the load graph and updates the window */
+void
+load_graph_queue_draw (LoadGraph *graph)
+{
+    /* repaint */
+    gtk_widget_queue_draw (graph->disp);
+}
+
+static int load_graph_update (gpointer user_data); // predeclare load_graph_update so we can compile ;)
+
+static gboolean
+load_graph_configure (GtkWidget *widget,
+                      GdkEventConfigure *event,
+                      gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    gtk_widget_get_allocation (widget, &allocation);
+    graph->draw_width = allocation.width - 2 * FRAME_WIDTH;
+    graph->draw_height = allocation.height - 2 * FRAME_WIDTH;
+
+    graph->clear_background();
+
+    load_graph_queue_draw (graph);
+
+    return TRUE;
+}
+
+static gboolean load_graph_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+    GdkWindow *window;
+
+    guint i, j;
+    gdouble sample_width, x_offset;
+
+    window = gtk_widget_get_window (graph->disp);
+
+    /* Number of pixels wide for one graph point */
+    sample_width = (float)(graph->draw_width - graph->rmargin - graph->indent) / (float)LoadGraph::NUM_POINTS;
+    /* General offset */
+    x_offset = graph->draw_width - graph->rmargin + (sample_width*2);
+
+    /* Subframe offset */
+    x_offset += graph->rmargin - ((sample_width / graph->frames_per_unit) * graph->render_counter);
+
+    /* draw the graph */
+    cairo_t* cr;
+
+    cr = gdk_cairo_create (window);
+
+    if (graph->background == NULL) {
+        draw_background(graph);
+    }
+    cairo_set_source (cr, graph->background);
+    cairo_paint (cr);
+
+    cairo_set_line_width (cr, 1);
+    cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+    cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+    cairo_rectangle (cr, graph->rmargin + graph->indent + FRAME_WIDTH + 1, FRAME_WIDTH - 1,
+             graph->draw_width - graph->rmargin - graph->indent - 1, graph->real_draw_height + FRAME_WIDTH - 1);
+    cairo_clip(cr);
+
+    for (j = 0; j < graph->n; ++j) {
+        cairo_move_to (cr, x_offset, (1.0f - graph->data[0][j]) * graph->real_draw_height);
+        gdk_cairo_set_source_rgba (cr, &(graph->colors [j]));
+
+        for (i = 1; i < LoadGraph::NUM_POINTS; ++i) {
+            if (graph->data[i][j] == -1.0f)
+                continue;
+            cairo_curve_to (cr,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i-1][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - (i * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f);
+        }
+        cairo_stroke (cr);
+
+    }
+
+    cairo_destroy (cr);
+
+    return TRUE;
+}
+
+static void
+get_load (LoadGraph *graph)
+{
+    guint i;
+    glibtop_cpu cpu;
+
+    glibtop_get_cpu (&cpu);
+
+#undef NOW
+#undef LAST
+#define NOW  (graph->cpu.times[graph->cpu.now])
+#define LAST (graph->cpu.times[graph->cpu.now ^ 1])
+
+    if (graph->n == 1) {
+        NOW[0][CPU_TOTAL] = cpu.total;
+        NOW[0][CPU_USED] = cpu.user + cpu.nice + cpu.sys;
+    } else {
+        for (i = 0; i < graph->n; i++) {
+            NOW[i][CPU_TOTAL] = cpu.xcpu_total[i];
+            NOW[i][CPU_USED] = cpu.xcpu_user[i] + cpu.xcpu_nice[i]
+                + cpu.xcpu_sys[i];
+        }
+    }
+
+    // on the first call, LAST is 0
+    // which means data is set to the average load since boot
+    // that value has no meaning, we just want all the
+    // graphs to be aligned, so the CPU graph needs to start
+    // immediately
+
+    for (i = 0; i < graph->n; i++) {
+        float load;
+        float total, used;
+        gchar *text;
+
+        total = NOW[i][CPU_TOTAL] - LAST[i][CPU_TOTAL];
+        used  = NOW[i][CPU_USED]  - LAST[i][CPU_USED];
+
+        load = used / MAX(total, 1.0f);
+        graph->data[0][i] = load;
+
+        /* Update label */
+        text = g_strdup_printf("%.1f%%", load * 100.0f);
+        gtk_label_set_text(GTK_LABEL(graph->labels.cpu[i]), text);
+        g_free(text);
+    }
+
+    graph->cpu.now ^= 1;
+
+#undef NOW
+#undef LAST
+}
+
+
+namespace
+{
+
+    void set_memory_label_and_picker(GtkLabel* label, GSMColorButton* picker,
+                                   guint64 used, guint64 total, double percent)
+    {
+        char* used_text;
+        char* total_text;
+        char* text;
+
+        used_text = g_format_size_full(used, G_FORMAT_SIZE_IEC_UNITS);
+        total_text = g_format_size_full(total, G_FORMAT_SIZE_IEC_UNITS);
+        if (total == 0) {
+            text = g_strdup(_("not available"));
+        } else {
+            // xgettext: 540MiB (53 %) of 1.0 GiB
+            text = g_strdup_printf(_("%s (%.1f%%) of %s"), used_text, 100.0 * percent, total_text);
+        }
+        gtk_label_set_text(label, text);
+        g_free(used_text);
+        g_free(total_text);
+        g_free(text);
+
+        if (picker)
+            gsm_color_button_set_fraction(picker, percent);
+    }
+}
+
+static void
+get_memory (LoadGraph *graph)
+{
+    float mempercent, swappercent;
+
+    glibtop_mem mem;
+    glibtop_swap swap;
+
+    glibtop_get_mem (&mem);
+    glibtop_get_swap (&swap);
+
+    /* There's no swap on LiveCD : 0.0f is better than NaN :) */
+    swappercent = (swap.total ? (float)swap.used / (float)swap.total : 0.0f);
+    mempercent  = (float)mem.user  / (float)mem.total;
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.memory),
+                                GSM_COLOR_BUTTON(graph->mem_color_picker),
+                                mem.user, mem.total, mempercent);
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.swap),
+                                GSM_COLOR_BUTTON(graph->swap_color_picker),
+                                swap.used, swap.total, swappercent);
+
+    graph->data[0][0] = mempercent;
+    graph->data[0][1] = swappercent;
+}
+
+/* Nice Numbers for Graph Labels after Paul Heckbert
+   nicenum: find a "nice" number approximately equal to x.
+   Round the number if round=1, take ceiling if round=0    */
+
+static double
+nicenum (double x, int round)
+{
+    int expv;				/* exponent of x */
+    double f;				/* fractional part of x */
+    double nf;				/* nice, rounded fraction */
+
+    expv = floor( log10(x) );
+    f = x/pow( 10.0, expv );		/* between 1 and 10 */
+    if (round) {
+        if ( f < 1.5 ) nf = 1.0;
+        else if ( f < 3.0 ) nf = 2.0;
+        else if ( f < 7.0 ) nf = 5.0;
+        else nf = 10.0;
+    } else {
+        if ( f <= 1.0 ) nf = 1.0;
+        else if ( f <= 2.0 ) nf = 2.0;
+        else if ( f <= 5.0 ) nf = 5.0;
+        else nf = 10.0;
+    }
+    return nf * pow(10.0, expv);
+}
+
+static void
+net_scale (LoadGraph *graph, guint64 din, guint64 dout)
+{
+    graph->data[0][0] = 1.0f * din / graph->net.max;
+    graph->data[0][1] = 1.0f * dout / graph->net.max;
+
+    guint64 dmax = std::max(din, dout);
+    graph->net.values[graph->net.cur] = dmax;
+    graph->net.cur = (graph->net.cur + 1) % LoadGraph::NUM_POINTS;
+
+    guint64 new_max;
+    // both way, new_max is the greatest value
+    if (dmax >= graph->net.max)
+        new_max = dmax;
+    else
+        new_max = *std::max_element(&graph->net.values[0],
+                                    &graph->net.values[LoadGraph::NUM_POINTS]);
+
+    //
+    // Round network maximum
+    //
+
+    const guint64 bak_max(new_max);
+
+    if (ProcData::get_instance()->config.network_in_bits) {
+        // nice number is for the ticks
+        unsigned ticks = graph->num_bars();
+
+        // gets messy at low values due to division by 8
+        guint64 bit_max = std::max( new_max*8, G_GUINT64_CONSTANT(10000) );
+
+        // our tick size leads to max
+        double d = nicenum(bit_max/ticks, 0);
+        bit_max = ticks * d;
+        new_max = bit_max / 8;
+
+        procman_debug("bak*8 %" G_GUINT64_FORMAT ", ticks %d, d %f"
+                      ", bit_max %" G_GUINT64_FORMAT ", new_max %" G_GUINT64_FORMAT,
+                      bak_max*8, ticks, d, bit_max, new_max );
+    } else {
+        // round up to get some extra space
+        // yes, it can overflow
+        new_max = 1.1 * new_max;
+        // make sure max is not 0 to avoid / 0
+        // default to 1 KiB
+        new_max = std::max(new_max, G_GUINT64_CONSTANT(1024));
+
+        // decompose new_max = coef10 * 2**(base10 * 10)
+        // where coef10 and base10 are integers and coef10 < 2**10
+        //
+        // e.g: ceil(100.5 KiB) = 101 KiB = 101 * 2**(1 * 10)
+        //      where base10 = 1, coef10 = 101, pow2 = 16
+
+        guint64 pow2 = std::floor(log2(new_max));
+        guint64 base10 = pow2 / 10.0;
+        guint64 coef10 = std::ceil(new_max / double(G_GUINT64_CONSTANT(1) << (base10 * 10)));
+        g_assert(new_max <= (coef10 * (G_GUINT64_CONSTANT(1) << (base10 * 10))));
+
+        // then decompose coef10 = x * 10**factor10
+        // where factor10 is integer and x < 10
+        // so we new_max has only 1 significant digit
+
+        guint64 factor10 = std::pow(10.0, std::floor(std::log10(coef10)));
+        coef10 = std::ceil(coef10 / double(factor10)) * factor10;
+
+        // then make coef10 divisible by num_bars
+        if (coef10 % graph->num_bars() != 0)
+            coef10 = coef10 + (graph->num_bars() - coef10 % graph->num_bars());
+        g_assert(coef10 % graph->num_bars() == 0);
+        new_max = coef10 * (G_GUINT64_CONSTANT(1) << guint64(base10 * 10));
+        procman_debug("bak %" G_GUINT64_FORMAT " new_max %" G_GUINT64_FORMAT
+                      "pow2 %" G_GUINT64_FORMAT " coef10 %" G_GUINT64_FORMAT,
+                      bak_max, new_max, pow2, coef10);
+    }
+
+    if (bak_max > new_max) {
+        procman_debug("overflow detected: bak=%" G_GUINT64_FORMAT
+                      " new=%" G_GUINT64_FORMAT,
+                      bak_max, new_max);
+        new_max = bak_max;
+    }
+
+    // if max is the same or has decreased but not so much, don't
+    // do anything to avoid rescaling
+    if ((0.8 * graph->net.max) < new_max && new_max <= graph->net.max)
+        return;
+
+    const double scale = 1.0f * graph->net.max / new_max;
+
+    for (size_t i = 0; i < LoadGraph::NUM_POINTS; i++) {
+        if (graph->data[i][0] >= 0.0f) {
+            graph->data[i][0] *= scale;
+            graph->data[i][1] *= scale;
+        }
+    }
+
+    procman_debug("rescale dmax = %" G_GUINT64_FORMAT
+                  " max = %" G_GUINT64_FORMAT
+                  " new_max = %" G_GUINT64_FORMAT,
+                  dmax, graph->net.max, new_max);
+
+    graph->net.max = new_max;
+
+    // force the graph background to be redrawn now that scale has changed
+    graph->clear_background();
+}
+
+static void
+get_net (LoadGraph *graph)
+{
+    glibtop_netlist netlist;
+    char **ifnames;
+    guint32 i;
+    guint64 in = 0, out = 0;
+#if GLIB_CHECK_VERSION(2,61,2)
+    gint64 time;
+#else
+    GTimeVal time;
+#endif
+    guint64 din, dout;
+
+    ifnames = glibtop_get_netlist(&netlist);
+
+    for (i = 0; i < netlist.number; ++i)
+    {
+        glibtop_netload netload;
+        glibtop_get_netload (&netload, ifnames[i]);
+
+        if (netload.if_flags & (1 << GLIBTOP_IF_FLAGS_LOOPBACK))
+            continue;
+
+        /* Skip interfaces without any IPv4/IPv6 address (or
+         those with only a LINK ipv6 addr) However we need to
+         be able to exclude these while still keeping the
+         value so when they get online (with NetworkManager
+         for example) we don't get a suddent peak.  Once we're
+         able to get this, ignoring down interfaces will be
+         possible too.  */
+        if (not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS6)
+             and netload.scope6 != GLIBTOP_IF_IN6_SCOPE_LINK)
+            and not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS)))
+            continue;
+
+        /* Don't skip interfaces that are down (GLIBTOP_IF_FLAGS_UP)
+           to avoid spikes when they are brought up */
+
+        in  += netload.bytes_in;
+        out += netload.bytes_out;
+    }
+
+    g_strfreev(ifnames);
+
+#if GLIB_CHECK_VERSION(2,61,2)
+    time = g_get_real_time ();
+
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time != 0) {
+        float dtime = (double) (time - graph->net.time) / G_USEC_PER_SEC;
+#else
+    g_get_current_time (&time);
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time.tv_sec != 0) {
+        float dtime;
+        dtime = time.tv_sec - graph->net.time.tv_sec +
+            (double) (time.tv_usec - graph->net.time.tv_usec) / G_USEC_PER_SEC;
+#endif
+        din   = static_cast<guint64>((in  - graph->net.last_in)  / dtime);
+        dout  = static_cast<guint64>((out - graph->net.last_out) / dtime);
+    } else {
+        /* Don't calc anything if new data is less than old (interface
+           removed, counters reset, ...) or if it is the first time */
+        din  = 0;
+        dout = 0;
+    }
+
+    graph->net.last_in  = in;
+    graph->net.last_out = out;
+    graph->net.time     = time;
+
+    net_scale(graph, din, dout);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    g_autofree gchar *str=NULL, *formatted_str=NULL;
+
+    str = g_format_size_full (network_in_bits ? din*8 : din, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? in*8 : in, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in_total), str);
+
+    str = g_format_size_full (network_in_bits ? dout*8 : dout, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? out*8 : out, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out_total), str);
+}
+
+
+/* Updates the load graph when the timeout expires */
+static gboolean
+load_graph_update (gpointer user_data)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(user_data);
+
+    if (graph->render_counter == graph->frames_per_unit - 1) {
+        std::rotate(&graph->data[0], &graph->data[LoadGraph::NUM_POINTS - 1], &graph->data[LoadGraph::NUM_POINTS]);
+
+        switch (graph->type) {
+        case LOAD_GRAPH_CPU:
+            get_load(graph);
+            break;
+        case LOAD_GRAPH_MEM:
+            get_memory(graph);
+            break;
+        case LOAD_GRAPH_NET:
+            get_net(graph);
+            break;
+        default:
+            g_assert_not_reached();
+        }
+    }
+
+    if (graph->draw)
+        load_graph_queue_draw (graph);
+
+    graph->render_counter++;
+
+    if (graph->render_counter >= graph->frames_per_unit)
+        graph->render_counter = 0;
+
+    return TRUE;
+}
+
+
+
+LoadGraph::~LoadGraph()
+{
+  load_graph_stop(this);
+
+  if (timer_index)
+    g_source_remove(timer_index);
+
+  clear_background();
+}
+
+
+
+static gboolean
+load_graph_destroy (GtkWidget *widget, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    delete graph;
+
+    return FALSE;
+}
+
+
+LoadGraph::LoadGraph(guint type)
+  : fontsize(8.0),
+    rmargin(3.5 * fontsize),
+    indent(24.0),
+    n(0),
+    type(type),
+    speed(0),
+    draw_width(0),
+    draw_height(0),
+    render_counter(0),
+    frames_per_unit(10), // this will be changed but needs initialising
+    graph_dely(0),
+    real_draw_height(0),
+    graph_delx(0.0),
+    graph_buffer_offset(0),
+    main_widget(NULL),
+    disp(NULL),
+    background(NULL),
+    timer_index(0),
+    draw(FALSE),
+    mem_color_picker(NULL),
+    swap_color_picker(NULL)
+{
+    LoadGraph * const graph = this;
+
+    // FIXME:
+    // on configure, graph->frames_per_unit = graph->draw_width/(LoadGraph::NUM_POINTS);
+    // knock FRAMES down to 5 until cairo gets faster
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memset(&cpu, 0, sizeof cpu);
+        n = ProcData::get_instance()->config.num_cpus;
+
+        for(guint i = 0; i < G_N_ELEMENTS(labels.cpu); ++i)
+            labels.cpu[i] = gtk_label_new(NULL);
+
+        break;
+
+    case LOAD_GRAPH_MEM:
+        n = 2;
+        labels.memory = gtk_label_new(NULL);
+        labels.swap = gtk_label_new(NULL);
+        break;
+
+    case LOAD_GRAPH_NET:
+        memset(&net, 0, sizeof net);
+        n = 2;
+        net.max = 1;
+        labels.net_in = gtk_label_new(NULL);
+        labels.net_in_total = gtk_label_new(NULL);
+        labels.net_out = gtk_label_new(NULL);
+        labels.net_out_total = gtk_label_new(NULL);
+        break;
+    }
+
+    speed  = ProcData::get_instance()->config.graph_update_interval;
+
+    colors.resize(n);
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memcpy(&colors[0], ProcData::get_instance()->config.cpu_color,
+               n * sizeof colors[0]);
+        break;
+    case LOAD_GRAPH_MEM:
+        colors[0] = ProcData::get_instance()->config.mem_color;
+        colors[1] = ProcData::get_instance()->config.swap_color;
+        mem_color_picker = gsm_color_button_new (&colors[0],
+                                                 GSMCP_TYPE_PIE);
+        swap_color_picker = gsm_color_button_new (&colors[1],
+                                                  GSMCP_TYPE_PIE);
+        break;
+    case LOAD_GRAPH_NET:
+        colors[0] = ProcData::get_instance()->config.net_in_color;
+        colors[1] = ProcData::get_instance()->config.net_out_color;
+        break;
+    }
+
+    timer_index = 0;
+    render_counter = (frames_per_unit - 1);
+    draw = FALSE;
+
+    main_widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+    gtk_widget_set_size_request(main_widget, -1, LoadGraph::GRAPH_MIN_HEIGHT);
+    gtk_widget_show (main_widget);
+
+    disp = gtk_drawing_area_new ();
+    gtk_widget_show (disp);
+    g_signal_connect (G_OBJECT (disp), "draw", G_CALLBACK (load_graph_draw), graph);
+    g_signal_connect (G_OBJECT(disp), "configure_event",
+                      G_CALLBACK (load_graph_configure), graph);
+    g_signal_connect (G_OBJECT(disp), "destroy",
+                      G_CALLBACK (load_graph_destroy), graph);
+
+    gtk_widget_set_events (disp, GDK_EXPOSURE_MASK);
+
+    gtk_box_pack_start (GTK_BOX (main_widget), disp, TRUE, TRUE, 0);
+
+
+    /* Allocate data in a contiguous block */
+    data_block = std::vector<float>(n * LoadGraph::NUM_POINTS, -1.0f);
+
+    for (guint i = 0; i < LoadGraph::NUM_POINTS; ++i)
+        data[i] = &data_block[0] + i * n;
+
+    gtk_widget_show_all (main_widget);
+}
+
+void
+load_graph_start (LoadGraph *graph)
+{
+    if(!graph->timer_index) {
+
+        load_graph_update(graph);
+
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->draw = TRUE;
+}
+
+void
+load_graph_stop (LoadGraph *graph)
+{
+    /* don't draw anymore, but continue to poll */
+    graph->draw = FALSE;
+}
+
+void
+load_graph_change_speed (LoadGraph *graph,
+             guint new_speed)
+{
+    if (graph->speed == new_speed)
+        return;
+
+    graph->speed = new_speed;
+
+    if(graph->timer_index) {
+        g_source_remove (graph->timer_index);
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->clear_background();
+}
+
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *graph)
+{
+    return &graph->labels;
+}
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *graph)
+{
+    return graph->main_widget;
+}
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *graph)
+{
+    return graph->mem_color_picker;
+}
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *graph)
+{
+    return graph->swap_color_picker;
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/8.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/8.html new file mode 100644 index 00000000..6bd78123 --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/8.html @@ -0,0 +1,1075 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
#include <config.h>
+
+#include <gtkmm/messagedialog.h>
+#include <glibmm/regex.h>
+#include <glib/gi18n.h>
+#include <glibtop/procopenfiles.h>
+
+#include <sys/wait.h>
+
+#include <set>
+#include <string>
+#include <sstream>
+#include <iterator>
+
+#include <glibmm/regex.h>
+
+#include "procman.h"
+#include "lsof.h"
+#include "util.h"
+
+
+using std::string;
+
+
+namespace
+{
+
+    class Lsof
+    {
+        Glib::RefPtr<Glib::Regex> re;
+
+        bool matches(const string &filename) const
+        {
+            return this->re->match(filename);
+        }
+
+    public:
+
+        Lsof(const string &pattern, bool caseless)
+        {
+            Glib::RegexCompileFlags flags = static_cast<Glib::RegexCompileFlags>(0);
+
+            if (caseless)
+                flags |= Glib::REGEX_CASELESS;
+
+            this->re = Glib::Regex::create(pattern, flags);
+        }
+
+
+        template<typename OutputIterator>
+        void search(const ProcInfo &info, OutputIterator out) const
+        {
+            glibtop_open_files_entry *entries;
+            glibtop_proc_open_files buf;
+
+            entries = glibtop_get_proc_open_files(&buf, info.pid);
+
+            for (unsigned i = 0; i != buf.number; ++i) {
+                if (entries[i].type & GLIBTOP_FILE_TYPE_FILE) {
+                    const string filename(entries[i].info.file.name);
+                    if (this->matches(filename))
+                        *out++ = filename;
+                }
+            }
+
+            g_free(entries);
+        }
+    };
+
+
+
+    // GUI Stuff
+
+
+    enum ProcmanLsof {
+        PROCMAN_LSOF_COL_SURFACE,
+        PROCMAN_LSOF_COL_PROCESS,
+        PROCMAN_LSOF_COL_PID,
+        PROCMAN_LSOF_COL_FILENAME,
+        PROCMAN_LSOF_NCOLS
+    };
+
+
+    struct GUI {
+
+        GtkListStore *model;
+        GtkEntry *entry;
+        GtkWindow *window;
+        GtkLabel *count;<--- Shadowed declaration
+        ProcData *procdata;
+        bool case_insensitive;
+
+
+        GUI()
+        {
+            procman_debug("New Lsof GUI %p", this);
+        }
+
+
+        ~GUI()
+        {
+            procman_debug("Destroying Lsof GUI %p", this);
+        }
+
+
+        void clear_results()
+        {
+            gtk_list_store_clear(this->model);
+            gtk_label_set_text(this->count, "");
+        }
+
+
+        void clear()
+        {
+            this->clear_results();
+            gtk_entry_set_text(this->entry, "");
+        }
+
+
+        void display_regex_error(const Glib::RegexError& error)
+        {
+            char * msg = g_strdup_printf ("<b>%s</b>\n%s\n%s",
+                                          _("Error"),
+                                          _("'%s' is not a valid Perl regular expression."),
+                                          "%s");
+            std::string message = make_string(g_strdup_printf(msg, this->pattern().c_str(), error.what().c_str()));
+            g_free(msg);
+
+            Gtk::MessageDialog dialog(message,
+                                      true, // use markup
+                                      Gtk::MESSAGE_ERROR,
+                                      Gtk::BUTTONS_OK,
+                                      true); // modal
+            dialog.run();
+        }
+
+
+        void update_count(unsigned count)
+        {
+            std::ostringstream ss;
+            ss << count;
+            string s = ss.str();
+            gtk_label_set_text(this->count, s.c_str());
+        }
+
+
+        string pattern() const
+        {
+            return gtk_entry_get_text(this->entry);
+        }
+
+
+        void search()
+        {
+            typedef std::set<string> MatchSet;
+            typedef MatchSet::const_iterator iterator;
+
+            this->clear_results();
+
+
+            try {
+                Lsof lsof(this->pattern(), this->case_insensitive);
+
+                unsigned count = 0;<--- Shadow variable
+
+                for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it) {
+                    const ProcInfo &info(*it->second);
+
+                    MatchSet matches;
+                    lsof.search(info, std::inserter(matches, matches.begin()));
+                    count += matches.size();
+
+                    for (iterator it(matches.begin()), end(matches.end()); it != end; ++it) {
+                        GtkTreeIter file;
+                        gtk_list_store_append(this->model, &file);
+                        gtk_list_store_set(this->model, &file,
+                                           PROCMAN_LSOF_COL_SURFACE, info.surface,
+                                           PROCMAN_LSOF_COL_PROCESS, info.name,
+                                           PROCMAN_LSOF_COL_PID, info.pid,
+                                           PROCMAN_LSOF_COL_FILENAME, it->c_str(),
+                                           -1);
+                    }
+                }
+
+                this->update_count(count);
+            }
+            catch (Glib::RegexError& error) {
+                this->display_regex_error(error);
+            }
+        }
+
+
+        static void search_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void search_entry_activate(GtkEntry *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void clear_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->clear();
+        }
+
+
+        static void close_button_clicked(GtkButton *, gpointer data)
+        {
+            GUI *gui = static_cast<GUI*>(data);
+            gtk_widget_destroy(GTK_WIDGET(gui->window));
+            delete gui;
+        }
+
+
+        static void case_button_toggled(GtkToggleButton *button, gpointer data)
+        {
+            bool state = gtk_toggle_button_get_active(button);
+            static_cast<GUI*>(data)->case_insensitive = state;
+        }
+
+
+        static gboolean window_delete_event(GtkWidget *, GdkEvent *, gpointer data)
+        {
+            delete static_cast<GUI*>(data);
+            return FALSE;
+        }
+
+    };
+}
+
+
+
+
+void procman_lsof(ProcData *procdata)
+{
+    GtkListStore *model = \
+        gtk_list_store_new(PROCMAN_LSOF_NCOLS,
+                           CAIRO_GOBJECT_TYPE_SURFACE, // PROCMAN_LSOF_COL_SURFACE
+                           G_TYPE_STRING,              // PROCMAN_LSOF_COL_PROCESS
+                           G_TYPE_UINT,                // PROCMAN_LSOF_COL_PID
+                           G_TYPE_STRING               // PROCMAN_LSOF_COL_FILENAME
+        );
+
+    GtkWidget *tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_object_unref(model);
+
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *renderer;
+
+    // SURFACE / PROCESS
+
+    column = gtk_tree_view_column_new();
+
+    renderer = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "surface", PROCMAN_LSOF_COL_SURFACE,
+                                        NULL);
+
+    renderer = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "text", PROCMAN_LSOF_COL_PROCESS,
+                                        NULL);
+
+    gtk_tree_view_column_set_title(column, _("Process"));
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PROCESS);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_column_set_min_width(column, 10);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), PROCMAN_LSOF_COL_PROCESS,
+                                         GTK_SORT_ASCENDING);
+
+
+    // PID
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("PID"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_PID,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PID);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    // FILENAME
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("Filename"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_FILENAME,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_FILENAME);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    GtkWidget *dialog; /* = gtk_dialog_new_with_buttons(_("Search for Open Files"), NULL,
+                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+                                                        NULL); */
+    dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(procdata->app));
+    gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
+    // gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_title(GTK_WINDOW(dialog), _("Search for Open Files"));
+
+    // g_signal_connect(G_OBJECT(dialog), "response",
+    //                           G_CALLBACK(close_dialog), NULL);
+    gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(dialog), 575, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(dialog), 12);
+    GtkWidget *mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_add(GTK_CONTAINER(dialog), mainbox);
+    gtk_box_set_spacing(GTK_BOX(mainbox), 6);
+
+
+    // Label, entry and search button
+
+    GtkWidget *hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), hbox1, FALSE, FALSE, 0);
+
+    GtkWidget *image = gtk_image_new_from_icon_name("edit-find", GTK_ICON_SIZE_DIALOG);
+    gtk_box_pack_start(GTK_BOX(hbox1), image, FALSE, FALSE, 0);
+
+
+    GtkWidget *vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox1), vbox2, TRUE, TRUE, 0);
+
+
+    GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox, TRUE, TRUE, 0);
+    GtkWidget *label = gtk_label_new_with_mnemonic(_("_Name contains:"));
+    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+    GtkWidget *entry = gtk_entry_new();
+
+    gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
+
+    GtkWidget *search_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                         "label", "gtk-find",
+                                                         "use-stock", TRUE,
+                                                         "use-underline", TRUE,
+                                                         NULL));
+
+    gtk_box_pack_start(GTK_BOX(hbox), search_button, FALSE, FALSE, 0);
+
+    GtkWidget *clear_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-clear",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    /* The default accelerator collides with the default close accelerator. */
+    gtk_button_set_label(GTK_BUTTON(clear_button), _("C_lear"));
+    gtk_box_pack_start(GTK_BOX(hbox), clear_button, FALSE, FALSE, 0);
+
+
+    GtkWidget *case_button = gtk_check_button_new_with_mnemonic(_("Case insensitive matching"));
+    GtkWidget *hbox3 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox3), case_button, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox3, FALSE, FALSE, 0);
+
+
+    GtkWidget *results_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), results_box, FALSE, FALSE, 0);
+    GtkWidget *results_label = gtk_label_new_with_mnemonic(_("S_earch results:"));
+    gtk_box_pack_start(GTK_BOX(results_box), results_label, FALSE, FALSE, 0);
+    GtkWidget *count_label = gtk_label_new(NULL);
+    gtk_box_pack_end(GTK_BOX(results_box), count_label, FALSE, FALSE, 0);
+
+    // Scrolled TreeView
+    GtkWidget *scrolled = gtk_scrolled_window_new(NULL, NULL);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
+                                   GTK_POLICY_AUTOMATIC,
+                                   GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled),
+                                        GTK_SHADOW_IN);
+    gtk_container_add(GTK_CONTAINER(scrolled), tree);
+    gtk_box_pack_start(GTK_BOX(mainbox), scrolled, TRUE, TRUE, 0);
+
+    GtkWidget *bottom_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+
+    GtkWidget *close_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-close",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    gtk_box_pack_start(GTK_BOX(mainbox), bottom_box, FALSE, FALSE, 0);
+    gtk_box_pack_end(GTK_BOX(bottom_box), close_button, FALSE, FALSE, 0);
+
+
+    GUI *gui = new GUI; // wil be deleted by the close button or delete-event
+    gui->procdata = procdata;
+    gui->model = model;
+    gui->window = GTK_WINDOW(dialog);
+    gui->entry = GTK_ENTRY(entry);
+    gui->count = GTK_LABEL(count_label);
+
+    g_signal_connect(G_OBJECT(entry), "activate",
+                     G_CALLBACK(GUI::search_entry_activate), gui);
+    g_signal_connect(G_OBJECT(clear_button), "clicked",
+                     G_CALLBACK(GUI::clear_button_clicked), gui);
+    g_signal_connect(G_OBJECT(search_button), "clicked",
+                     G_CALLBACK(GUI::search_button_clicked), gui);
+    g_signal_connect(G_OBJECT(close_button), "clicked",
+                     G_CALLBACK(GUI::close_button_clicked), gui);
+    g_signal_connect(G_OBJECT(case_button), "toggled",
+                     G_CALLBACK(GUI::case_button_toggled), gui);
+    g_signal_connect(G_OBJECT(dialog), "delete-event",
+                     G_CALLBACK(GUI::window_delete_event), gui);
+
+
+    gtk_widget_show_all(dialog);
+}
+
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/9.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/9.html new file mode 100644 index 00000000..b1d95a0b --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/9.html @@ -0,0 +1,1197 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
#include <config.h>
+
+#include <glibtop/procmap.h>
+#include <glibtop/mountlist.h>
+#include <sys/stat.h>
+#include <glib/gi18n.h>
+
+#include <string>
+#include <map>
+#include <sstream>
+#include <iomanip>
+#include <stdexcept>
+
+using std::string;
+
+
+#include "procman.h"
+#include "memmaps.h"
+#include "proctable.h"
+#include "util.h"
+
+
+/* be careful with this enum, you could break the column names */
+enum
+{
+    MMAP_COL_FILENAME,
+    MMAP_COL_VMSTART,
+    MMAP_COL_VMEND,
+    MMAP_COL_VMSZ,
+    MMAP_COL_FLAGS,
+    MMAP_COL_VMOFFSET,
+    MMAP_COL_PRIVATE_CLEAN,
+    MMAP_COL_PRIVATE_DIRTY,
+    MMAP_COL_SHARED_CLEAN,
+    MMAP_COL_SHARED_DIRTY,
+    MMAP_COL_DEVICE,
+    MMAP_COL_INODE,
+    MMAP_COL_MAX
+};
+
+
+namespace
+{
+    class OffsetFormater
+    {
+        string format;
+
+    public:
+
+        void set(const glibtop_map_entry &last_map)
+        {
+            this->format = (last_map.end <= G_MAXUINT32) ? "%08" G_GINT64_MODIFIER "x" : "%016" G_GINT64_MODIFIER "x";
+        }
+
+        string operator()(guint64 v) const
+        {
+            char buffer[17];
+            g_snprintf(buffer, sizeof buffer, this->format.c_str(), v);
+            return buffer;
+        }
+    };
+
+
+    class InodeDevices
+    {
+        typedef std::map<guint16, string> Map;
+        Map devices;
+
+    public:
+
+        void update()
+        {
+            this->devices.clear();
+
+            glibtop_mountlist list;
+            glibtop_mountentry *entries = glibtop_get_mountlist(&list, 1);
+
+            for (unsigned i = 0; i != list.number; ++i) {
+                struct stat buf;
+
+                if (stat(entries[i].devname, &buf) != -1)
+                    this->devices[buf.st_rdev] = entries[i].devname;
+            }
+
+            g_free(entries);
+        }
+
+        string get(guint64 dev64)
+        {
+            if (dev64 == 0)
+                return "";
+
+            guint16 dev = dev64 & 0xffff;
+
+            if (dev != dev64)
+                g_warning("weird device %" G_GINT64_MODIFIER "x", dev64);
+
+            Map::iterator it(this->devices.find(dev));
+
+            if (it != this->devices.end())
+                return it->second;
+
+            guint8 major, minor;
+            major = dev >> 8;
+            minor = dev;
+
+            std::ostringstream out;
+            out << std::hex
+                << std::setfill('0')
+                << std::setw(2) << unsigned(major)
+                << ':'
+                << std::setw(2) << unsigned(minor);
+
+            this->devices[dev] = out.str();
+            return out.str();
+        }
+    };
+
+
+    class MemMapsData
+    {
+    public:
+        guint timer;
+        GtkWidget *tree;
+        GSettings *settings;
+        ProcInfo *info;
+        OffsetFormater format;
+        mutable InodeDevices devices;
+        const char * const schema;
+
+        MemMapsData(GtkWidget *a_tree, GSettings *a_settings)
+            : tree(a_tree),
+            settings(a_settings),
+            schema("memmapstree")
+        {
+            procman_get_tree_state(this->settings, this->tree, this->schema);
+        }
+
+        ~MemMapsData()
+        {
+            procman_save_tree_state(this->settings, this->tree, this->schema);
+        }
+    };
+}
+
+
+struct glibtop_map_entry_cmp
+{
+    bool operator()(const glibtop_map_entry &a, const guint64 start) const
+    {
+        return a.start < start;
+    }
+
+    bool operator()(const guint64 &start, const glibtop_map_entry &a) const
+    {
+        return start < a.start;
+    }
+
+};
+
+
+static void
+update_row(GtkTreeModel *model, GtkTreeIter &row, const MemMapsData &mm, const glibtop_map_entry *memmaps)
+{
+    guint64 size;
+    string filename, device;
+    string vmstart, vmend, vmoffset;
+    char flags[5] = "----";
+
+    size = memmaps->end - memmaps->start;
+
+    if(memmaps->perm & GLIBTOP_MAP_PERM_READ)    flags [0] = 'r';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_WRITE)   flags [1] = 'w';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_EXECUTE) flags [2] = 'x';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_SHARED)  flags [3] = 's';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_PRIVATE) flags [3] = 'p';
+
+    if (memmaps->flags & (1 << GLIBTOP_MAP_ENTRY_FILENAME))
+      filename = memmaps->filename;
+
+    vmstart  = mm.format(memmaps->start);
+    vmend    = mm.format(memmaps->end);
+    vmoffset = mm.format(memmaps->offset);
+    device   = mm.devices.get(memmaps->device);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        MMAP_COL_FILENAME, filename.c_str(),
+                        MMAP_COL_VMSTART, vmstart.c_str(),
+                        MMAP_COL_VMEND, vmend.c_str(),
+                        MMAP_COL_VMSZ, size,
+                        MMAP_COL_FLAGS, flags,
+                        MMAP_COL_VMOFFSET, vmoffset.c_str(),
+                        MMAP_COL_PRIVATE_CLEAN, memmaps->private_clean,
+                        MMAP_COL_PRIVATE_DIRTY, memmaps->private_dirty,
+                        MMAP_COL_SHARED_CLEAN, memmaps->shared_clean,
+                        MMAP_COL_SHARED_DIRTY, memmaps->shared_dirty,
+                        MMAP_COL_DEVICE, device.c_str(),
+                        MMAP_COL_INODE, memmaps->inode,
+                        -1);
+}
+
+
+
+
+static void
+update_memmaps_dialog (MemMapsData *mmdata)
+{
+    GtkTreeModel *model;
+    glibtop_map_entry *memmaps;
+    glibtop_proc_map procmap;
+
+    memmaps = glibtop_get_proc_map (&procmap, mmdata->info->pid);
+    /* process has disappeared */
+    if(!memmaps or procmap.number == 0) return;
+
+    mmdata->format.set(memmaps[procmap.number - 1]);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+
+    GtkTreeIter iter;<--- Shadowed declaration
+
+    typedef std::map<guint64, GtkTreeIter> IterCache;
+    IterCache iter_cache;
+
+    /*
+      removes the old maps and
+      also fills a cache of start -> iter in order to speed
+      up add
+    */
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        while (true) {
+            char *vmstart = 0;
+            guint64 start;
+            gtk_tree_model_get(model, &iter,
+                               MMAP_COL_VMSTART, &vmstart,
+                               -1);
+
+            try {
+                std::istringstream(vmstart) >> std::hex >> start;
+            } catch (std::logic_error &e) {
+                g_warning("Could not parse %s", vmstart);
+                start = 0;
+            }
+
+            g_free(vmstart);
+
+            bool found = std::binary_search(memmaps, memmaps + procmap.number,
+                                            start, glibtop_map_entry_cmp());
+
+            if (found) {
+                iter_cache[start] = iter;
+                if (!gtk_tree_model_iter_next(model, &iter))
+                    break;
+            } else {
+                if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                    break;
+            }
+        }
+    }
+
+    mmdata->devices.update();
+
+    /*
+      add the new maps
+    */
+
+    for (guint i = 0; i != procmap.number; i++) {
+        GtkTreeIter iter;<--- Shadow variable
+        IterCache::iterator it(iter_cache.find(memmaps[i].start));
+
+        if (it != iter_cache.end())
+            iter = it->second;
+        else
+            gtk_list_store_prepend(GTK_LIST_STORE(model), &iter);
+
+        update_row(model, iter, *mmdata, &memmaps[i]);
+    }
+
+    g_free (memmaps);
+}
+
+
+
+static void
+dialog_response (GtkDialog * dialog, gint response_id, gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+
+    g_source_remove (mmdata->timer);
+
+    delete mmdata;
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+
+static MemMapsData*
+create_memmapsdata (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Filename"),
+        // xgettext: virtual memory start
+        N_("VM Start"),
+        // xgettext: virtual memory end
+        N_("VM End"),
+        // xgettext: virtual memory syze
+        N_("VM Size"),
+        N_("Flags"),
+        // xgettext: virtual memory offset
+        N_("VM Offset"),
+        // xgettext: memory that has not been modified since
+        // it has been allocated
+        N_("Private clean"),
+        // xgettext: memory that has been modified since it
+        // has been allocated
+        N_("Private dirty"),
+        // xgettext: shared memory that has not been modified
+        // since it has been allocated
+        N_("Shared clean"),
+        // xgettext: shared memory that has been modified
+        // since it has been allocated
+        N_("Shared dirty"),
+        N_("Device"),
+        N_("Inode")
+    };
+
+    model = gtk_list_store_new (MMAP_COL_MAX,
+                                G_TYPE_STRING, /* MMAP_COL_FILENAME  */
+                                G_TYPE_STRING, /* MMAP_COL_VMSTART     */
+                                G_TYPE_STRING, /* MMAP_COL_VMEND     */
+                                G_TYPE_UINT64, /* MMAP_COL_VMSZ     */
+                                G_TYPE_STRING, /* MMAP_COL_FLAGS     */
+                                G_TYPE_STRING, /* MMAP_COL_VMOFFSET  */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_DIRTY */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_DIRTY */
+                                G_TYPE_STRING, /* MMAP_COL_DEVICE     */
+                                G_TYPE_UINT64 /* MMAP_COL_INODE     */
+                                );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < MMAP_COL_MAX; i++) {
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(tree), col);
+
+        switch (i) {
+            case MMAP_COL_PRIVATE_CLEAN:
+            case MMAP_COL_PRIVATE_DIRTY:
+            case MMAP_COL_SHARED_CLEAN:
+            case MMAP_COL_SHARED_DIRTY:
+            case MMAP_COL_VMSZ:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                         &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+                break;
+        }
+
+
+        switch (i) {
+            case MMAP_COL_VMSTART:
+            case MMAP_COL_VMEND:
+            case MMAP_COL_FLAGS:
+            case MMAP_COL_VMOFFSET:
+            case MMAP_COL_DEVICE:
+                g_object_set(cell, "family", "monospace", NULL);
+                break;
+        }
+    }
+
+    return new MemMapsData(tree, procdata->settings);
+}
+
+
+static gboolean
+memmaps_timer (gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+    g_assert(model);
+
+    update_memmaps_dialog (mmdata);
+
+    return TRUE;
+}
+
+
+static void
+create_single_memmaps_dialog (GtkTreeModel *model, GtkTreePath *path,
+                              GtkTreeIter *iter, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    MemMapsData *mmdata;
+    GtkWidget *memmapsdialog;
+    GtkWidget *dialog_vbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    ProcInfo *info;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    mmdata = create_memmapsdata (procdata);
+    mmdata->info = info;
+
+    memmapsdialog = gtk_dialog_new_with_buttons (_("Memory Maps"), GTK_WINDOW (procdata->app),
+                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                 "gtk-close", GTK_RESPONSE_CLOSE,
+                                                 NULL);
+    gtk_window_set_resizable(GTK_WINDOW(memmapsdialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(memmapsdialog), 620, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(memmapsdialog), 5);
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG(memmapsdialog));
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Memory maps for process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), label, FALSE, TRUE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    gtk_container_add (GTK_CONTAINER (scrolled), mmdata->tree);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), mmdata->tree);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+
+    g_signal_connect(G_OBJECT(memmapsdialog), "response",
+                              G_CALLBACK(dialog_response), mmdata);
+
+    gtk_widget_show_all (memmapsdialog);
+
+    mmdata->timer = g_timeout_add_seconds (5, memmaps_timer, mmdata);
+
+    update_memmaps_dialog (mmdata);
+}
+
+
+void
+create_memmaps_dialog (ProcData *procdata)
+{
+    /* TODO: do we really want to open multiple dialogs ? */
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_memmaps_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/index.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/index.html new file mode 100644 index 00000000..02bb6ffc --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/index.html @@ -0,0 +1,323 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/cgroups.cpp
27variableScope398styleThe scope of the variable 'paren_offset' can be reduced.
27variableScope398styleThe scope of the variable 'off' can be reduced.
27variableScope398styleThe scope of the variable 'tmp_size' can be reduced.
55cstyleCast398styleC-style pointer casting
src/disks.cpp
202redundantAssignment563styleVariable 'res' is reassigned a value before the old one has been used.
src/gsm_color_button.c
648variableScope398styleThe scope of the variable 'color_chooser' can be reduced.
src/interface.cpp
452cstyleCast398styleC-style pointer casting
454cstyleCast398styleC-style pointer casting
src/load-graph.cpp
41shadowVariable398styleLocal variable 'n' shadows outer variable
164shadowVariable398styleLocal variable 'i' shadows outer variable
src/load-graph.h
36noExplicitConstructor398styleStruct 'LoadGraph' has a constructor with 1 argument that is not explicit.
src/lsof.cpp
164shadowVariable398styleLocal variable 'count' shadows outer variable
src/memmaps.cpp
269shadowVariable398styleLocal variable 'iter' shadows outer variable
src/msm-resources.c
9unusedStructMember563styleunion member 'Anonymous0::alignment' is never used.
9unusedStructMember563styleunion member 'Anonymous0::ptr' is never used.
src/openfiles.cpp
73nullPointerRedundantCheck476warningEither the condition 'res' is redundant or there is possible null pointer dereference: res.
205shadowVariable398styleLocal variable 'openfiles' shadows outer variable
247variableScope398styleThe scope of the variable 'column' can be reduced.
248variableScope398styleThe scope of the variable 'cell' can be reduced.
src/prettytable.h
39unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_opened'
40unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_closed'
src/procdialogs.cpp
294noExplicitConstructor398styleClass 'SpinButtonUpdater' has a constructor with 1 argument that is not explicit.
415shadowVariable398styleLocal variable 'column' shadows outer variable
475cstyleCast398styleC-style pointer casting
498cstyleCast398styleC-style pointer casting
513cstyleCast398styleC-style pointer casting
src/procman-app.cpp
348uninitMemberVar398warningMember variable 'ProcmanApp::procdata' is not initialized in the constructor.
src/procman.cpp
34uninitMemberVarPrivate398warningMember variable 'ProcData::uimanager' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::action_group' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::statusbar' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::loadavg' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::endprocessbutton' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::popup_menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::disk_list' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::notebook' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::config' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::selection' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::settings' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::app' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::frequency' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::smooth_refresh' is not initialized in the constructor.
112shadowVariable398styleLocal variable 'order' shadows outer variable
162shadowVariable398styleLocal variable 'order' shadows outer variable
src/procman.h
103uninitMemberVar398warningMember variable 'MutableProcInfo::cgroup_name' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::unit' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::session' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::seat' is not initialized in the constructor.
173noExplicitConstructor398styleClass 'ProcInfo' has a constructor with 1 argument that is not explicit.
src/procproperties.cpp
208variableScope398styleThe scope of the variable 'column' can be reduced.
209variableScope398styleThe scope of the variable 'cell' can be reduced.
src/proctable.cpp
920shadowVariable398styleLocal variable 'arguments' shadows outer variable
929shadowVariable398styleLocal variable 'tooltip' shadows outer variable
1016shadowVariable398styleLocal variable 'it' shadows outer variable
1022shadowVariable398styleLocal variable 'it' shadows outer variable
1068shadowVariable398styleLocal variable 'it' shadows outer variable
1073shadowVariable398styleLocal variable 'it' shadows outer variable
src/selinux.cpp
21varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
src/smooth_refresh.h
22noExplicitConstructor398styleClass 'SmoothRefresh' has a constructor with 1 argument that is not explicit.
src/sysinfo.cpp
126unusedPrivateFunction398styleUnused private function: 'SysInfo::get_os_type'
233cstyleCast398styleC-style pointer casting
343cstyleCast398styleC-style pointer casting
509uninitMemberVar398warningMember variable 'LSBSysInfo::lsb_fd' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::name' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::release' is not initialized in the constructor.
515missingOverridestyleThe function 'set_distro_labels' overrides a function in a base class but is not marked with a 'override' specifier.
570shadowVariable398styleLocal variable 'release' shadows outer variable
615unusedPrivateFunction398styleUnused private function: 'LSBSysInfo::sync_lsb_release'
626variableScope398styleThe scope of the variable 'codename' can be reduced.
626shadowVariable398styleLocal variable 'release' shadows outer variable
690stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
697stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
701stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
736variableScope398styleThe scope of the variable 'len' can be reduced.
738stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
1001unreadVariable563styleVariable 'table_count' is assigned a value that is never used.
+
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/stats.html b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/stats.html new file mode 100644 index 00000000..aa8922ed --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/stats.html @@ -0,0 +1,189 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+

Top 10 files for warning severity, total findings: 24
+   15  src/procman.cpp
+   4   src/procman.h
+   3   src/sysinfo.cpp
+   1   src/procman-app.cpp
+   1   src/openfiles.cpp
+

+

Top 10 files for portability severity, total findings: 1
+   1  src/selinux.cpp
+

+

Top 10 files for performance severity, total findings: 4
+   4  src/sysinfo.cpp
+

+

Top 10 files for style severity, total findings: 47
+   10  src/sysinfo.cpp
+   6   src/proctable.cpp
+   5   src/procdialogs.cpp
+   4   src/cgroups.cpp
+   3   src/openfiles.cpp
+   2   src/procproperties.cpp
+   2   src/procman.cpp
+   2   src/prettytable.h
+   2   src/msm-resources.c
+   2   src/load-graph.cpp
+

+ +
+ +
+ + diff --git a/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/style.css b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/style.css new file mode 100644 index 00000000..3897bfaf --- /dev/null +++ b/2023-09-11-094648-2277-cppcheck@4954edb594c8_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-09-11-112139-6130-1@3d354f8f4fd2_master/index.html b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/index.html new file mode 100644 index 00000000..a927ad1f --- /dev/null +++ b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/index.html @@ -0,0 +1,136 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@0ddd94b1b9c0
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 16.0.6 (Fedora 16.0.6-2.fc38) +
Date:Mon Sep 11 11:21:39 2023
+

Bug Summary

+ + + + + + + +
Bug TypeQuantityDisplay?
All Bugs14
Logic error
Use of identical expressions1
Unused code
Dead assignment1
Unreachable code12
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
Unused codeDead assignmentrootdir/src/disks.cppget_mount_opt2011View Report
Unused codeUnreachable coderootdir/src/procman-app.cppon_command_line3811View Report
Unused codeUnreachable coderootdir/src/util.cppio_rate_cell_data_func4941View Report
Unused codeUnreachable coderootdir/src/util.cppstatus_cell_data_func5911View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_gicon421View Report
Unused codeUnreachable coderootdir/src/util.cppduration_cell_data_func5351View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_na_cell_data_func3841View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_na_cell_data_func4561View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_cell_data_func4221View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_icon131View Report
Unused codeUnreachable coderootdir/src/util.cpptime_cell_data_func5641View Report
Unused codeUnreachable coderootdir/src/procman-app.cpptimeouts_changed_cb1511View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_cell_data_func3501View Report
Logic errorUse of identical expressionsusr/include/sigc++-2.0/sigc++/visit_each.hoperator()981View Report
+ + diff --git a/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-22e004.html b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-22e004.html new file mode 100644 index 00000000..21d1d9e3 --- /dev/null +++ b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-22e004.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 381, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-112139-6130-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
This statement is never executed
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-491eb3.html b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-491eb3.html new file mode 100644 index 00000000..df332be5 --- /dev/null +++ b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-491eb3.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 494, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-112139-6130-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-4d889d.html b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-4d889d.html new file mode 100644 index 00000000..caaae02f --- /dev/null +++ b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-4d889d.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 591, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-112139-6130-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-633ebf.html b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-633ebf.html new file mode 100644 index 00000000..ff295aca --- /dev/null +++ b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-633ebf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 42, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-112139-6130-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
This statement is never executed
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-6c54e6.html b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-6c54e6.html new file mode 100644 index 00000000..66eb7ab8 --- /dev/null +++ b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-6c54e6.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 535, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-112139-6130-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-6c8186.html b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-6c8186.html new file mode 100644 index 00000000..2a272293 --- /dev/null +++ b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-6c8186.html @@ -0,0 +1,886 @@ + + + +/usr/include/sigc++-2.0/sigc++/visit_each.h + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:usr/include/sigc++-2.0/sigc++/visit_each.h
Warning:line 98, column 64
identical expressions on both sides of logical operator
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-112139-6130-1 -x c++ procman.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright 2002, The libsigc++ Development Team
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18#ifndef _SIGC_VISIT_EACH_HPP_
19#define _SIGC_VISIT_EACH_HPP_
20
21#include <sigc++/type_traits.h>
22#include <type_traits>
23
24namespace sigc {
25
26#ifndef DOXYGEN_SHOULD_SKIP_THIS
27namespace internal {
28
29//This should really be an inner class of limit_derived_target, without the T_limit template type,
30//But the SUN CC 5.7 (not earlier versions) compiler finds it ambiguous when we specify a particular specialization of it.
31//and does not seem to allow us to tell it explicitly that it's an inner class.
32template <bool I_derived, class T_type, class T_limit>
33struct with_type;
34
35//Specialization for I_derived = false
36template <class T_type, class T_limit> struct
37with_type<false, T_type, T_limit>
38{
39 static void execute_(const T_type&, const T_limit&) {}
40};
41
42//Specialization for I_derived = true
43template <class T_type, class T_limit>
44struct with_type<true, T_type, T_limit>
45{
46 static void execute_(const T_type& _A_type, const T_limit& _A_action)
47 { _A_action.action_(_A_type); }
48};
49
50
51/// Helper struct for visit_each_type().
52template <class T_target, class T_action>
53struct limit_derived_target
54{
55 typedef limit_derived_target<T_target, T_action> T_self;
56
57 template <class T_type>
58 void operator()(const T_type& _A_type) const
59 {
60 with_type<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
61 }
62
63 limit_derived_target(const T_action& _A_action)
64 : action_(_A_action)
65 {}
66
67 T_action action_;
68};
69
70// Specialization for T_target pointer types, to provide a slightly different execute_() implementation.
71
72template <bool I_derived, class T_type, class T_limit>
73struct with_type_pointer;
74
75//Specialization for I_derived = false
76template <class T_type, class T_limit>
77struct with_type_pointer<false, T_type, T_limit>
78{
79 static void execute_(const T_type&, const T_limit&) {}
80};
81
82//Specialization for I_derived = true
83template <class T_type, class T_limit>
84struct with_type_pointer<true, T_type, T_limit>
85{
86 static void execute_(const T_type& _A_type, const T_limit& _A_action)
87 { _A_action.action_(&_A_type); }
88};
89
90template <class T_target, class T_action>
91struct limit_derived_target<T_target*, T_action>
92{
93 typedef limit_derived_target<T_target*, T_action> T_self;
94
95 template <class T_type>
96 void operator()(const T_type& _A_type) const
97 {
98 with_type_pointer<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
identical expressions on both sides of logical operator
99 }
100
101 limit_derived_target(const T_action& _A_action)
102 : action_(_A_action)
103 {}
104
105 T_action action_;
106};
107
108} /* namespace internal */
109#endif // DOXYGEN_SHOULD_SKIP_THIS
110
111// struct visitor was introduced as a result of https://bugzilla.gnome.org/show_bug.cgi?id=724496
112// The advantage of using specializations of a template struct instead of overloads of
113// a template function is described by Herb Sutter in http://www.gotw.ca/publications/mill17.htm
114// In libsigc++ the main reason for using this technique is that we can avoid using ADL
115// (argument-dependent lookup), and therefore there is no risk that a visit_each() overload
116// in e.g. Boost is selected by mistake.
117
118/** sigc::visitor<T_functor>::do_visit_each() performs a functor on each of the targets of a functor.
119 * All unknown types just call @a _A_action on them.
120 * Add specializations that specialize the @a T_functor argument for your own
121 * functor types, so that subobjects get visited. This is needed to enable
122 * auto-disconnection support for your functor types.
123 *
124 * @par Example:
125 * @code
126 * namespace some_ns
127 * {
128 * struct some_functor
129 * {
130 * void operator()() {}
131 * some_possibly_sigc_trackable_derived_type some_data_member;
132 * some_other_functor_type some_other_functor;
133 * };
134 * }
135 *
136 * namespace sigc
137 * {
138 * template <>
139 * struct visitor<some_ns::some_functor>
140 * {
141 * template <class T_action>
142 * static void do_visit_each(const T_action& _A_action,
143 * const some_ns::some_functor& _A_target)
144 * {
145 * sigc::visit_each(_A_action, _A_target.some_data_member);
146 * sigc::visit_each(_A_action, _A_target.some_other_functor);
147 * }
148 * };
149 * }
150 * @endcode
151 *
152 * @ingroup sigcfunctors
153 */
154template <class T_functor>
155struct visitor
156{
157 template <class T_action>
158 static void do_visit_each(const T_action& _A_action, const T_functor& _A_functor)
159 {
160 _A_action(_A_functor);
161 }
162};
163
164/** This function performs a functor on each of the targets of a functor.
165 *
166 * @ingroup sigcfunctors
167 */
168template <class T_action, class T_functor>
169void visit_each(const T_action& _A_action, const T_functor& _A_functor)
170{ sigc::visitor<T_functor>::do_visit_each(_A_action, _A_functor); }
171
172/** This function performs a functor on each of the targets
173 * of a functor limited to a restricted type.
174 *
175 * @ingroup sigcfunctors
176 */
177template <class T_type, class T_action, class T_functor>
178void visit_each_type(const T_action& _A_action, const T_functor& _A_functor)
179{
180 typedef internal::limit_derived_target<T_type, T_action> type_limited_action;
181
182 type_limited_action limited_action(_A_action);
183
184 //specifying the types of the template specialization prevents disconnection of bound trackable references (such as with std::ref()),
185 //probably because the visit_each<> specializations take various different template types,
186 //in various sequences, and we are probably specifying only a subset of them with this.
187 //
188 //But this is required by the AIX (and maybe IRIX MipsPro and Tru64) compilers.
189 //I guess that std::ref() therefore does not work on those platforms. murrayc
190 // sigc::visit_each<type_limited_action, T_functor>(limited_action, _A_functor);
191
192 //g++ (even slightly old ones) is our primary platform, so we could use the non-crashing version.
193 //However, the explicit version also fixes a crash in a slightly more common case: http://bugzilla.gnome.org/show_bug.cgi?id=169225
194 //Users (and distributors) of libsigc++ on AIX (and maybe IRIX MipsPro and Tru64) do
195 //need to use the version above instead, to allow compilation.
196
197 //Added 2014-03-20: The preceding comment probably does not apply any more,
198 //now when the visit_each<>() overloads have been replaced by visitor<> specializations.
199 //It's probably safe to add explicit template parameters on calls to visit_each(),
200 //visit_each_type() and visitor::do_visit_each(), if necessary.
201
202 sigc::visit_each(limited_action, _A_functor);
203}
204
205} /* namespace sigc */
206#endif
diff --git a/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-77634b.html b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-77634b.html new file mode 100644 index 00000000..cbbdb8fb --- /dev/null +++ b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-77634b.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 384, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-112139-6130-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-7bbc8c.html b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-7bbc8c.html new file mode 100644 index 00000000..711e118a --- /dev/null +++ b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-7bbc8c.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 456, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-112139-6130-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-7ce786.html b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-7ce786.html new file mode 100644 index 00000000..69de4fd3 --- /dev/null +++ b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-7ce786.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 422, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-112139-6130-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-802eaf.html b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-802eaf.html new file mode 100644 index 00000000..659b6d23 --- /dev/null +++ b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-802eaf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 13, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-112139-6130-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
This statement is never executed
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-8e6c9c.html b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-8e6c9c.html new file mode 100644 index 00000000..e06e14c5 --- /dev/null +++ b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-8e6c9c.html @@ -0,0 +1,1200 @@ + + + +disks.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/disks.cpp
Warning:line 201, column 13
Value stored to 'res' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name disks.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-112139-6130-1 -x c++ disks.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#ifdef __linux__1
4#include <mntent.h>
5#endif // __linux__
6
7#include <giomm.h>
8#include <giomm/themedicon.h>
9#include <gtk/gtk.h>
10#include <glibtop/mountlist.h>
11#include <glibtop/fsusage.h>
12#include <glib/gi18n.h>
13
14#include "procman.h"
15#include "disks.h"
16#include "util.h"
17#include "interface.h"
18#include "iconthemewrapper.h"
19
20namespace
21{
22 const unsigned DISK_ICON_SIZE = 24;
23}
24
25enum DiskColumns
26{
27 /* string columns* */
28 DISK_DEVICE,
29 DISK_DIR,
30 DISK_TYPE,
31 DISK_SUBVOLUME,
32 DISK_TOTAL,
33 DISK_FREE,
34 DISK_AVAIL,
35 /* USED has to be the last column */
36 DISK_USED,
37 // then unvisible columns
38 /* Surface column */
39 DISK_ICON,
40 /* numeric columns */
41 DISK_USED_PERCENTAGE,
42 DISK_N_COLUMNS
43};
44
45
46
47static void
48fsusage_stats(const glibtop_fsusage *buf,
49 guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
50 gint *percentage)
51{
52 guint64 total = buf->blocks * buf->block_size;
53
54 if (!total) {
55 /* not a real device */
56 *btotal = *bfree = *bavail = *bused = 0ULL;
57 *percentage = 0;
58 } else {
59 int percent;
60 *btotal = total;
61 *bfree = buf->bfree * buf->block_size;
62 *bavail = buf->bavail * buf->block_size;
63 *bused = *btotal - *bfree;
64 /* percent = 100.0f * *bused / *btotal; */
65 percent = 100 * *bused / (*bused + *bavail);
66 *percentage = CLAMP(percent, 0, 100)(((percent) > (100)) ? (100) : (((percent) < (0)) ? (0)
: (percent)))
;
67 }
68}
69
70
71namespace
72{
73 string get_icon_for_path(const std::string& path)
74 {
75 using namespace Glib;
76 using namespace Gio;
77
78 // FIXME: I don't know whether i should use Volume or Mount or UnixMount
79 // all i need an icon name.
80 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
81
82 std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
83
84 for (size_t i = 0; i != mounts.size(); ++i) {
85 if (mounts[i]->get_name() != path)
86 continue;
87
88 RefPtr<Icon> icon = mounts[i]->get_icon();
89 RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
90
91 if (themed_icon) {
92 char* name = 0;
93 // FIXME: not wrapped yet
94 g_object_get(G_OBJECT(themed_icon->gobj())((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((themed_icon->gobj())), (((GType) ((20) << (2)))
)))))
, "name", &name, NULL__null);
95 return make_string(name);
96 }
97 }
98
99 return "";
100 }
101}
102
103
104static Glib::RefPtr<Gdk::Pixbuf>
105get_icon_for_device(const char *mountpoint)
106{
107 procman::IconThemeWrapper icon_theme;
108 string icon_name = get_icon_for_path(mountpoint);
109 if (icon_name == "")
110 // FIXME: defaults to a safe value
111 icon_name = "drive-harddisk"; // get_icon_for_path("/");
112 return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
113}
114
115
116static gboolean
117find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
118 GtkTreeIter *result)
119{
120 GtkTreeIter iter;
121 gboolean found = FALSE(0);
122
123 if (gtk_tree_model_get_iter_first(model, &iter)) {
124 do {
125 char *dir;
126
127 gtk_tree_model_get(model, &iter,
128 DISK_DIR, &dir,
129 -1);
130
131 if (dir && !strcmp(dir, mountpoint)) {
132 *result = iter;
133 found = TRUE(!(0));
134 }
135
136 g_free(dir);
137
138 } while (!found && gtk_tree_model_iter_next(model, &iter));
139 }
140
141 return found;
142}
143
144
145
146static void
147remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
148{
149 GtkTreeIter iter;
150
151 if (!gtk_tree_model_get_iter_first(model, &iter))
152 return;
153
154 while (true) {
155 char *dir;
156 guint i;
157 gboolean found = FALSE(0);
158
159 gtk_tree_model_get(model, &iter,
160 DISK_DIR, &dir,
161 -1);
162
163 for (i = 0; i != n; ++i) {
164 if (!strcmp(dir, entries[i].mountdir)) {
165 found = TRUE(!(0));
166 break;
167 }
168 }
169
170 g_free(dir);
171
172 if (!found) {
173 if (!gtk_list_store_remove(GTK_LIST_STORE(model)((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_list_store_get_type ()))))))
, &iter))
174 break;
175 else
176 continue;
177 }
178
179 if (!gtk_tree_model_iter_next(model, &iter))
180 break;
181 }
182}
183
184#ifdef __linux__1
185static char *
186get_mount_opt(const glibtop_mountentry *entry, const char* opt)
187{
188 char *opt_value = NULL__null;
189 const struct mntent *mnt;
190 FILE *fp;
191
192 if (!(fp = setmntent(MOUNTED"/etc/mtab", "r"))) {
193 goto out;
194 }
195
196 while ((mnt = getmntent(fp))) {
197 if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
198 (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
199 char *res;
200
201 res = hasmntopt(mnt, "subvol");
Value stored to 'res' is never read
202 if ((res = hasmntopt(mnt, "subvol")) != NULL__null) {
203 char **strs = g_strsplit_set(res, "=", 2);
204
205 if (g_strv_length(strs) == 2) {
206 char *value = strs[1];
207 if (g_strcmp0 (value,"/root") == 0)
208 opt_value = g_strdup("/")g_strdup_inline ("/");
209 else
210 opt_value = g_strdup(strs[1])g_strdup_inline (strs[1]);
211 g_strfreev(strs);
212 }
213 }
214 break;
215 }
216 }
217
218 endmntent(fp);
219
220 out:
221 return opt_value;
222}
223#endif // __linux__
224
225
226static void
227add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
228{
229 Glib::RefPtr<Gdk::Pixbuf> pixbuf;
230 cairo_surface_t *surface;
231 GtkTreeIter iter;
232 glibtop_fsusage usage;
233 guint64 bused, bfree, bavail, btotal;
234 gint percentage;
235#ifdef __linux__1
236 char *subvol = NULL__null;
237#endif // __linux__
238
239 glibtop_get_fsusage(&usage, entry->mountdir);
240
241 if (not show_all_fs and usage.blocks == 0) {
242 if (find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
243 gtk_list_store_remove(list, &iter);
244 return;
245 }
246
247 fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
248#ifdef __linux__1
249 subvol = get_mount_opt(entry, "subvol");
250#endif // __linux__
251 pixbuf = get_icon_for_device(entry->mountdir);
252 surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL__null);
253
254 /* if we can find a row with the same mountpoint, we get it but we
255 still need to update all the fields.
256 This makes selection persistent.
257 */
258 if (!find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
259 gtk_list_store_append(list, &iter);
260
261 gtk_list_store_set(list, &iter,
262 DISK_ICON, surface,
263 DISK_DEVICE, entry->devname,
264 DISK_DIR, entry->mountdir,
265 DISK_TYPE, entry->type,
266#ifdef __linux__1
267
268 DISK_SUBVOLUME, subvol != NULL__null ? subvol : "",
269#else
270 DISK_SUBVOLUME, "",
271#endif // __linux__
272 DISK_USED_PERCENTAGE, percentage,
273 DISK_TOTAL, btotal,
274 DISK_FREE, bfree,
275 DISK_AVAIL, bavail,
276 DISK_USED, bused,
277 -1);
278#ifdef __linux__1
279 g_free (subvol);
280#endif // __linux__
281}
282
283
284
285int
286cb_update_disks(gpointer data)
287{
288 ProcData *const procdata = static_cast<ProcData*>(data);
289
290 GtkListStore *list;
291 glibtop_mountentry * entries;
292 glibtop_mountlist mountlist;
293 guint i;
294
295 list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)))((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_tree_view_get_model(((((GtkTreeView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((procdata->disk_list)), ((gtk_tree_view_get_type
()))))))))), ((gtk_list_store_get_type ()))))))
;
296
297 entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
298
299 remove_old_disks(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entries, mountlist.number);
300
301 for (i = 0; i < mountlist.number; i++)
302 add_disk(list, &entries[i], procdata->config.show_all_fs);
303
304 g_free(entries);
305
306 return TRUE(!(0));
307}
308
309
310static void
311cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
312{
313 ProcData * const procdata = static_cast<ProcData*>(user_data);
314
315 procman_save_tree_state(procdata->settings,
316 GTK_WIDGET(treeview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_widget_get_type ()))))))
,
317 "disktreenew");
318}
319
320
321static void
322open_dir(GtkTreeView *tree_view,
323 GtkTreePath *path,
324 GtkTreeViewColumn *column,
325 gpointer user_data)
326{
327 GtkTreeIter iter;
328 GtkTreeModel *model;
329 char *dir, *url;
330
331 model = gtk_tree_view_get_model(tree_view);
332
333 if (!gtk_tree_model_get_iter(model, &iter, path)) {
334 char *p;
335 p = gtk_tree_path_to_string(path);
336 g_warning("Cannot get iter for path '%s'\n", p);
337 g_free(p);
338 return;
339 }
340
341 gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
342
343 url = g_strdup_printf("file://%s", dir);
344
345 GError* error = 0;
346 if (!g_app_info_launch_default_for_uri(url, NULL__null, &error)) {
347 g_warning("Cannot open '%s' : %s\n", url, error->message);
348 g_error_free(error);
349 }
350
351 g_free(url);
352 g_free(dir);
353}
354
355static guint timeout_id = 0;
356static GtkTreeViewColumn *current_column;
357
358static gboolean
359save_column_width (gpointer data)
360{
361 gint width;
362 gchar *key;
363 int id;
364 GSettings *settings;
365
366 settings = g_settings_get_child (G_SETTINGS (data)((((GSettings*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((g_settings_get_type ()))))))
, "disktreenew");
367 id = gtk_tree_view_column_get_sort_column_id (current_column);
368 width = gtk_tree_view_column_get_width (current_column);
369
370 key = g_strdup_printf ("col-%d-width", id);
371 g_settings_set_int(settings, key, width);
372 g_free (key);
373
374 if (timeout_id) {
375 g_source_remove (timeout_id);
376 timeout_id = 0;
377 }
378
379 return FALSE(0);
380}
381
382static void
383cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
384{
385 current_column = GTK_TREE_VIEW_COLUMN(widget)((((GtkTreeViewColumn*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((widget)), ((gtk_tree_view_column_get_type (
)))))))
;
386
387 if (timeout_id)
388 g_source_remove (timeout_id);
389
390 timeout_id = g_timeout_add (250, save_column_width, data);
391}
392
393void
394create_disk_view(ProcData *procdata, GtkBuilder *builder)
395{
396 GtkWidget *scrolled;
397 GtkWidget *disk_tree;
398 GtkListStore *model;
399 GtkTreeViewColumn *col;
400 GtkCellRenderer *cell;
401 guint i;
402
403 const gchar * const titles[] = {
404 N_("Device")("Device"),
405 N_("Directory")("Directory"),
406 N_("Type")("Type"),
407 N_("SubVolume")("SubVolume"),
408 N_("Total")("Total"),
409 N_("Free")("Free"),
410 N_("Available")("Available"),
411 N_("Used")("Used")
412 };
413
414 scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "disks_scrolled"))), ((
gtk_widget_get_type ()))))))
;
415
416 model = gtk_list_store_new(DISK_N_COLUMNS, /* n columns */
417 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DEVICE */
418 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DIR */
419 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_TYPE */
420 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_SUBVOLUME */
421 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_TOTAL */
422 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_FREE */
423 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_AVAIL */
424 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_USED */
425 CAIRO_GOBJECT_TYPE_SURFACEcairo_gobject_surface_get_type (), /* DISK_ICON */
426 G_TYPE_INT((GType) ((6) << (2)))); /* DISK_USED_PERCENTAGE */
427
428 disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_model_get_type ()))))))
);
429 g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("row-activated"), (((GCallback) (open_dir))), (__null
), __null, (GConnectFlags) 0)
;
430 procdata->disk_list = disk_tree;
431 gtk_container_add(GTK_CONTAINER(scrolled)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((scrolled)), ((gtk_container_get_type ()))))))
, disk_tree);
432 g_object_unref(G_OBJECT(model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
);
433
434 /* icon + device */
435
436 col = gtk_tree_view_column_new();
437 cell = gtk_cell_renderer_pixbuf_new();
438 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
439 gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
440 NULL__null);
441
442 cell = gtk_cell_renderer_text_new();
443 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
444 gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
445 NULL__null);
446 gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE])gettext (titles[DISK_DEVICE]));
447 gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
448 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
449 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
450 gtk_tree_view_column_set_min_width (col, 30);
451 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
452 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
453 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
454
455 /* sizes - used */
456
457 for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
458 cell = gtk_cell_renderer_text_new();
459 col = gtk_tree_view_column_new();
460 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
461 gtk_tree_view_column_set_title(col, _(titles[i])gettext (titles[i]));
462 gtk_tree_view_column_set_sort_column_id(col, i);
463 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
464 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
465 gtk_tree_view_column_set_min_width (col, 30);
466 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
467 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
468 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
469
470 switch (i) {
471 case DISK_TOTAL:
472 case DISK_FREE:
473 case DISK_AVAIL:
474 g_object_set(cell, "xalign", 1.0f, NULL__null);
475 gtk_tree_view_column_set_cell_data_func(col, cell,
476 &procman::storage_size_cell_data_func,
477 GUINT_TO_POINTER(i)((gpointer) (gulong) (i)),
478 NULL__null);
479 break;
480
481 default:
482 gtk_tree_view_column_set_attributes(col, cell,
483 "text", i,
484 NULL__null);
485 break;
486 }
487 }
488
489 /* used + percentage */
490
491 col = gtk_tree_view_column_new();
492 cell = gtk_cell_renderer_text_new();
493 g_object_set(cell, "xalign", 1.0f, NULL__null);
494 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
495 gtk_tree_view_column_set_cell_data_func(col, cell,
496 &procman::storage_size_cell_data_func,
497 GUINT_TO_POINTER(DISK_USED)((gpointer) (gulong) (DISK_USED)),
498 NULL__null);
499
500 cell = gtk_cell_renderer_progress_new();
501 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
502 gtk_tree_view_column_set_attributes(col, cell, "value",
503 DISK_USED_PERCENTAGE, NULL__null);
504 gtk_tree_view_column_set_title(col, _(titles[DISK_USED])gettext (titles[DISK_USED]));
505 gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
506 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
507 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
508 gtk_tree_view_column_set_min_width (col, 150);
509 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
510 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
511 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
512
513 /* numeric sort */
514
515 procman_get_tree_state(procdata->settings, disk_tree,
516 "disktreenew");
517
518 g_signal_connect (G_OBJECT(disk_tree), "columns-changed",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
519 G_CALLBACK(cb_disk_columns_changed), procdata)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
;
520}
diff --git a/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-c673b5.html b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-c673b5.html new file mode 100644 index 00000000..f1b7bdff --- /dev/null +++ b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-c673b5.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 564, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-112139-6130-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-d507c5.html b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-d507c5.html new file mode 100644 index 00000000..340543b0 --- /dev/null +++ b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-d507c5.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 151, column 9
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-112139-6130-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
This statement is never executed
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-e8ff80.html b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-e8ff80.html new file mode 100644 index 00000000..77e67eeb --- /dev/null +++ b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/report-e8ff80.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 350, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-09-11-112139-6130-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-09-11-112139-6130-1@3d354f8f4fd2_master/scanview.css b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/scanview.css new file mode 100644 index 00000000..cf8a5a6a --- /dev/null +++ b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/2023-09-11-112139-6130-1@3d354f8f4fd2_master/sorttable.js b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/sorttable.js new file mode 100644 index 00000000..32faa078 --- /dev/null +++ b/2023-09-11-112139-6130-1@3d354f8f4fd2_master/sorttable.js @@ -0,0 +1,492 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse',''); + cell.className = cell.className.replace('sorttable_sorted',''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j=0; j 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } + else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } + else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i=0; i=0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a,b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); + if (isNaN(bb)) bb = 0; + return aa-bb; + }, + sort_alpha: function(a,b) { + if (a[0]==b[0]) return 0; + if (a[0] 0 ) { + var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for(var i = t; i > b; --i) { + if ( comp_func(list[i], list[i-1]) < 0 ) { + var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write(" + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef _PROCMAN_PROCMAN_H_
+#define _PROCMAN_PROCMAN_H_
+
+#include <glibmm/refptr.h>
+#include <cairo-gobject.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+#include <glibtop/cpu.h>
+
+#include <time.h>
+#include <sys/types.h>
+
+#include <map>
+#include <string>
+
+struct ProcInfo;
+struct ProcData;
+struct LoadGraph;
+
+#include "smooth_refresh.h"
+#include "prettytable.h"
+
+#define GSM_GSETTINGS_SCHEMA "org.mate.system-monitor"
+
+enum
+{
+    ALL_PROCESSES,
+    MY_PROCESSES,
+    ACTIVE_PROCESSES
+};
+
+enum
+{
+    VERY_HIGH_PRIORITY,
+    HIGH_PRIORITY,
+    NORMAL_PRIORITY,
+    LOW_PRIORITY,
+    VERY_LOW_PRIORITY,
+    CUSTOM_PRIORITY
+};
+
+static const unsigned MIN_UPDATE_INTERVAL =   1 * 1000;
+static const unsigned MAX_UPDATE_INTERVAL = 100 * 1000;
+
+enum ProcmanTab
+{
+    PROCMAN_TAB_SYSINFO,
+    PROCMAN_TAB_PROCESSES,
+    PROCMAN_TAB_RESOURCES,
+    PROCMAN_TAB_DISKS
+};
+
+struct ProcConfig
+{
+    gint        width;
+    gint        height;
+    gint        xpos;
+    gint        ypos;
+    gboolean    maximized;
+    gboolean    show_kill_warning;
+    gboolean    show_tree;
+    gboolean    show_all_fs;
+    int         update_interval;
+    int         graph_update_interval;
+    int         disks_update_interval;
+    gint        whose_process;
+    gint        current_tab;
+    GdkRGBA     cpu_color[GLIBTOP_NCPU];
+    GdkRGBA     mem_color;
+    GdkRGBA     swap_color;
+    GdkRGBA     net_in_color;
+    GdkRGBA     net_out_color;
+    GdkRGBA     bg_color;
+    GdkRGBA     frame_color;
+    gint        num_cpus;
+    bool solaris_mode;
+    bool network_in_bits;
+};
+
+struct MutableProcInfo
+{
+MutableProcInfo()<--- Member variable 'MutableProcInfo::cgroup_name' is not initialized in the constructor.<--- Member variable 'MutableProcInfo::unit' is not initialized in the constructor.<--- Member variable 'MutableProcInfo::session' is not initialized in the constructor.<--- Member variable 'MutableProcInfo::seat' is not initialized in the constructor.
+  : disk_write_bytes_current(0ULL),
+    disk_read_bytes_current(0ULL),
+    disk_write_bytes_total(0ULL),
+    disk_read_bytes_total(0ULL),
+    status(0U)
+    { }
+
+    std::string user;
+
+    gchar wchan[40];
+
+    // all these members are filled with libgtop which uses
+    // guint64 (to have fixed size data) but we don't need more
+    // than an unsigned long (even for 32bit apps on a 64bit
+    // kernel) as these data are amounts, not offsets.
+    gulong vmsize;
+    gulong memres;
+    gulong memshared;
+    gulong memwritable;
+    gulong mem;
+
+#ifdef HAVE_WNCK
+    // wnck gives an unsigned long
+    gulong memxserver;
+#endif
+
+    gulong start_time;
+    guint64 cpu_time;
+    guint64 disk_write_bytes_current;
+    guint64 disk_read_bytes_current;
+    guint64 disk_write_bytes_total;
+    guint64 disk_read_bytes_total;
+    guint status;
+    guint pcpu;
+    gint nice;
+    gchar *cgroup_name;
+
+    gchar *unit;
+    gchar *session;
+    gchar *seat;
+
+    std::string owner;
+};
+
+class ProcInfo
+: public MutableProcInfo
+{
+    /* undefined */ ProcInfo& operator=(const ProcInfo&);
+    /* undefined */ ProcInfo(const ProcInfo&);
+
+    typedef std::map<guint, std::string> UserMap;
+    /* cached username */
+    static UserMap users;
+
+  public:
+
+    // TODO: use a set instead
+    // sorted by pid. The map has a nice property : it is sorted
+    // by pid so this helps a lot when looking for the parent node
+    // as ppid is nearly always < pid.
+    typedef std::map<pid_t, ProcInfo*> List;
+    typedef List::iterator Iterator;
+
+    static List all;
+
+    static ProcInfo* find(pid_t pid);
+    static Iterator begin() { return ProcInfo::all.begin(); }
+    static Iterator end() { return ProcInfo::all.end(); }
+
+    ProcInfo(pid_t pid);
+    ~ProcInfo();
+    // adds one more ref to icon
+    void set_icon(Glib::RefPtr<Gdk::Pixbuf> icon);
+    void set_user(guint uid);
+    std::string lookup_user(guint uid);
+
+    GtkTreeIter      node;
+    cairo_surface_t *surface;
+    gchar           *tooltip;
+    gchar           *name;
+    gchar           *arguments;
+    gchar           *security_context;
+
+    const pid_t      pid;
+    pid_t            ppid;
+    guint            uid;
+
+// private:
+    // tracks cpu time per process keeps growing because if a
+    // ProcInfo is deleted this does not mean that the process is
+    // not going to be recreated on the next update.  For example,
+    // if dependencies + (My or Active), the proclist is cleared
+    // on each update.  This is a workaround
+    static std::map<pid_t, guint64> cpu_times;
+};
+
+struct ProcData
+{
+    // lazy initialization
+    static ProcData* get_instance();
+
+    GtkUIManager    *uimanager;
+    GtkActionGroup    *action_group;
+    GtkWidget    *statusbar;
+    gint        tip_message_cid;
+    GtkWidget    *tree;
+    GtkWidget    *loadavg;
+    GtkWidget    *endprocessbutton;
+    GtkWidget    *popup_menu;
+    GtkWidget    *disk_list;
+    GtkWidget    *notebook;
+    ProcConfig    config;
+    LoadGraph    *cpu_graph;
+    LoadGraph    *mem_graph;
+    LoadGraph    *net_graph;
+    gint        cpu_label_fixed_width;
+    gint        net_label_fixed_width;
+    ProcInfo    *selected_process;
+    GtkTreeSelection *selection;
+    guint        timeout;
+    guint        disk_timeout;
+
+    PrettyTable    pretty_table;
+
+    GSettings       *settings;
+    GtkWidget        *app;
+    GtkUIManager    *menu;
+
+    unsigned    frequency;
+
+    SmoothRefresh  *smooth_refresh;
+
+    guint64 cpu_total_time;
+    guint64 cpu_total_time_last;
+
+    gboolean terminating;
+
+private:
+    ProcData();
+    /* undefined */ ProcData(const ProcData &);
+    /* undefined */ ProcData& operator=(const ProcData &);
+};
+
+void        procman_save_config (ProcData *data);
+void        procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+gboolean    procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+
+struct ReniceArgs
+{
+    ProcData *procdata;
+    int nice_value;
+};
+
+struct KillArgs
+{
+    ProcData *procdata;
+    int signal;
+};
+
+#endif /* _PROCMAN_PROCMAN_H_ */
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/1.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/1.html new file mode 100644 index 00000000..b83a4070 --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/1.html @@ -0,0 +1,435 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
#ifndef _PROCMAN_SMOOTH_REFRESH
+#define _PROCMAN_SMOOTH_REFRESH
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <string>
+
+using std::string;
+
+class SmoothRefresh
+{
+  public:
+
+    /*
+      smooth_refresh_new
+
+      @config_interval : pointer to config_interval so we can observe
+      config_interval changes.
+
+      @return : initialized SmoothRefresh
+    */
+    SmoothRefresh(GSettings *a_settings);
+
+    ~SmoothRefresh();
+
+    /*
+      smooth_refresh_reset
+
+      Resets state and re-read config_interval
+    */
+    void reset();
+
+    /*
+      smooth_refresh_get
+
+      Computes the new refresh_interval so that CPU usage is lower than
+      SMOOTH_REFRESH_PCPU.
+
+      @new_interval : where the new refresh_interval is stored.
+
+      @return : TRUE is refresh_interval has changed. The new refresh_interval
+      is stored in @new_interval. Else FALSE;
+    */
+    bool get(guint &new_interval);
+
+    static const string KEY;
+    static const bool KEY_DEFAULT_VALUE;
+
+  private:
+
+    unsigned get_own_cpu_usage();
+
+    static void status_changed(GSettings *settings,
+                               const gchar *key,
+                               gpointer user_data);
+
+    void load_settings_value(const gchar *key);
+
+    /*
+      fuzzy logic:
+      - decrease refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_LO
+      - increase refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_HI
+
+    */
+
+    enum
+    {
+        PCPU_HI = 22,
+        PCPU_LO = 18
+    };
+
+    /*
+      -self : procman's PID (so we call getpid() only once)
+
+      -interval : current refresh interval
+
+      -config_interval : pointer to the configuration refresh interval.
+      Used to watch configuration changes
+
+      -interval >= -config_interval
+
+      -last_pcpu : to avoid spikes, the last CPU%. See PCPU_{LO,HI}
+
+      -last_total_time:
+      -last_cpu_time: Save last cpu and process times to compute CPU%
+    */
+
+    GSettings *settings;
+    bool active;
+    guint connection;
+    guint interval;
+    unsigned  last_pcpu;
+    guint64 last_total_time;
+    guint64 last_cpu_time;
+};
+
+#endif /* _PROCMAN_SMOOTH_REFRESH */
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/10.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/10.html new file mode 100644 index 00000000..cb5e0f54 --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/10.html @@ -0,0 +1,1067 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
#include <gio/gio.h>
+
+#if defined (__ELF__) && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
+# define SECTION __attribute__ ((section (".gresource.msm"), aligned (8)))
+#else
+# define SECTION
+#endif
+
+static const SECTION union { const guint8 data[3353]; const double alignment; void * const ptr;}  msm_resource_data = { {<--- union member 'Anonymous0::alignment' is never used.<--- union member 'Anonymous0::ptr' is never used.
+  0107, 0126, 0141, 0162, 0151, 0141, 0156, 0164, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0030, 0000, 0000, 0000, 0310, 0000, 0000, 0000, 0000, 0000, 0000, 0050, 0006, 0000, 0000, 0000, 
+  0000, 0000, 0000, 0000, 0001, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0005, 0000, 0000, 0000, 0376, 0236, 0033, 0101, 0005, 0000, 0000, 0000, 
+  0310, 0000, 0000, 0000, 0024, 0000, 0114, 0000, 0334, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 
+  0113, 0120, 0220, 0013, 0002, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 0004, 0000, 0114, 0000, 
+  0350, 0000, 0000, 0000, 0354, 0000, 0000, 0000, 0324, 0265, 0002, 0000, 0377, 0377, 0377, 0377, 
+  0354, 0000, 0000, 0000, 0001, 0000, 0114, 0000, 0360, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 
+  0173, 0250, 0316, 0037, 0000, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 0014, 0000, 0166, 0000, 
+  0000, 0001, 0000, 0000, 0034, 0006, 0000, 0000, 0234, 0164, 0275, 0021, 0000, 0000, 0000, 0000, 
+  0034, 0006, 0000, 0000, 0016, 0000, 0166, 0000, 0060, 0006, 0000, 0000, 0017, 0015, 0000, 0000, 
+  0201, 0321, 0040, 0031, 0001, 0000, 0000, 0000, 0017, 0015, 0000, 0000, 0005, 0000, 0114, 0000, 
+  0024, 0015, 0000, 0000, 0030, 0015, 0000, 0000, 0155, 0141, 0164, 0145, 0055, 0163, 0171, 0163, 
+  0164, 0145, 0155, 0055, 0155, 0157, 0156, 0151, 0164, 0157, 0162, 0057, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0157, 0162, 0147, 0057, 0005, 0000, 0000, 0000, 0057, 0000, 0000, 0000, 
+  0001, 0000, 0000, 0000, 0151, 0156, 0164, 0145, 0162, 0146, 0141, 0143, 0145, 0056, 0165, 0151, 
+  0242, 0073, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0133, 0133, 0163, 0352, 0066, 
+  0020, 0176, 0317, 0257, 0160, 0375, 0332, 0161, 0010, 0227, 0320, 0164, 0006, 0070, 0323, 0166, 
+  0232, 0364, 0241, 0347, 0114, 0046, 0344, 0114, 0037, 0031, 0331, 0136, 0260, 0212, 0054, 0271, 
+  0222, 0314, 0345, 0337, 0237, 0065, 0066, 0004, 0002, 0370, 0102, 0210, 0061, 0224, 0067, 0154, 
+  0257, 0054, 0355, 0267, 0253, 0335, 0317, 0253, 0245, 0363, 0145, 0346, 0063, 0143, 0002, 0122, 
+  0121, 0301, 0273, 0146, 0375, 0366, 0316, 0064, 0200, 0073, 0302, 0245, 0174, 0324, 0065, 0277, 
+  0277, 0076, 0132, 0017, 0346, 0227, 0336, 0115, 0347, 0047, 0313, 0062, 0236, 0200, 0203, 0044, 
+  0032, 0134, 0143, 0112, 0265, 0147, 0214, 0030, 0161, 0301, 0150, 0336, 0066, 0037, 0156, 0033, 
+  0206, 0145, 0241, 0020, 0345, 0032, 0344, 0220, 0070, 0320, 0353, 0110, 0370, 0057, 0244, 0022, 
+  0224, 0301, 0250, 0335, 0065, 0107, 0172, 0374, 0263, 0371, 0066, 0113, 0363, 0266, 0321, 0062, 
+  0153, 0275, 0216, 0260, 0377, 0005, 0107, 0033, 0016, 0043, 0112, 0165, 0315, 0047, 0075, 0376, 
+  0207, 0162, 0127, 0114, 0115, 0203, 0272, 0135, 0323, 0047, 0224, 0017, 0246, 0361, 0215, 0136, 
+  0047, 0220, 0042, 0000, 0251, 0347, 0006, 0047, 0076, 0164, 0115, 0207, 0160, 0153, 0050, 0234, 
+  0120, 0231, 0275, 0107, 0302, 0024, 0164, 0152, 0113, 0201, 0055, 0121, 0115, 0065, 0003, 0323, 
+  0320, 0222, 0160, 0305, 0210, 0046, 0066, 0303, 0233, 0163, 0300, 0221, 0375, 0271, 0322, 0340, 
+  0033, 0137, 0005, 0247, 0132, 0310, 0224, 0127, 0270, 0060, 0044, 0041, 0323, 0326, 0224, 0272, 
+  0332, 0063, 0173, 0255, 0326, 0135, 0016, 0141, 0017, 0350, 0310, 0323, 0050, 0375, 0353, 0375, 
+  0272, 0264, 0343, 0121, 0346, 0356, 0120, 0375, 0167, 0061, 0133, 0323, 0333, 0306, 0253, 0255, 
+  0067, 0117, 0250, 0242, 0270, 0172, 0263, 0367, 0052, 0303, 0064, 0215, 0013, 0200, 0043, 0044, 
+  0005, 0256, 0211, 0106, 0263, 0230, 0075, 0264, 0217, 0246, 0016, 0141, 0073, 0226, 0033, 0060, 
+  0264, 0252, 0047, 0230, 0013, 0022, 0355, 0126, 0113, 0356, 0356, 0323, 0345, 0233, 0320, 0140, 
+  0013, 0061, 0216, 0025, 0342, 0313, 0253, 0143, 0050, 0224, 0041, 0351, 0023, 0071, 0242, 0334, 
+  0122, 0232, 0110, 0204, 0276, 0336, 0310, 0026, 0005, 0356, 0346, 0023, 0324, 0042, 0170, 0057, 
+  0230, 0151, 0113, 0065, 0127, 0224, 0017, 0105, 0151, 0346, 0364, 0140, 0026, 0220, 0110, 0241, 
+  0214, 0127, 0116, 0162, 0312, 0331, 0102, 0242, 0305, 0227, 0176, 0237, 0212, 0222, 0012, 0210, 
+  0203, 0061, 0143, 0017, 0104, 0251, 0376, 0263, 0373, 0141, 0055, 0206, 0365, 0235, 0264, 0241, 
+  0347, 0101, 0264, 0251, 0211, 0155, 0356, 0000, 0376, 0157, 0142, 0003, 0333, 0204, 0236, 0055, 
+  0156, 0225, 0001, 0176, 0074, 0323, 0376, 0100, 0263, 0076, 0164, 0245, 0034, 0242, 0066, 0106, 
+  0330, 0266, 0243, 0026, 0261, 0255, 0041, 0145, 0154, 0307, 0264, 0265, 0325, 0230, 0254, 0175, 
+  0270, 0362, 0103, 0034, 0354, 0374, 0037, 0234, 0060, 0063, 0234, 0355, 0165, 0332, 0207, 0074, 
+  0373, 0172, 0315, 0275, 0230, 0040, 0356, 0200, 0114, 0106, 0045, 0372, 0227, 0107, 0030, 0035, 
+  0241, 0136, 0213, 0340, 0126, 0310, 0231, 0226, 0100, 0147, 0315, 0020, 0073, 0134, 0306, 0212, 
+  0003, 0241, 0150, 0014, 0360, 0335, 0141, 0136, 0331, 0167, 0244, 0140, 0014, 0334, 0365, 0144, 
+  0037, 0071, 0050, 0050, 0005, 0152, 0240, 0222, 0247, 0145, 0144, 0213, 0143, 0173, 0252, 0362, 
+  0010, 0152, 0144, 0105, 0041, 0312, 0354, 0121, 0236, 0073, 0016, 0236, 0312, 0200, 0365, 0003, 
+  0303, 0112, 0250, 0065, 0016, 0137, 0030, 0016, 0323, 0147, 0142, 0073, 0073, 0276, 0133, 0040, 
+  0054, 0376, 0311, 0135, 0143, 0360, 0034, 0217, 0116, 0131, 0157, 0250, 0300, 0042, 0116, 0264, 
+  0142, 0213, 0004, 0001, 0020, 0174, 0221, 0003, 0331, 0130, 0034, 0337, 0135, 0044, 0070, 0100, 
+  0047, 0240, 0254, 0204, 0342, 0145, 0373, 0127, 0262, 0143, 0021, 0244, 0014, 0375, 0102, 0216, 
+  0036, 0301, 0050, 0337, 0261, 0334, 0123, 0071, 0107, 0043, 0335, 0071, 0062, 0227, 0125, 0314, 
+  0315, 0162, 0347, 0365, 0105, 0052, 0253, 0102, 0122, 0177, 0136, 0206, 0254, 0102, 0306, 0332, 
+  0203, 0312, 0247, 0146, 0177, 0374, 0014, 0273, 0046, 0377, 0242, 0214, 0165, 0077, 0234, 0116, 
+  0020, 0126, 0347, 0373, 0154, 0257, 0116, 0167, 0005, 0011, 0115, 0244, 0125, 0025, 0266, 0325, 
+  0037, 0317, 0337, 0215, 0277, 0250, 0302, 0017, 0362, 0171, 0312, 0370, 0131, 0022, 0131, 0067, 
+  0264, 0044, 0132, 0113, 0212, 0151, 0010, 0324, 0332, 0357, 0144, 0300, 0064, 0376, 0032, 0067, 
+  0046, 0204, 0205, 0013, 0267, 0142, 0156, 0124, 0201, 0250, 0255, 0217, 0071, 0063, 0036, 0265, 
+  0341, 0220, 0043, 0111, 0002, 0357, 0154, 0167, 0371, 0301, 0156, 0336, 0376, 0160, 0255, 0342, 
+  0221, 0211, 0351, 0006, 0222, 0103, 0274, 0121, 0032, 0220, 0223, 0175, 0234, 0076, 0265, 0256, 
+  0161, 0377, 0113, 0332, 0354, 0202, 0205, 0076, 0212, 0056, 0041, 0112, 0013, 0231, 0022, 0331, 
+  0152, 0056, 0101, 0037, 0047, 0137, 0040, 0050, 0201, 0133, 0370, 0300, 0212, 0271, 0112, 0063, 
+  0165, 0311, 0263, 0135, 0103, 0322, 0213, 0010, 0300, 0040, 0146, 0172, 0276, 0160, 0121, 0230, 
+  0013, 0176, 0112, 0056, 0204, 0223, 0044, 0144, 0076, 0235, 0301, 0345, 0246, 0072, 0025, 0045, 
+  0372, 0347, 0032, 0370, 0174, 0360, 0057, 0060, 0023, 0107, 0132, 0125, 0041, 0023, 0177, 0005, 
+  0037, 0223, 0260, 0201, 0206, 0067, 0372, 0123, 0022, 0134, 0263, 0162, 0161, 0347, 0274, 0146, 
+  0345, 0174, 0131, 0071, 0072, 0135, 0302, 0004, 0263, 0310, 0134, 0252, 0333, 0302, 0337, 0230, 
+  0231, 0124, 0167, 0161, 0254, 0264, 0015, 0361, 0223, 0244, 0356, 0033, 0306, 0013, 0227, 0055, 
+  0005, 0337, 0002, 0111, 0070, 0257, 0051, 0066, 0022, 0160, 0273, 0100, 0126, 0157, 0147, 0274, 
+  0324, 0023, 0276, 0030, 0001, 0007, 0261, 0253, 0256, 0221, 0043, 0010, 0051, 0334, 0361, 0145, 
+  0326, 0066, 0163, 0342, 0225, 0122, 0143, 0307, 0005, 0027, 0015, 0115, 0231, 0241, 0205, 0301, 
+  0120, 0133, 0030, 0214, 0210, 0343, 0245, 0223, 0035, 0055, 0202, 0225, 0334, 0201, 0201, 0143, 
+  0063, 0003, 0140, 0240, 0075, 0053, 0370, 0343, 0144, 0361, 0271, 0006, 0250, 0037, 0325, 0000, 
+  0007, 0034, 0111, 0235, 0342, 0341, 0225, 0362, 0136, 0024, 0345, 0255, 0177, 0220, 0125, 0160, 
+  0320, 0027, 0110, 0171, 0043, 0255, 0252, 0100, 0171, 0277, 0201, 0236, 0012, 0071, 0276, 0122, 
+  0335, 0342, 0116, 0171, 0245, 0272, 0173, 0330, 0154, 0073, 0067, 0233, 0215, 0140, 0074, 0031, 
+  0233, 0155, 0345, 0154, 0225, 0151, 0076, 0134, 0062, 0355, 0215, 0217, 0370, 0160, 0252, 0263, 
+  0042, 0137, 0057, 0313, 0125, 0237, 0023, 0377, 0112, 0063, 0203, 0026, 0232, 0260, 0101, 0162, 
+  0336, 0352, 0236, 0225, 0055, 0136, 0243, 0245, 0033, 0057, 0311, 0322, 0253, 0141, 0220, 0372, 
+  0207, 0015, 0242, 0160, 0357, 0237, 0333, 0256, 0350, 0143, 0104, 0377, 0134, 0374, 0357, 0113, 
+  0336, 0020, 0150, 0005, 0175, 0206, 0233, 0241, 0072, 0206, 0070, 0302, 0106, 0300, 0101, 0040, 
+  0267, 0341, 0137, 0034, 0120, 0133, 0121, 0327, 0063, 0050, 0235, 0221, 0045, 0077, 0215, 0322, 
+  0366, 0156, 0112, 0256, 0156, 0154, 0071, 0114, 0334, 0362, 0334, 0070, 0014, 0346, 0337, 0042, 
+  0077, 0360, 0321, 0131, 0336, 0347, 0342, 0200, 0072, 0143, 0220, 0003, 0262, 0172, 0136, 0006, 
+  0244, 0233, 0235, 0007, 0355, 0343, 0065, 0163, 0155, 0300, 0176, 0127, 0071, 0330, 0227, 0241, 
+  0376, 0202, 0101, 0157, 0225, 0016, 0372, 0045, 0026, 0176, 0076, 0122, 0146, 0313, 0255, 0134, 
+  0306, 0262, 0057, 0243, 0050, 0164, 0274, 0126, 0273, 0306, 0061, 0133, 0355, 0242, 0276, 0261, 
+  0052, 0124, 0145, 0136, 0100, 0211, 0120, 0072, 0007, 0167, 0332, 0065, 0112, 0353, 0264, 0033, 
+  0226, 0327, 0150, 0127, 0106, 0143, 0134, 0073, 0317, 0327, 0363, 0256, 0166, 0156, 0227, 0252, 
+  0361, 0265, 0225, 0273, 0102, 0045, 0274, 0002, 0273, 0245, 0171, 0314, 0020, 0062, 0254, 0106, 
+  0004, 0171, 0244, 0014, 0214, 0370, 0137, 0070, 0207, 0006, 0221, 0346, 0261, 0202, 0310, 0231, 
+  0235, 0074, 0364, 0061, 0160, 0204, 0312, 0046, 0062, 0141, 0207, 0253, 0313, 0112, 0237, 0100, 
+  0064, 0076, 0261, 0153, 0054, 0113, 0252, 0170, 0136, 0337, 0276, 0361, 0366, 0117, 0332, 0233, 
+  0037, 0325, 0360, 0311, 0023, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0160, 0162, 0145, 0146, 
+  0145, 0162, 0145, 0156, 0143, 0145, 0163, 0056, 0165, 0151, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0065, 0123, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0134, 0335, 0162, 0342, 0066, 
+  0024, 0276, 0357, 0123, 0250, 0276, 0355, 0050, 0004, 0262, 0155, 0167, 0072, 0301, 0073, 0335, 
+  0335, 0046, 0335, 0231, 0266, 0263, 0323, 0354, 0266, 0227, 0036, 0331, 0076, 0140, 0155, 0204, 
+  0344, 0112, 0002, 0102, 0257, 0372, 0054, 0175, 0264, 0076, 0111, 0217, 0177, 0010, 0140, 0300, 
+  0066, 0004, 0210, 0041, 0334, 0331, 0346, 0110, 0072, 0072, 0377, 0237, 0216, 0206, 0353, 0067, 
+  0017, 0003, 0101, 0106, 0240, 0015, 0127, 0262, 0353, 0264, 0057, 0056, 0035, 0002, 0062, 0120, 
+  0041, 0227, 0375, 0256, 0363, 0371, 0323, 0015, 0175, 0355, 0274, 0161, 0277, 0272, 0376, 0232, 
+  0122, 0162, 0013, 0022, 0064, 0263, 0020, 0222, 0061, 0267, 0021, 0351, 0013, 0026, 0002, 0271, 
+  0272, 0270, 0172, 0175, 0321, 0041, 0224, 0042, 0021, 0227, 0026, 0164, 0217, 0005, 0340, 0136, 
+  0153, 0370, 0153, 0310, 0065, 0030, 0042, 0270, 0337, 0165, 0372, 0366, 0376, 0033, 0147, 0266, 
+  0312, 0325, 0105, 0347, 0225, 0323, 0162, 0257, 0225, 0377, 0005, 0002, 0113, 0002, 0301, 0214, 
+  0351, 0072, 0267, 0366, 0376, 0303, 0200, 0365, 0301, 0041, 0074, 0354, 0072, 0074, 0171, 0154, 
+  0073, 0356, 0165, 0254, 0125, 0014, 0332, 0116, 0210, 0144, 0003, 0350, 0072, 0043, 0156, 0270, 
+  0057, 0300, 0161, 0077, 0351, 0041, 0134, 0267, 0246, 0277, 0056, 0321, 0005, 0114, 0322, 0236, 
+  0012, 0206, 0306, 0161, 0157, 0230, 0060, 0145, 0244, 0074, 0120, 0222, 0046, 0217, 0216, 0073, 
+  0346, 0062, 0124, 0143, 0032, 0010, 0265, 0070, 0242, 0225, 0261, 0132, 0203, 0345, 0316, 0241, 
+  0131, 0216, 0100, 0304, 0324, 0327, 0152, 0154, 0100, 0327, 0143, 0371, 0075, 0147, 0102, 0365, 
+  0063, 0236, 0143, 0015, 0075, 0320, 0250, 0161, 0060, 0136, 0230, 0175, 0177, 0012, 0137, 0276, 
+  0322, 0041, 0150, 0072, 0346, 0241, 0215, 0034, 0367, 0333, 0022, 0112, 0313, 0055, 0212, 0204, 
+  0130, 0315, 0244, 0021, 0314, 0062, 0024, 0120, 0327, 0231, 0000, 0256, 0161, 0067, 0061, 0026, 
+  0006, 0344, 0127, 0045, 0271, 0125, 0232, 0174, 0234, 0161, 0130, 0062, 0135, 0010, 0075, 0066, 
+  0024, 0166, 0272, 0362, 0253, 0313, 0313, 0032, 0304, 0021, 0360, 0176, 0144, 0221, 0272, 0123, 
+  0116, 0155, 0254, 0126, 0023, 0232, 0030, 0075, 0215, 0031, 0262, 0142, 0053, 0125, 0151, 0047, 
+  0061, 0320, 0210, 0047, 0224, 0231, 0124, 0347, 0151, 0203, 0210, 0213, 0220, 0244, 0316, 0042, 
+  0231, 0240, 0351, 0053, 0132, 0211, 0257, 0036, 0234, 0025, 0332, 0172, 0213, 0237, 0123, 0125, 
+  0145, 0023, 0171, 0202, 0115, 0324, 0320, 0076, 0111, 0113, 0003, 0246, 0373, 0134, 0122, 0253, 
+  0342, 0162, 0035, 0345, 0164, 0276, 0262, 0126, 0015, 0312, 0111, 0225, 0346, 0050, 0027, 0146, 
+  0321, 0277, 0035, 0027, 0035, 0335, 0362, 0200, 0211, 0022, 0172, 0023, 0263, 0000, 0103, 0214, 
+  0343, 0166, 0252, 0045, 0303, 0202, 0144, 0132, 0017, 0045, 0317, 0126, 0012, 0150, 0210, 0354, 
+  0311, 0242, 0230, 0026, 0007, 0155, 0040, 0253, 0164, 0321, 0265, 0313, 0144, 0153, 0044, 0076, 
+  0347, 0371, 0331, 0207, 0245, 0311, 0005, 0363, 0101, 0070, 0356, 0317, 0110, 0123, 0042, 0200, 
+  0241, 0001, 0232, 0361, 0110, 0131, 0034, 0003, 0103, 0077, 0010, 0240, 0132, 0165, 0133, 0304, 
+  0222, 0012, 0112, 0015, 0001, 0360, 0021, 0030, 0232, 0173, 0105, 0345, 0200, 0064, 0314, 0071, 
+  0156, 0026, 0355, 0126, 0106, 0034, 0324, 0355, 0075, 0052, 0167, 0151, 0044, 0074, 0304, 0114, 
+  0206, 0325, 0233, 0354, 0161, 0041, 0052, 0331, 0210, 0225, 0341, 0231, 0271, 0055, 0070, 0157, 
+  0353, 0161, 0361, 0126, 0256, 0311, 0072, 0012, 0115, 0003, 0176, 0225, 0106, 0337, 0025, 0263, 
+  0302, 0111, 0252, 0264, 0335, 0004, 0225, 0266, 0313, 0125, 0172, 0140, 0266, 0160, 0021, 0232, 
+  0104, 0164, 0307, 0005, 0031, 0356, 0320, 0044, 0223, 0242, 0112, 0322, 0100, 0211, 0341, 0100, 
+  0232, 0156, 0033, 0237, 0223, 0064, 0216, 0017, 0130, 0115, 0055, 0333, 0353, 0255, 0346, 0141, 
+  0156, 0255, 0012, 0043, 0244, 0264, 0136, 0077, 0371, 0162, 0210, 0162, 0143, 0323, 0350, 0236, 
+  0155, 0211, 0226, 0004, 0371, 0025, 0373, 0373, 0115, 0131, 0360, 0225, 0272, 0317, 0366, 0050, 
+  0247, 0157, 0007, 0360, 0227, 0150, 0152, 0056, 0025, 0164, 0243, 0232, 0164, 0045, 0125, 0120, 
+  0271, 0346, 0073, 0125, 0232, 0307, 0211, 0260, 0016, 0062, 0130, 0254, 0141, 0305, 0344, 0345, 
+  0166, 0160, 0020, 0023, 0330, 0257, 0214, 0332, 0235, 0035, 0132, 0037, 0212, 0162, 0146, 0172, 
+  0355, 0327, 0173, 0021, 0277, 0017, 0021, 0033, 0161, 0245, 0017, 0042, 0373, 0205, 0015, 0175, 
+  0127, 0307, 0227, 0176, 0111, 0063, 0326, 0032, 0236, 0275, 0074, 0237, 0035, 0302, 0152, 0230, 
+  0340, 0175, 0324, 0232, 0261, 0114, 0333, 0022, 0272, 0214, 0243, 0125, 0150, 0340, 0155, 0316, 
+  0164, 0131, 0055, 0211, 0162, 0021, 0100, 0005, 0227, 0100, 0007, 0052, 0134, 0261, 0001, 0146, 
+  0255, 0346, 0230, 0335, 0301, 0314, 0075, 0347, 0243, 0307, 0031, 0010, 0040, 0043, 0046, 0206, 
+  0251, 0135, 0212, 0060, 0301, 0246, 0255, 0371, 0061, 0225, 0371, 0106, 0100, 0317, 0122, 0034, 
+  0301, 0202, 0250, 0020, 0374, 0213, 0300, 0100, 0305, 0253, 0351, 0066, 0115, 0022, 0257, 0066, 
+  0267, 0125, 0317, 0100, 0220, 0071, 0321, 0001, 0064, 0237, 0143, 0207, 0124, 0361, 0025, 0376, 
+  0135, 0151, 0336, 0213, 0042, 0350, 0324, 0316, 0223, 0303, 0070, 0144, 0026, 0274, 0024, 0117, 
+  0240, 0172, 0017, 0227, 0057, 0353, 0006, 0313, 0142, 0236, 0154, 0167, 0266, 0166, 0356, 0307, 
+  0115, 0036, 0316, 0271, 0327, 0073, 0255, 0367, 0071, 0225, 0074, 0231, 0062, 0205, 0017, 0004, 
+  0215, 0117, 0311, 0320, 0374, 0120, 0121, 0100, 0017, 0045, 0246, 0205, 0304, 0225, 0053, 0071, 
+  0035, 0110, 0030, 0050, 0311, 0203, 0044, 0207, 0364, 0001, 0215, 0154, 0205, 0060, 0114, 0314, 
+  0245, 0134, 0163, 0056, 0362, 0014, 0276, 0274, 0244, 0312, 0073, 0344, 0157, 0036, 0207, 0254, 
+  0337, 0302, 0041, 0352, 0040, 0056, 0363, 0071, 0021, 0171, 0063, 0134, 0361, 0277, 0177, 0376, 
+  0055, 0233, 0127, 0360, 0201, 0117, 0223, 0003, 0301, 0102, 0275, 0136, 0074, 0077, 0341, 0175, 
+  0156, 0115, 0241, 0010, 0334, 0114, 0013, 0355, 0335, 0150, 0241, 0121, 0252, 0177, 0027, 0101, 
+  0260, 0200, 0101, 0315, 0100, 0051, 0033, 0125, 0200, 0320, 0125, 0336, 0366, 0223, 0114, 0136, 
+  0210, 0227, 0115, 0100, 0064, 0364, 0064, 0230, 0350, 0070, 0201, 0152, 0025, 0017, 0233, 0205, 
+  0210, 0120, 0263, 0061, 0345, 0062, 0304, 0202, 0321, 0046, 0265, 0132, 0221, 0174, 0077, 0006, 
+  0321, 0336, 0221, 0101, 0004, 0311, 0207, 0055, 0354, 0341, 0107, 0201, 0144, 0304, 0207, 0236, 
+  0322, 0100, 0020, 0261, 0342, 0352, 0104, 0151, 0342, 0335, 0043, 0330, 0115, 0236, 0037, 0203, 
+  0314, 0331, 0104, 0236, 0313, 0104, 0072, 0273, 0212, 0031, 0112, 0060, 0315, 0315, 0026, 0106, 
+  0342, 0275, 0347, 0043, 0036, 0002, 0171, 0367, 0361, 0063, 0031, 0032, 0326, 0007, 0342, 0117, 
+  0322, 0227, 0100, 0015, 0245, 0075, 0133, 0306, 0163, 0131, 0306, 0325, 0163, 0244, 0260, 0166, 
+  0163, 0363, 0346, 0323, 0241, 0172, 0217, 0203, 0010, 0315, 0121, 0036, 0222, 0354, 0010, 0370, 
+  0147, 0022, 0150, 0004, 0062, 0370, 0040, 0061, 0053, 0015, 0322, 0263, 0034, 0162, 0223, 0262, 
+  0125, 0062, 0315, 0227, 0241, 0261, 0274, 0067, 0161, 0334, 0344, 0230, 0266, 0204, 0016, 0060, 
+  0257, 0305, 0206, 0377, 0135, 0171, 0100, 0133, 0175, 0122, 0120, 0030, 0360, 0220, 0237, 0137, 
+  0134, 0236, 0370, 0151, 0302, 0306, 0356, 0324, 0074, 0054, 0135, 0327, 0247, 0052, 0117, 0023, 
+  0267, 0161, 0255, 0324, 0304, 0033, 0341, 0140, 0037, 0063, 0326, 0010, 0367, 0346, 0074, 0315, 
+  0104, 0152, 0054, 0023, 0020, 0056, 0270, 0261, 0173, 0106, 0340, 0126, 0003, 0170, 0271, 0201, 
+  0155, 0352, 0131, 0315, 0302, 0346, 0201, 0126, 0102, 0100, 0370, 0147, 0172, 0047, 0244, 0250, 
+  0170, 0223, 0377, 0172, 0214, 0375, 0011, 0023, 0261, 0344, 0226, 0113, 0326, 0322, 0342, 0262, 
+  0216, 0361, 0177, 0102, 0255, 0376, 0301, 0141, 0116, 0014, 0363, 0172, 0076, 0214, 0020, 0030, 
+  0332, 0245, 0241, 0217, 0063, 0127, 0371, 0010, 0244, 0260, 0230, 0032, 0054, 0121, 0023, 0053, 
+  0130, 0335, 0350, 0137, 0272, 0154, 0140, 0100, 0074, 0236, 0222, 0256, 0224, 0302, 0335, 0043, 
+  0301, 0242, 0105, 0114, 0203, 0052, 0235, 0315, 0320, 0132, 0121, 0102, 0235, 0140, 0041, 0327, 
+  0350, 0105, 0027, 0274, 0234, 0044, 0046, 0217, 0363, 0060, 0337, 0251, 0033, 0340, 0223, 0076, 
+  0133, 0203, 0342, 0372, 0042, 0150, 0257, 0024, 0055, 0316, 0100, 0263, 0036, 0367, 0322, 0312, 
+  0073, 0357, 0112, 0153, 0060, 0152, 0250, 0203, 0163, 0157, 0362, 0171, 0172, 0223, 0063, 0361, 
+  0367, 0065, 0213, 0243, 0146, 0001, 0236, 0047, 0001, 0231, 0342, 0316, 0016, 0331, 0277, 0254, 
+  0271, 0277, 0365, 0176, 0173, 0233, 0262, 0174, 0006, 0071, 0307, 0000, 0162, 0226, 0014, 0255, 
+  0241, 0015, 0323, 0203, 0037, 0063, 0154, 0333, 0200, 0235, 0011, 0264, 0320, 0212, 0075, 0255, 
+  0056, 0354, 0154, 0233, 0347, 0056, 0254, 0273, 0102, 0030, 0307, 0326, 0205, 0135, 0277, 0205, 
+  0163, 0027, 0366, 0324, 0273, 0260, 0076, 0112, 0151, 0233, 0166, 0312, 0135, 0244, 0306, 0104, 
+  0202, 0035, 0053, 0175, 0117, 0114, 0014, 0220, 0100, 0113, 0222, 0314, 0166, 0232, 0275, 0224, 
+  0272, 0301, 0365, 0004, 0032, 0266, 0057, 0247, 0347, 0122, 0271, 0150, 0355, 0033, 0332, 0233, 
+  0301, 0355, 0105, 0350, 0330, 0204, 0334, 0371, 0373, 0224, 0243, 0215, 0254, 0157, 0215, 0170, 
+  0366, 0007, 0312, 0053, 0113, 0332, 0020, 0106, 0374, 0014, 0311, 0237, 0011, 0222, 0117, 0205, 
+  0177, 0074, 0227, 0205, 0213, 0034, 0037, 0025, 0324, 0256, 0161, 0125, 0370, 0014, 0266, 0033, 
+  0003, 0266, 0227, 0114, 0355, 0310, 0301, 0366, 0336, 0100, 0364, 0124, 0120, 0047, 0174, 0215, 
+  0171, 0151, 0213, 0057, 0027, 0076, 0057, 0211, 0342, 0330, 0300, 0363, 0272, 0015, 0234, 0241, 
+  0363, 0251, 0103, 0147, 0046, 0204, 0067, 0325, 0176, 0172, 0167, 0165, 0023, 0000, 0235, 0342, 
+  0147, 0017, 0247, 0040, 0230, 0232, 0201, 0230, 0364, 0117, 0000, 0316, 0330, 0371, 0214, 0235, 
+  0137, 0310, 0175, 0305, 0251, 0343, 0274, 0324, 0333, 0212, 0213, 0373, 0077, 0052, 0334, 0161, 
+  0276, 0323, 0170, 0012, 0056, 0167, 0302, 0067, 0032, 0367, 0350, 0247, 0315, 0271, 0370, 0170, 
+  0063, 0053, 0033, 0236, 0347, 0362, 0143, 0310, 0315, 0175, 0162, 0051, 0116, 0302, 0370, 0144, 
+  0357, 0077, 0116, 0265, 0377, 0242, 0157, 0077, 0256, 0120, 0364, 0013, 0276, 0000, 0231, 0233, 
+  0004, 0115, 0044, 0062, 0102, 0031, 0235, 0357, 0077, 0036, 0305, 0242, 0263, 0126, 0105, 0147, 
+  0227, 0235, 0234, 0004, 0274, 0171, 0071, 0170, 0153, 0114, 0063, 0047, 0115, 0015, 0167, 0313, 
+  0210, 0162, 0133, 0041, 0075, 0245, 0237, 0323, 0314, 0276, 0136, 0315, 0320, 0271, 0247, 0177, 
+  0161, 0232, 0176, 0310, 0341, 0174, 0226, 0120, 0115, 0341, 0235, 0150, 0060, 0261, 0222, 0006, 
+  0127, 0240, 0355, 0166, 0366, 0277, 0207, 0171, 0243, 0036, 0113, 0321, 0171, 0312, 0222, 0201, 
+  0337, 0073, 0356, 0374, 0137, 0175, 0055, 0015, 0154, 0025, 0131, 0230, 0361, 0070, 0373, 0163, 
+  0313, 0257, 0376, 0007, 0112, 0344, 0157, 0105, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0155, 
+  0141, 0164, 0145, 0057, 0000, 0000, 0000, 0000
+} };
+
+static GStaticResource static_resource = { msm_resource_data.data, sizeof (msm_resource_data.data) - 1 /* nul terminator */, NULL, NULL, NULL };
+
+G_MODULE_EXPORT
+GResource *msm_get_resource (void);
+GResource *msm_get_resource (void)
+{
+  return g_static_resource_get_resource (&static_resource);
+}
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GLib Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __G_CONSTRUCTOR_H__
+#define __G_CONSTRUCTOR_H__
+
+/*
+  If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and
+  destructors, in a usable way, including e.g. on library unload. If not you're on
+  your own.
+
+  Some compilers need #pragma to handle this, which does not work with macros,
+  so the way you need to use this is (for constructors):
+
+  #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+  #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(my_constructor)
+  #endif
+  G_DEFINE_CONSTRUCTOR(my_constructor)
+  static void my_constructor(void) {
+   ...
+  }
+
+*/
+
+#ifndef __GTK_DOC_IGNORE__
+
+#if  __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func (void);
+#define G_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func (void);
+
+#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
+/* Visual studio 2008 and later has _Pragma */
+
+/*
+ * Only try to include gslist.h if not already included via glib.h,
+ * so that items using gconstructor.h outside of GLib (such as
+ * GResources) continue to build properly.
+ */
+#ifndef __G_LIB_H__
+#include "gslist.h"
+#endif
+
+#include <stdlib.h>
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* We do some weird things to avoid the constructors being optimized
+ * away on VS2015 if WholeProgramOptimization is enabled. First we
+ * make a reference to the array from the wrapper to make sure its
+ * references. Then we use a pragma to make sure the wrapper function
+ * symbol is always included at the link stage. Also, the symbols
+ * need to be extern (but not dllexport), even though they are not
+ * really used from another object file.
+ */
+
+/* We need to account for differences between the mangling of symbols
+ * for x86 and x64/ARM/ARM64 programs, as symbols on x86 are prefixed
+ * with an underscore but symbols on x64/ARM/ARM64 are not.
+ */
+#ifdef _M_IX86
+#define G_MSVC_SYMBOL_PREFIX "_"
+#else
+#define G_MSVC_SYMBOL_PREFIX ""
+#endif
+
+#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
+#define G_DEFINE_DESTRUCTOR(_func) G_MSVC_DTOR (_func, G_MSVC_SYMBOL_PREFIX)
+
+#define G_MSVC_CTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _wrapper(void) { _func(); g_slist_find (NULL,  _array ## _func); return 0; } \
+  __pragma(comment(linker,"/include:" _sym_prefix # _func "_wrapper")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _wrapper;
+
+#define G_MSVC_DTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _constructor(void) { atexit (_func); g_slist_find (NULL,  _array ## _func); return 0; } \
+   __pragma(comment(linker,"/include:" _sym_prefix # _func "_constructor")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined (_MSC_VER)
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* Pre Visual studio 2008 must use #pragma section */
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _wrapper(void) { _func(); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func ## _wrapper;
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _constructor(void) { atexit (_func); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined(__SUNPRO_C)
+
+/* This is not tested, but i believe it should work, based on:
+ * http://opensource.apple.com/source/OpenSSL098/OpenSSL098-35/src/fips/fips_premain.c
+ */
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  init(_func)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void);
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  fini(_func)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void);
+
+#else
+
+/* constructors not supported for this compiler */
+
+#endif
+
+#endif /* __GTK_DOC_IGNORE__ */
+#endif /* __G_CONSTRUCTOR_H__ */
+
+#ifdef G_HAS_CONSTRUCTORS
+
+#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(msmresource_constructor)
+#endif
+G_DEFINE_CONSTRUCTOR(msmresource_constructor)
+#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(msmresource_destructor)
+#endif
+G_DEFINE_DESTRUCTOR(msmresource_destructor)
+
+#else
+#warning "Constructor not supported on this compiler, linking in resources will not work"
+#endif
+
+static void msmresource_constructor (void)
+{
+  g_static_resource_init (&static_resource);
+}
+
+static void msmresource_destructor (void)
+{
+  g_static_resource_fini (&static_resource);
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/11.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/11.html new file mode 100644 index 00000000..174d418f --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/11.html @@ -0,0 +1,1039 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
#include <config.h>
+
+#include <glib/gi18n.h>
+#include <glibtop/procopenfiles.h>
+#include <sys/stat.h>
+#include <netdb.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include "procman.h"
+#include "openfiles.h"
+#include "proctable.h"
+#include "util.h"
+#include "settings-keys.h"
+
+#ifndef NI_IDN
+#define NI_IDN 0
+#endif
+
+enum
+{
+    COL_FD,
+    COL_TYPE,
+    COL_OBJECT,
+    COL_OPENFILE_STRUCT,
+    NUM_OPENFILES_COL
+};
+
+
+static const char*
+get_type_name(enum glibtop_file_type t)
+{
+    switch(t)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        return _("file");
+    case GLIBTOP_FILE_TYPE_PIPE:
+        return _("pipe");
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+        return _("IPv6 network connection");
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        return _("IPv4 network connection");
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        return _("local socket");
+    default:
+        return _("unknown type");
+    }
+}
+
+
+
+static char *
+friendlier_hostname(const char *addr_str, int port)
+{
+    struct addrinfo hints = { };
+    struct addrinfo *res = NULL;
+    char hostname[NI_MAXHOST];
+    char service[NI_MAXSERV];
+    char port_str[6];
+
+    if (!addr_str[0]) return g_strdup("");
+
+    snprintf(port_str, sizeof port_str, "%d", port);
+
+    hints.ai_family = AF_UNSPEC;
+    hints.ai_socktype = SOCK_STREAM;
+
+    if (getaddrinfo(addr_str, port_str, &hints, &res))
+        goto failsafe;
+
+    if (getnameinfo(res->ai_addr, res->ai_addrlen, hostname,<--- Null pointer dereference
+            sizeof hostname, service, sizeof service, NI_IDN))
+        goto failsafe;
+
+    if (res) freeaddrinfo(res);<--- Assuming that condition 'res' is not redundant
+        return g_strdup_printf("%s, TCP port %d (%s)", hostname, port, service);
+
+  failsafe:
+    if (res) freeaddrinfo(res);
+    return g_strdup_printf("%s, TCP port %d", addr_str, port);
+}
+
+
+
+static void
+add_new_files (gpointer key, gpointer value, gpointer data)
+{
+    glibtop_open_files_entry *openfiles = static_cast<glibtop_open_files_entry*>(value);
+
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreeIter row;
+
+    char *object;
+
+    switch(openfiles->type)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        object = g_strdup(openfiles->info.file.name);
+        break;
+
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        object = friendlier_hostname(openfiles->info.sock.dest_host,
+                         openfiles->info.sock.dest_port);
+        break;
+
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        object = g_strdup(openfiles->info.localsock.name);
+        break;
+
+    default:
+        object = g_strdup("");
+    }
+
+    gtk_list_store_insert (GTK_LIST_STORE (model), &row, 0);
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        COL_FD, openfiles->fd,
+                        COL_TYPE, get_type_name(static_cast<glibtop_file_type>(openfiles->type)),
+                        COL_OBJECT, object,
+#if GLIB_CHECK_VERSION (2, 68, 0)
+                        COL_OPENFILE_STRUCT, g_memdup2(openfiles, sizeof(*openfiles)),
+#else
+                        COL_OPENFILE_STRUCT, g_memdup(openfiles, sizeof(*openfiles)),
+#endif
+                        -1);
+
+    g_free(object);
+}
+
+static GList *old_maps = NULL;
+
+static gboolean
+classify_openfiles (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+    GHashTable *new_maps = static_cast<GHashTable*>(data);
+    GtkTreeIter *old_iter;
+    glibtop_open_files_entry *openfiles;
+    gchar *old_name;
+
+    gtk_tree_model_get (model, iter, 1, &old_name, -1);
+
+    openfiles = static_cast<glibtop_open_files_entry*>(g_hash_table_lookup (new_maps, old_name));
+    if (openfiles) {
+        g_hash_table_remove (new_maps, old_name);
+        g_free (old_name);
+        return FALSE;
+
+    }
+
+    old_iter = gtk_tree_iter_copy (iter);
+    old_maps = g_list_append (old_maps, old_iter);
+    g_free (old_name);
+    return FALSE;
+
+}
+
+
+static gboolean
+compare_open_files(gconstpointer a, gconstpointer b)
+{
+    const glibtop_open_files_entry *o1 = static_cast<const glibtop_open_files_entry *>(a);
+    const glibtop_open_files_entry *o2 = static_cast<const glibtop_open_files_entry *>(b);
+
+    /* Falta manejar los diferentes tipos! */
+    return (o1->fd == o2->fd) && (o1->type == o2->type); /* XXX! */
+}
+
+
+static void
+update_openfiles_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+    GtkTreeModel *model;
+    glibtop_open_files_entry *openfiles;<--- Shadowed declaration
+    glibtop_proc_open_files procmap;
+    GHashTable *new_maps;
+    guint i;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    if (!info)
+        return;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    openfiles = glibtop_get_proc_open_files (&procmap, info->pid);
+
+    if (!openfiles)
+        return;
+
+    new_maps = static_cast<GHashTable *>(g_hash_table_new_full (g_str_hash, compare_open_files,
+                                                                NULL, NULL));
+    for (i=0; i < procmap.number; i++)
+        g_hash_table_insert (new_maps, openfiles + i, openfiles + i);
+
+    gtk_tree_model_foreach (model, classify_openfiles, new_maps);
+
+    g_hash_table_foreach (new_maps, add_new_files, model);
+
+    while (old_maps) {
+        GtkTreeIter *iter = static_cast<GtkTreeIter*>(old_maps->data);
+        glibtop_open_files_entry *openfiles = NULL;<--- Shadow variable
+
+        gtk_tree_model_get (model, iter,
+                            COL_OPENFILE_STRUCT, &openfiles,
+                            -1);
+
+        gtk_list_store_remove (GTK_LIST_STORE (model), iter);
+        gtk_tree_iter_free (iter);
+        g_free (openfiles);
+
+        old_maps = g_list_next (old_maps);
+
+    }
+
+    g_hash_table_destroy (new_maps);
+    g_free (openfiles);
+}
+
+static void
+close_openfiles_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GSettings *settings;
+    guint timer;
+
+    settings = static_cast<GSettings*>(g_object_get_data (G_OBJECT (tree), "settings"));
+    procman_save_tree_state (settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    return ;
+}
+
+
+static GtkWidget *
+create_openfiles_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    const gchar * const titles[] = {
+        /* Translators: "FD" here means "File Descriptor". Please use
+           a very short translation if possible, and at most
+           2-3 characters for it to be able to fit in the UI. */
+        N_("FD"),
+        N_("Type"),
+        N_("Object")
+    };
+
+    model = gtk_list_store_new (NUM_OPENFILES_COL,
+                                G_TYPE_INT,        /* FD */
+                                G_TYPE_STRING,    /* Type */
+                                G_TYPE_STRING,    /* Object */
+                                G_TYPE_POINTER    /* open_files_entry */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_OPENFILES_COL-1; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        switch (i) {
+        case COL_FD:
+            g_object_set(cell, "xalign", 1.0f, NULL);
+            break;
+        }
+
+        column = gtk_tree_view_column_new_with_attributes (_(titles[i]),
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_sort_column_id (column, i);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    procman_get_tree_state (procdata->settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    return tree;
+}
+
+
+static gboolean
+openfiles_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_openfiles_dialog (tree);
+
+    return TRUE;
+}
+
+
+static void
+create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *openfilesdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    openfilesdialog = gtk_dialog_new_with_buttons (_("Open Files"), NULL,
+                                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                   "gtk-close", GTK_RESPONSE_CLOSE,
+                                                   NULL);
+    gtk_window_set_resizable (GTK_WINDOW (openfilesdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (openfilesdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (openfilesdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (openfilesdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Files opened by process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                    GTK_POLICY_AUTOMATIC,
+                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_openfiles_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+    g_object_set_data (G_OBJECT (tree), "settings", procdata->settings);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (openfilesdialog), "response",
+                      G_CALLBACK (close_openfiles_dialog), tree);
+
+    gtk_widget_show_all (openfilesdialog);
+
+    timer = g_timeout_add_seconds (5, openfiles_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_openfiles_dialog (tree);
+
+}
+
+
+void
+create_openfiles_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_openfiles_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/12.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/12.html new file mode 100644 index 00000000..c1c9bcc6 --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/12.html @@ -0,0 +1,385 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
// -*- c++ -*-
+
+#ifndef _PROCMAN_PRETTYTABLE_H_
+#define _PROCMAN_PRETTYTABLE_H_
+
+#include <glib.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <glibmm/refptr.h>
+#include <gdkmm/pixbuf.h>
+#include <giomm/filemonitor.h>
+
+#include <map>
+#include <string>
+
+#ifdef HAVE_WNCK
+extern "C" {
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h>
+}
+#endif
+
+#include "iconthemewrapper.h"
+
+class ProcInfo;
+
+using std::string;
+
+class PrettyTable
+{
+ public:
+    PrettyTable();
+    ~PrettyTable();
+
+    void set_icon(ProcInfo &);
+
+private:
+
+#ifdef HAVE_WNCK
+    static void on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_opened'
+    static void on_application_closed(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_closed'
+
+    void register_application(pid_t pid, Glib::RefPtr<Gdk::Pixbuf> icon);
+    void unregister_application(pid_t pid);
+#endif
+
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_theme(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_default(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_gio(const ProcInfo &);
+#ifdef HAVE_WNCK
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_wnck(const ProcInfo &);
+#endif
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_name(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_for_kernel(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_dummy(const ProcInfo &);
+
+    bool get_default_icon_name(const string &cmd, string &name);
+    void file_monitor_event (Glib::RefPtr<Gio::File>,
+                             Glib::RefPtr<Gio::File>,
+                             Gio::FileMonitorEvent);
+    void init_gio_app_cache ();
+
+    typedef std::map<string, Glib::RefPtr<Gdk::Pixbuf> > IconCache;
+    typedef std::map<pid_t, Glib::RefPtr<Gdk::Pixbuf> > IconsForPID;
+    typedef std::map<string, Glib::RefPtr<Gio::AppInfo> > AppCache;
+    typedef std::map<string, Glib::RefPtr<Gio::FileMonitor> > DesktopDirMonitors;
+
+    IconsForPID apps;
+    IconCache defaults;
+    DesktopDirMonitors monitors;
+    AppCache gio_apps;
+    procman::IconThemeWrapper theme;
+};
+
+#endif /* _PROCMAN_PRETTYTABLE_H_ */
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/13.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/13.html new file mode 100644 index 00000000..b7c3450b --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/13.html @@ -0,0 +1,1417 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
/* Procman - dialogs
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+
+#include <signal.h>
+#include <string.h>
+
+#include "procdialogs.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "procactions.h"
+#include "util.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "procman_gksu.h"
+#include "procman_pkexec.h"
+#include "cgroups.h"
+
+#define GET_WIDGET(x) GTK_WIDGET(gtk_builder_get_object(builder, x))
+
+static GtkWidget *renice_dialog = NULL;
+static GtkWidget *prefs_dialog = NULL;
+static gint new_nice_value = 0;
+
+
+static void
+kill_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    struct KillArgs *kargs = static_cast<KillArgs*>(data);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    if (id == GTK_RESPONSE_OK)
+        kill_process (kargs->procdata, kargs->signal);
+
+    g_free (kargs);
+}
+
+void
+procdialog_create_kill_dialog (ProcData *procdata, int signal)
+{
+    GtkWidget *kill_alert_dialog;
+    gchar *primary, *secondary, *button_text;
+    struct KillArgs *kargs;
+
+    kargs = g_new(KillArgs, 1);
+    kargs->procdata = procdata;
+    kargs->signal = signal;
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if ( selected_count == 1 ) {
+        ProcInfo *selected_process = NULL;
+        // get the last selected row
+        gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &selected_process);
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing single process*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        } else {
+            /*xgettext: primary alert message for ending single process*/
+            primary = g_strdup_printf (_("Are you sure you want to end the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        }
+    } else {
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the %d selected processes?"),
+                                       selected_count);
+        } else {
+            /*xgettext: primary alert message for ending multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to end the %d selected processes?"),
+                                       selected_count);
+
+        }
+    }
+
+    if ( signal == SIGKILL ) {
+        /*xgettext: secondary alert message*/
+        secondary = _("Killing a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be killed.");
+        button_text = ngettext("_Kill Process", "_Kill Processes", selected_count);
+    } else {
+        /*xgettext: secondary alert message*/
+        secondary = _("Ending a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be ended.");
+        button_text = ngettext("_End Process", "_End Processes", selected_count);
+    }
+
+    kill_alert_dialog = gtk_message_dialog_new (GTK_WINDOW (procdata->app),
+                                                static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
+                                                GTK_MESSAGE_WARNING,
+                                                GTK_BUTTONS_NONE,
+                                                "%s",
+                                                primary);
+    g_free (primary);
+
+    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (kill_alert_dialog),
+                                              "%s",
+                                              secondary);
+
+    gtk_dialog_add_buttons (GTK_DIALOG (kill_alert_dialog),
+                            "gtk-cancel", GTK_RESPONSE_CANCEL,
+                            button_text, GTK_RESPONSE_OK,
+                            NULL);
+
+    gtk_dialog_set_default_response (GTK_DIALOG (kill_alert_dialog),
+                                     GTK_RESPONSE_CANCEL);
+
+    g_signal_connect (G_OBJECT (kill_alert_dialog), "response",
+                      G_CALLBACK (kill_dialog_button_pressed), kargs);
+
+    gtk_widget_show_all (kill_alert_dialog);
+}
+
+static void
+renice_scale_changed (GtkAdjustment *adj, gpointer data)
+{
+    GtkWidget *label = GTK_WIDGET (data);
+
+    new_nice_value = int(gtk_adjustment_get_value (adj));
+    gchar* text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (new_nice_value));
+    gtk_label_set_text (GTK_LABEL (label), text);
+    g_free(text);
+
+}
+
+static void
+renice_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (id == 100) {
+        if (new_nice_value == -100)
+            return;
+        renice(procdata, new_nice_value);
+    }
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+    renice_dialog = NULL;
+}
+
+void
+procdialog_create_renice_dialog (ProcData *procdata)
+{
+    ProcInfo  *info;
+    GtkWidget *dialog = NULL;
+    GtkWidget *dialog_vbox;
+    GtkWidget *vbox;
+    GtkWidget *label;
+    GtkWidget *priority_label;
+    GtkWidget *grid;
+    GtkAdjustment *renice_adj;
+    GtkWidget *hscale;
+    GtkWidget *button;
+    GtkWidget *icon;
+    gchar     *text;
+    gchar     *dialog_title;
+
+    if (renice_dialog)
+        return;
+
+    gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &info);
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if (!info)
+        return;
+
+    if ( selected_count == 1 ) {
+        dialog_title = g_strdup_printf (_("Change Priority of Process “%s†(PID: %u)"),
+                                        info->name, info->pid);
+    } else {
+        dialog_title = g_strdup_printf (_("Change Priority of %d Selected Processes"),
+                                        selected_count);
+    }
+
+    dialog = gtk_dialog_new_with_buttons (dialog_title, NULL,
+                                          GTK_DIALOG_DESTROY_WITH_PARENT,
+                                          "gtk-cancel", GTK_RESPONSE_CANCEL,
+                                          NULL);
+    g_free (dialog_title);
+
+    renice_dialog = dialog;
+    gtk_window_set_resizable (GTK_WINDOW (renice_dialog), FALSE);
+    gtk_container_set_border_width (GTK_CONTAINER (renice_dialog), 5);
+
+    button = gtk_button_new_with_mnemonic (_("Change _Priority"));
+    gtk_widget_set_can_default (button, TRUE);
+
+    icon = gtk_image_new_from_icon_name ("gtk-apply", GTK_ICON_SIZE_BUTTON);
+    gtk_button_set_image (GTK_BUTTON (button), icon);
+
+    gtk_dialog_add_action_widget (GTK_DIALOG (renice_dialog), button, 100);
+    gtk_dialog_set_default_response (GTK_DIALOG (renice_dialog), 100);
+    new_nice_value = -100;
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+    gtk_box_set_spacing (GTK_BOX (dialog_vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), vbox, TRUE, TRUE, 0);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+
+    grid = gtk_grid_new ();
+    gtk_grid_set_column_spacing (GTK_GRID(grid), 12);
+    gtk_grid_set_row_spacing (GTK_GRID(grid), 6);
+    gtk_box_pack_start (GTK_BOX (vbox), grid, TRUE, TRUE, 0);
+
+    label = gtk_label_new_with_mnemonic (_("_Nice value:"));
+    gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 2);
+
+    renice_adj = gtk_adjustment_new (info->nice, RENICE_VAL_MIN, RENICE_VAL_MAX, 1, 1, 0);
+    new_nice_value = 0;
+    hscale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, renice_adj);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), hscale);
+    gtk_scale_set_digits (GTK_SCALE (hscale), 0);
+    gtk_widget_set_hexpand (hscale, TRUE);
+    gtk_grid_attach (GTK_GRID (grid), hscale, 1, 0, 1, 1);
+    text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (info->nice));
+    priority_label = gtk_label_new (text);
+    gtk_grid_attach (GTK_GRID (grid), priority_label, 1, 1, 1, 1);
+    g_free(text);
+
+    text = g_strconcat("<small><i><b>", _("Note:"), "</b> ",
+        _("The priority of a process is given by its nice value. A lower nice value corresponds to a higher priority."),
+        "</i></small>", NULL);
+    label = gtk_label_new (_(text));
+    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+    g_free (text);
+
+    g_signal_connect (G_OBJECT (dialog), "response",
+                      G_CALLBACK (renice_dialog_button_pressed), procdata);
+    g_signal_connect (G_OBJECT (renice_adj), "value_changed",
+                      G_CALLBACK (renice_scale_changed), priority_label);
+
+    gtk_widget_show_all (dialog);
+
+
+}
+
+static void
+prefs_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    if (id == GTK_RESPONSE_HELP)
+    {
+        GError* error = 0;
+        if (!g_app_info_launch_default_for_uri("help:mate-system-monitor/mate-system-monitor-prefs", NULL, &error))
+        {
+            g_warning("Could not display preferences help : %s", error->message);
+            g_error_free(error);
+        }
+    }
+    else
+    {
+        gtk_widget_destroy (GTK_WIDGET (dialog));
+        prefs_dialog = NULL;
+    }
+}
+
+
+class SpinButtonUpdater
+{
+public:
+    SpinButtonUpdater(const string& key)
+        : key(key)
+    { }
+
+    static gboolean callback(GtkWidget *widget, GdkEventFocus *event, gpointer data)
+    {
+        SpinButtonUpdater* updater = static_cast<SpinButtonUpdater*>(data);
+        gtk_spin_button_update(GTK_SPIN_BUTTON(widget));
+        updater->update(GTK_SPIN_BUTTON(widget));
+        return FALSE;
+    }
+
+private:
+
+    void update(GtkSpinButton* spin)
+    {
+        int new_value = int(1000 * gtk_spin_button_get_value(spin));
+        g_settings_set_int(ProcData::get_instance()->settings,
+                           this->key.c_str(), new_value);
+
+        procman_debug("set %s to %d", this->key.c_str(), new_value);
+    }
+
+    const string key;
+};
+
+
+static void
+field_toggled (const gchar *child_schema, GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+    GtkTreeIter iter;
+    GtkTreeViewColumn *column;
+    gboolean toggled;
+    GSettings *settings = g_settings_get_child (ProcData::get_instance()->settings, child_schema);
+    gchar *key;
+    int id;
+
+    if (!path)
+        return;
+
+    gtk_tree_model_get_iter (model, &iter, path);
+
+    gtk_tree_model_get (model, &iter, 2, &column, -1);
+    toggled = gtk_cell_renderer_toggle_get_active (cell);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, !toggled, -1);
+    gtk_tree_view_column_set_visible (column, !toggled);
+
+    id = gtk_tree_view_column_get_sort_column_id (column);
+
+    key = g_strdup_printf ("col-%d-visible", id);
+    g_settings_set_boolean (settings, key, !toggled);
+    g_free (key);
+
+    gtk_tree_path_free (path);
+}
+
+static void
+proc_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("proctree", cell, path_str, data);
+}
+
+static void
+disk_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("disktreenew", cell, path_str, data);
+}
+
+static void
+create_field_page(GtkBuilder* builder, GtkWidget *tree, const gchar *widgetname)
+{
+    GtkTreeView *treeview;
+    GList *it, *columns;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;<--- Shadowed declaration
+    GtkCellRenderer *cell;
+    gchar *full_widgetname;
+
+    full_widgetname = g_strdup_printf ("%s_columns", widgetname);
+    treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, full_widgetname));
+    g_free (full_widgetname);
+
+    model = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER);
+
+    gtk_tree_view_set_model (GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(model));
+    g_object_unref (G_OBJECT (model));
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_toggle_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "active", 0,
+                                         NULL);
+
+    if (g_strcmp0 (widgetname, "proctree") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (proc_field_toggled), model);
+    else if (g_strcmp0 (widgetname, "disktreenew") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (disk_field_toggled), model);
+
+    gtk_tree_view_column_set_clickable (column, TRUE);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "text", 1,
+                                         NULL);
+
+    gtk_tree_view_column_set_title (column, "Not Shown");
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    for(it = columns; it; it = it->next)
+    {
+        GtkTreeViewColumn *column = static_cast<GtkTreeViewColumn*>(it->data);<--- Shadow variable
+        GtkTreeIter iter;
+        const gchar *title;
+        gboolean visible;
+        gint column_id;
+
+        title = gtk_tree_view_column_get_title (column);
+        if (!title)
+            title = _("Icon");
+
+        column_id = gtk_tree_view_column_get_sort_column_id(column);
+        if ((column_id == COL_CGROUP) && (!cgroups_enabled()))
+            continue;
+
+        if ((column_id == COL_UNIT ||
+             column_id == COL_SESSION ||
+             column_id == COL_SEAT ||
+             column_id == COL_OWNER)
+#ifdef HAVE_SYSTEMD
+            && !LOGIND_RUNNING()
+#endif
+                )
+            continue;
+
+        visible = gtk_tree_view_column_get_visible (column);
+
+        gtk_list_store_append (model, &iter);
+        gtk_list_store_set (model, &iter, 0, visible, 1, title, 2, column,-1);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procdialog_create_preferences_dialog (ProcData *procdata)
+{
+    typedef SpinButtonUpdater SBU;
+
+    static SBU interval_updater("update-interval");
+    static SBU graph_interval_updater("graph-update-interval");
+    static SBU disks_interval_updater("disks-interval");
+
+    GtkWidget *notebook;
+    GtkAdjustment *adjustment;
+    GtkWidget *spin_button;
+    GtkWidget *check_button;
+    GtkWidget *smooth_button;
+    GtkBuilder *builder;
+    gfloat update;
+
+    if (prefs_dialog)
+        return;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/preferences.ui");
+
+    prefs_dialog = GET_WIDGET("preferences_dialog");
+    notebook = GET_WIDGET("notebook");
+    spin_button = GET_WIDGET("processes_interval_spinner");
+
+    update = (gfloat) procdata->config.update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0,
+                                   MIN_UPDATE_INTERVAL / 1000,
+                                   MAX_UPDATE_INTERVAL / 1000,
+                                   0.25,
+                                   1.0,
+                                   0);
+
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK (SBU::callback), &interval_updater);
+
+    smooth_button = GET_WIDGET("smooth_button");
+    g_settings_bind(procdata->settings, SmoothRefresh::KEY.c_str(), smooth_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    check_button = GET_WIDGET("check_button");
+    g_settings_bind(procdata->settings, "kill-dialog", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    GtkWidget *solaris_button = GET_WIDGET("solaris_button");
+    g_settings_bind(procdata->settings, procman::settings::solaris_mode.c_str(), solaris_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->tree, "proctree");
+
+    update = (gfloat) procdata->config.graph_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0, 0.25,
+                                                      100.0, 0.25, 1.0, 0);
+
+    spin_button = GET_WIDGET("resources_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &graph_interval_updater);
+
+    GtkWidget *bits_button = GET_WIDGET("bits_button");
+    g_settings_bind(procdata->settings, procman::settings::network_in_bits.c_str(), bits_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+
+    update = (gfloat) procdata->config.disks_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new (update / 1000.0, 1.0,
+                                                       100.0, 1.0, 1.0, 0);
+
+    spin_button = GET_WIDGET("devices_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &disks_interval_updater);
+
+    check_button = GET_WIDGET("all_devices_check");
+    g_settings_bind(procdata->settings, "show-all-fs", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->disk_list, "disktreenew");
+
+    gtk_widget_show_all (prefs_dialog);
+    g_signal_connect (G_OBJECT (prefs_dialog), "response",
+                       G_CALLBACK (prefs_dialog_button_pressed), procdata);
+
+    switch (procdata->config.current_tab) {
+    case PROCMAN_TAB_SYSINFO:
+    case PROCMAN_TAB_PROCESSES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
+        break;
+    case PROCMAN_TAB_RESOURCES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 1);
+        break;
+    case PROCMAN_TAB_DISKS:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 2);
+        break;
+    }
+
+    gtk_builder_connect_signals (builder, NULL);
+    g_object_unref (G_OBJECT (builder));
+}
+
+
+static char *
+procman_action_to_command(ProcmanActionType type,
+                          gint pid,
+                          gint extra_value)
+{
+    switch (type) {
+    case PROCMAN_ACTION_KILL:
+           return g_strdup_printf("kill -s %d %d", extra_value, pid);
+    case PROCMAN_ACTION_RENICE:
+        return g_strdup_printf("renice %d %d", extra_value, pid);
+    default:
+        g_assert_not_reached();
+    }
+}
+
+
+/*
+ * type determines whether if dialog is for killing process or renice.
+ * type == PROCMAN_ACTION_KILL,   extra_value -> signal to send
+ * type == PROCMAN_ACTION_RENICE, extra_value -> new priority.
+ */
+gboolean
+procdialog_create_root_password_dialog(ProcmanActionType type,
+                                       ProcData *procdata,
+                                       gint pid,
+                                       gint extra_value)
+{
+    char * command;
+    gboolean ret = FALSE;
+
+    command = procman_action_to_command(type, pid, extra_value);
+
+    procman_debug("Trying to run '%s' as root", command);
+
+    if (procman_has_pkexec())
+        ret = procman_pkexec_create_root_password_dialog(command);
+    else if (procman_has_gksu())
+        ret = procman_gksu_create_root_password_dialog(command);
+
+    g_free(command);
+    return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/14.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/14.html new file mode 100644 index 00000000..3c8a776c --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/14.html @@ -0,0 +1,1109 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
#include <glib/gi18n.h>
+#include <glibtop.h>
+#include <glibtop/close.h>
+#include <glibtop/cpu.h>
+#include <glibtop/sysinfo.h>
+
+#include "procman-app.h"
+#include "procman.h"
+#include "interface.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "argv.h"
+#include "util.h"
+
+static void
+mount_changed(const Glib::RefPtr<Gio::Mount>&)
+{
+    cb_update_disks(ProcData::get_instance());
+}
+
+
+static void
+init_volume_monitor(ProcData *procdata)
+{
+    using namespace Gio;
+    using namespace Glib;
+
+    RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+    monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
+}
+
+static gboolean
+has_key (gchar **keys, const gchar *key)
+{
+    gchar **loop = keys;
+
+    while (*loop) {
+        if (!strcmp (*loop++, key))
+            return TRUE;
+    }
+
+    return FALSE;
+}
+
+static void
+tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_tree = g_settings_get_boolean(settings, key);
+
+    g_object_set(G_OBJECT(procdata->tree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
+    proctable_update (procdata);
+}
+
+
+static void
+network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
+    // force scale to be redrawn
+    procdata->net_graph->clear_background();
+}
+
+static void
+view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.whose_process = g_settings_get_int (settings, key);
+    procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2);
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "kill-dialog")) {
+        procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
+    }
+}
+
+static void
+timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "update-interval")) {
+        procdata->config.update_interval = g_settings_get_int (settings, key);
+        procdata->config.update_interval =
+            MAX (procdata->config.update_interval, 1000);
+
+        procdata->smooth_refresh->reset();
+
+        if(procdata->timeout) {
+            g_source_remove (procdata->timeout);
+            procdata->timeout = g_timeout_add (procdata->config.update_interval,
+                                               cb_timeout,
+                                               procdata);
+        }
+    }
+    else if (g_str_equal (key, "graph-update-interval")){
+        procdata->config.graph_update_interval = g_settings_get_int (settings, key);
+        procdata->config.graph_update_interval =
+            MAX (procdata->config.graph_update_interval,
+                 250);
+        load_graph_change_speed(procdata->cpu_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->mem_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->net_graph,
+                                procdata->config.graph_update_interval);
+    }
+    else if (g_str_equal(key, "disks-interval")) {
+        procdata->config.disks_update_interval = g_settings_get_int (settings, key);
+        procdata->config.disks_update_interval =
+            MAX (procdata->config.disks_update_interval, 1000);
+
+        if(procdata->disk_timeout) {
+            g_source_remove (procdata->disk_timeout);
+            procdata->disk_timeout = \
+                g_timeout_add (procdata->config.disks_update_interval,
+                               cb_update_disks,
+                               procdata);
+        }
+    }
+    else {
+        g_assert_not_reached();
+    }
+}
+
+static void
+color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    gchar *color = g_settings_get_string (settings, key);
+
+    if (g_str_has_prefix (key, "cpu-color")) {
+        for (int i = 0; i < procdata->config.num_cpus; i++) {
+            string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
+            if (cpu_key == key) {
+                gdk_rgba_parse (&procdata->config.cpu_color[i], color);
+                procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
+                break;
+            }
+        }
+    }
+    else if (g_str_equal (key, "mem-color")) {
+        gdk_rgba_parse (&procdata->config.mem_color, color);
+        procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
+    }
+    else if (g_str_equal (key, "swap-color")) {
+        gdk_rgba_parse (&procdata->config.swap_color, color);
+        procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
+    }
+    else if (g_str_equal (key, "net-in-color")) {
+        gdk_rgba_parse (&procdata->config.net_in_color, color);
+        procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
+    }
+    else if (g_str_equal (key, "net-out-color")) {
+        gdk_rgba_parse (&procdata->config.net_out_color, color);
+        procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
+    }
+    else {
+        g_assert_not_reached();
+    }
+    g_free(color);
+}
+
+static void
+show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
+
+    cb_update_disks (data);
+}
+
+static ProcData *
+procman_data_new (GSettings *settings)
+{
+    GSettingsSchema *schema;
+    ProcData *pd;
+    gchar *color;
+    gchar **keys;
+    glibtop_cpu cpu;
+
+    pd = ProcData::get_instance();
+
+    g_settings_get (settings, "window-state", "(iiii)",
+                    &pd->config.width, &pd->config.height,
+                    &pd->config.xpos, &pd->config.ypos);
+
+    pd->config.maximized = g_settings_get_boolean(settings, "maximized");
+
+    pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
+    g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd);
+
+    pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
+    std::string detail_string("changed::" + procman::settings::solaris_mode);
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd);
+
+    pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
+    detail_string = "changed::" + procman::settings::network_in_bits;
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd);
+
+    pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
+    g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd);
+    pd->config.update_interval = g_settings_get_int (settings, "update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.graph_update_interval = g_settings_get_int (settings,
+                                                           "graph-update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",
+                      G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd);
+
+
+    /* show_all_fs */
+    pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
+    g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd);
+
+
+    pd->config.whose_process = g_settings_get_int (settings, "view-as");
+    g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd);
+    pd->config.current_tab = g_settings_get_int (settings, "current-tab");
+
+    glibtop_get_cpu (&cpu);
+    pd->frequency = cpu.frequency;
+    pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
+
+    g_object_get (settings, "settings-schema", &schema, NULL);
+    keys = g_settings_schema_list_keys (schema);
+    g_settings_schema_unref (schema);
+
+    for (int i = 0; i < pd->config.num_cpus; i++) {
+        gchar *key;
+        key = g_strdup_printf ("cpu-color%d", i);
+
+        if (has_key (keys, key))
+            color = g_settings_get_string (settings, key);
+        else
+            color = g_strdup ("#f25915e815e8");
+        detail_string = std::string("changed::") + std::string(key);
+        g_signal_connect (G_OBJECT(settings), detail_string.c_str(),
+                          G_CALLBACK(color_changed_cb), pd);
+        gdk_rgba_parse (&pd->config.cpu_color[i], color);
+        g_free (color);
+        g_free (key);
+    }
+    g_strfreev (keys);
+
+    color = g_settings_get_string (settings, "mem-color");
+    if (!color)
+        color = g_strdup ("#000000ff0082");
+    g_signal_connect (G_OBJECT(settings), "changed::mem-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.mem_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "swap-color");
+    if (!color)
+        color = g_strdup ("#00b6000000ff");
+    g_signal_connect (G_OBJECT(settings), "changed::swap-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.swap_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-in-color");
+    if (!color)
+        color = g_strdup ("#000000f200f2");
+    g_signal_connect (G_OBJECT(settings), "changed::net-in-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_in_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-out-color");
+    if (!color)
+        color = g_strdup ("#00f2000000c1");
+    g_signal_connect (G_OBJECT(settings), "changed::net-out-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_out_color, color);
+    g_free (color);
+
+    /* Sanity checks */
+    GdkDisplay *display;
+    GdkMonitor *monitor;
+    GdkRectangle monitor_geometry;
+
+    display = gdk_display_get_default ();
+    monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
+    if (monitor == NULL) {
+        monitor = gdk_display_get_monitor (display, 0);
+    }
+    gdk_monitor_get_geometry (monitor, &monitor_geometry);
+
+    pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width);
+    pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height);
+    pd->config.update_interval = MAX (pd->config.update_interval, 1000);
+    pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250);
+    pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000);
+    pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2);
+    pd->config.current_tab = CLAMP(pd->config.current_tab,
+                                   PROCMAN_TAB_SYSINFO,
+                                   PROCMAN_TAB_DISKS);
+
+    // delayed initialization as SmoothRefresh() needs ProcData
+    // i.e. we can't call ProcData::get_instance
+    pd->smooth_refresh = new SmoothRefresh(settings);
+
+    pd->terminating = FALSE;
+
+    return pd;
+}
+
+static void
+procman_free_data (ProcData *procdata)
+{
+
+    proctable_free_table (procdata);
+    delete procdata->smooth_refresh;
+}
+
+ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)<--- Member variable 'ProcmanApp::procdata' is not initialized in the constructor.
+{
+    Glib::set_application_name(_("System Monitor"));
+}
+
+Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
+{
+    return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
+}
+
+void ProcmanApp::on_activate()
+{
+    gtk_window_present (GTK_WINDOW (procdata->app));
+}
+
+static void
+set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
+{
+    gtk_notebook_set_current_page(notebook, tab);
+    cb_change_current_page(notebook, tab, procdata);
+}
+
+int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
+{
+    int argc = 0;
+    char** argv = command_line->get_arguments(argc);
+
+    Glib::OptionContext context;
+    context.set_summary(_("A simple process and system monitor."));
+    context.set_ignore_unknown_options(true);
+    procman::OptionGroup option_group;
+    context.set_main_group(option_group);
+
+    try {
+        context.parse(argc, argv);
+    } catch (const Glib::Error& ex) {
+        g_error("Arguments parse error : %s", ex.what().c_str());
+    }
+
+    if (option_group.show_system_tab) {
+        procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_SYSINFO, procdata);
+    } else if (option_group.show_processes_tab) {
+        procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_PROCESSES, procdata);
+    } else if (option_group.show_resources_tab) {
+        procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_RESOURCES, procdata);
+    } else if (option_group.show_file_systems_tab) {
+        procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_DISKS, procdata);
+    }
+
+    on_activate ();
+
+    return 0;
+}
+
+void ProcmanApp::on_startup()
+{
+    Gtk::Application::on_startup();
+
+    GSettings *settings;
+
+    Gtk::Window::set_default_icon_name ("utilities-system-monitor");
+
+    settings = g_settings_new (GSM_GSETTINGS_SCHEMA);
+
+    glibtop_init ();
+
+    procdata = procman_data_new (settings);
+    procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA);
+
+    create_main_window (procdata);
+    init_volume_monitor (procdata);
+
+    Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app));
+    window->show();
+    window->set_name ("mate-system-monitor");
+
+    add_window (*window);
+}
+
+void ProcmanApp::on_shutdown()
+{
+    procman_free_data(procdata);
+    glibtop_close();
+}
+
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/15.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/15.html new file mode 100644 index 00000000..caf6d784 --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/15.html @@ -0,0 +1,671 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+
+#include <locale.h>
+
+#include <gtkmm.h>
+#include <glib/gi18n.h>
+
+#include "procman-app.h"
+#include "procman.h"
+#include "proctable.h"
+
+ProcData::ProcData()<--- Member variable 'ProcData::uimanager' is not initialized in the constructor.<--- Member variable 'ProcData::action_group' is not initialized in the constructor.<--- Member variable 'ProcData::statusbar' is not initialized in the constructor.<--- Member variable 'ProcData::loadavg' is not initialized in the constructor.<--- Member variable 'ProcData::endprocessbutton' is not initialized in the constructor.<--- Member variable 'ProcData::popup_menu' is not initialized in the constructor.<--- Member variable 'ProcData::disk_list' is not initialized in the constructor.<--- Member variable 'ProcData::notebook' is not initialized in the constructor.<--- Member variable 'ProcData::config' is not initialized in the constructor.<--- Member variable 'ProcData::selection' is not initialized in the constructor.<--- Member variable 'ProcData::settings' is not initialized in the constructor.<--- Member variable 'ProcData::app' is not initialized in the constructor.<--- Member variable 'ProcData::menu' is not initialized in the constructor.<--- Member variable 'ProcData::frequency' is not initialized in the constructor.<--- Member variable 'ProcData::smooth_refresh' is not initialized in the constructor.
+    : tree(NULL),
+      cpu_graph(NULL),
+      mem_graph(NULL),
+      net_graph(NULL),
+      selected_process(NULL),
+      timeout(0),
+      disk_timeout(0),
+      cpu_total_time(1),
+      cpu_total_time_last(1)
+{ }
+
+ProcData* ProcData::get_instance()
+{
+    static ProcData instance;
+    return &instance;
+}
+
+gboolean
+procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns, *it;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    sort_col = g_settings_get_int (pt_settings, "sort-col");
+
+    order = static_cast<GtkSortType>(g_settings_get_int (pt_settings, "sort-order"));
+
+    if (sort_col != -1)
+        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
+                                              sort_col,
+                                              order);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        for (it = columns; it; it = it->next)
+        {
+            GtkTreeViewColumn *column;
+            gint width;
+            gboolean visible;
+            int id;
+            gchar *key;
+
+            column = static_cast<GtkTreeViewColumn*>(it->data);
+            id = gtk_tree_view_column_get_sort_column_id (column);
+
+            key = g_strdup_printf ("col-%d-width", id);
+            g_settings_get (pt_settings, key, "i", &width);
+            g_free (key);
+
+            key = g_strdup_printf ("col-%d-visible", id);
+            visible = g_settings_get_boolean (pt_settings, key);
+            g_free (key);
+
+            gtk_tree_view_column_set_visible (column, visible);
+            if (visible) {
+                /* ensure column is really visible */
+                width = MAX(width, 20);
+                gtk_tree_view_column_set_fixed_width(column, width);
+            }
+        }
+
+        GVariant     *value;
+        GVariantIter iter;
+        int          sortIndex;
+
+        GSList *order = NULL;<--- Shadow variable
+
+        value = g_settings_get_value(pt_settings, "columns-order");
+        g_variant_iter_init(&iter, value);
+
+        while (g_variant_iter_loop (&iter, "i", &sortIndex))
+            order = g_slist_append(order, GINT_TO_POINTER(sortIndex));
+
+        proctable_set_columns_order(GTK_TREE_VIEW(tree), order);
+
+        g_variant_unref(value);
+        g_slist_free(order);
+    }
+
+    g_object_unref(pt_settings);
+    pt_settings = NULL;
+
+    g_list_free(columns);
+
+    return TRUE;
+}
+
+void
+procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    if (ProcData::get_instance()->terminating)
+        return;
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    if (gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (model), &sort_col,
+                                              &order)) {
+        g_settings_set_int (pt_settings, "sort-col", sort_col);
+        g_settings_set_int (pt_settings, "sort-order", order);
+    }
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        GSList *order;<--- Shadow variable
+        GSList *order_node;
+        GVariantBuilder *builder;
+        GVariant *order_variant;
+
+        order = proctable_get_columns_order(GTK_TREE_VIEW(tree));
+
+        builder = g_variant_builder_new (G_VARIANT_TYPE ("ai"));
+
+        for (order_node = order; order_node; order_node = order_node->next)
+            g_variant_builder_add(builder, "i", GPOINTER_TO_INT(order_node->data));
+
+        order_variant = g_variant_new("ai", builder);
+        g_settings_set_value(pt_settings, "columns-order", order_variant);
+
+        g_slist_free(order);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procman_save_config (ProcData *data)
+{
+    GSettings *settings = data->settings;
+
+    g_assert(data);
+
+    data->config.maximized = gdk_window_get_state(gtk_widget_get_window (data->app)) & GDK_WINDOW_STATE_MAXIMIZED;
+    if (!data->config.maximized) {
+        // we only want to store/overwrite size and position info with non-maximized state info
+        data->config.width  = gdk_window_get_width (gtk_widget_get_window (data->app));
+        data->config.height = gdk_window_get_height(gtk_widget_get_window (data->app));
+
+        gtk_window_get_position(GTK_WINDOW(data->app), &data->config.xpos, &data->config.ypos);
+
+        g_settings_set (settings, "window-state", "(iiii)",
+                        data->config.width, data->config.height,
+                        data->config.xpos, data->config.ypos);
+    }
+    g_settings_set_boolean (settings, "maximized", data->config.maximized);
+
+    g_settings_set_int (settings, "current-tab", data->config.current_tab);
+}
+
+int
+main (int argc, char *argv[])
+{
+    bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+    textdomain (GETTEXT_PACKAGE);
+    setlocale (LC_ALL, "");
+
+    Glib::RefPtr<ProcmanApp> application = ProcmanApp::create();
+    return application->run (argc, argv);
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/16.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/16.html new file mode 100644 index 00000000..91267585 --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/16.html @@ -0,0 +1,913 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
/* Process properties dialog
+ * Copyright (C) 2010 Krishnan Parthasarathi <krishnan.parthasarathi@gmail.com>
+ *                    Robert Ancell <robert.ancell@canonical.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <glibtop/procmem.h>
+#include <glibtop/procmap.h>
+#include <glibtop/procstate.h>
+
+#include "procman.h"
+#include "procproperties.h"
+#include "proctable.h"
+#include "util.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
+enum
+{
+    COL_PROP = 0,
+    COL_VAL,
+    NUM_COLS,
+};
+
+typedef struct _proc_arg {
+    const gchar *prop;
+    gchar *val;
+} proc_arg;
+
+static void
+get_process_memory_writable (ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info (ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+static gchar*
+format_memsize(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
+}
+
+static gchar*
+format_size(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size(size);
+}
+
+static void
+fill_proc_properties (GtkWidget *tree, ProcInfo *info)
+{
+    guint i;
+    GtkListStore *store;
+
+    if (!info)
+        return;
+
+    get_process_memory_info(info);
+
+    proc_arg proc_props[] = {
+        { N_("Process Name"), g_strdup_printf("%s", info->name)},
+        { N_("User"), g_strdup_printf("%s (%d)", info->user.c_str(), info->uid)},
+        { N_("Status"), g_strdup(format_process_state(info->status))},
+        { N_("Memory"), format_memsize(info->mem)},
+        { N_("Virtual Memory"), format_memsize(info->vmsize)},
+        { N_("Resident Memory"), format_memsize(info->memres)},
+        { N_("Writable Memory"), format_memsize(info->memwritable)},
+        { N_("Shared Memory"), format_memsize(info->memshared)},
+#ifdef HAVE_WNCK
+        { N_("X Server Memory"), format_memsize(info->memxserver)},
+#endif
+        { N_("Disk Read Total"), format_size(info->disk_read_bytes_total)},
+        { N_("Disk Write Total"), format_size(info->disk_write_bytes_total)},
+        { N_("CPU"), g_strdup_printf("%d%%", info->pcpu)},
+        { N_("CPU Time"), procman::format_duration_for_display(100 * info->cpu_time / ProcData::get_instance()->frequency) },
+        { N_("Started"), procman_format_date_for_display(info->start_time) },
+        { N_("Nice"), g_strdup_printf("%d", info->nice)},
+        { N_("Priority"), g_strdup_printf("%s", procman::get_nice_level(info->nice)) },
+        { N_("ID"), g_strdup_printf("%d", info->pid)},
+        { N_("Security Context"), info->security_context ? g_strdup_printf("%s", info->security_context) : g_strdup(_("N/A"))},
+        { N_("Command Line"), g_strdup_printf("%s", info->arguments)},
+        { N_("Waiting Channel"), g_strdup_printf("%s", info->wchan)},
+        { N_("Control Group"), info->cgroup_name ? g_strdup_printf("%s", info->cgroup_name) : g_strdup(_("N/A"))},
+        { NULL, NULL}
+    };
+
+    store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
+    for (i = 0; proc_props[i].prop; i++) {
+        GtkTreeIter iter;
+
+        if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL(store), &iter, NULL, i)) {
+            gtk_list_store_append(store, &iter);
+            gtk_list_store_set(store, &iter, COL_PROP, _(proc_props[i].prop), -1);
+        }
+
+        gtk_list_store_set(store, &iter, COL_VAL, g_strstrip(proc_props[i].val), -1);
+        g_free(proc_props[i].val);
+    }
+}
+
+static void
+update_procproperties_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    fill_proc_properties(tree, info);
+}
+
+static void
+close_procprop_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    guint timer;
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static GtkWidget *
+create_procproperties_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    model = gtk_list_store_new (NUM_COLS,
+                                G_TYPE_STRING,	/* Property */
+                                G_TYPE_STRING	/* Value */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_COLS; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        column = gtk_tree_view_column_new_with_attributes (NULL,
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tree), FALSE);
+    fill_proc_properties(tree, procdata->selected_process);
+
+    return tree;
+}
+
+static gboolean
+procprop_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_procproperties_dialog (tree);
+
+    return TRUE;
+}
+
+static void
+create_single_procproperties_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                     GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *procpropdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    procpropdialog = gtk_dialog_new_with_buttons (_("Process Properties"), NULL,
+                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                  "gtk-close", GTK_RESPONSE_CLOSE,
+                                                  NULL);
+    gtk_window_set_resizable (GTK_WINDOW (procpropdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (procpropdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (procpropdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (procpropdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("Properties of process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_procproperties_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (procpropdialog), "response",
+                      G_CALLBACK (close_procprop_dialog), tree);
+
+    gtk_widget_show_all (procpropdialog);
+
+    timer = g_timeout_add_seconds (5, procprop_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_procproperties_dialog (tree);
+}
+
+void
+create_procproperties_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_procproperties_dialog,
+                                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/17.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/17.html new file mode 100644 index 00000000..3ce08395 --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/17.html @@ -0,0 +1,2635 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
/* Procman tree view and process updating
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <cairo-gobject.h>
+#include <string.h>
+#include <math.h>
+#include <glib/gi18n.h>
+#include <glib/gprintf.h>
+#include <glibtop.h>
+#include <glibtop/loadavg.h>
+#include <glibtop/proclist.h>
+#include <glibtop/procio.h>
+#include <glibtop/procstate.h>
+#include <glibtop/procmem.h>
+#include <glibtop/procmap.h>
+#include <glibtop/proctime.h>
+#include <glibtop/procuid.h>
+#include <glibtop/procargs.h>
+#include <glibtop/prockernel.h>
+#include <glibtop/mem.h>
+#include <glibtop/swap.h>
+#include <sys/stat.h>
+#include <pwd.h>
+#include <time.h>
+
+#include <set>
+#include <list>
+
+#ifdef HAVE_SYSTEMD
+#include <systemd/sd-login.h>
+#endif
+
+#include "procman.h"
+#include "selection.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "util.h"
+#include "interface.h"
+#include "selinux.h"
+#include "cgroups.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
+ProcInfo::UserMap ProcInfo::users;
+ProcInfo::List ProcInfo::all;
+std::map<pid_t, guint64> ProcInfo::cpu_times;
+
+
+ProcInfo* ProcInfo::find(pid_t pid)
+{
+    Iterator it(ProcInfo::all.find(pid));
+    return (it == ProcInfo::all.end() ? NULL : it->second);
+}
+
+void
+get_last_selected (GtkTreeModel *model, GtkTreePath *path,
+           GtkTreeIter *iter, gpointer data)
+{
+    ProcInfo **info = static_cast<ProcInfo**>(data);
+
+    gtk_tree_model_get (model, iter, COL_POINTER, info, -1);
+}
+
+static void
+cb_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "proctree");
+}
+
+static void
+cb_sort_changed (GtkTreeSortable *model, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state (procdata->settings,
+                             GTK_WIDGET (procdata->tree),
+                             "proctree");
+}
+
+
+static GtkTreeViewColumn*
+my_gtk_tree_view_get_column_with_sort_column_id(GtkTreeView *treeview, int id)
+{
+    GList *columns, *it;
+    GtkTreeViewColumn *col = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(it = columns; it; it = it->next)
+    {
+        if(gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(it->data)) == id)
+        {
+            col = static_cast<GtkTreeViewColumn*>(it->data);
+            break;
+        }
+    }
+
+    g_list_free(columns);
+
+    return col;
+}
+
+
+void
+proctable_set_columns_order(GtkTreeView *treeview, GSList *order)
+{
+    GtkTreeViewColumn* last = NULL;
+    GSList *it;
+
+    for(it = order; it; it = it->next)
+    {
+        int id;
+        GtkTreeViewColumn *cur;
+
+        id = GPOINTER_TO_INT(it->data);
+
+        cur = my_gtk_tree_view_get_column_with_sort_column_id(treeview, id);
+
+        if(cur && cur != last)
+        {
+            gtk_tree_view_move_column_after(treeview, cur, last);
+            last = cur;
+        }
+    }
+}
+
+
+GSList*
+proctable_get_columns_order(GtkTreeView *treeview)
+{
+    GList *columns, *col;
+    GSList *order = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(col = columns; col; col = col->next)
+    {
+        int id;
+
+        id = gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(col->data));
+        order = g_slist_prepend(order, GINT_TO_POINTER(id));
+    }
+
+    g_list_free(columns);
+
+    order = g_slist_reverse(order);
+
+    return order;
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "proctree");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_proctable_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+static gboolean
+search_equal_func(GtkTreeModel *model,
+                  gint column,
+                  const gchar *key,
+                  GtkTreeIter *iter,
+                  gpointer search_data)
+{
+    char* name;
+    char* user;
+    gboolean found;
+
+    gtk_tree_model_get(model, iter,
+                       COL_NAME, &name,
+                       COL_USER, &user,
+                       -1);
+
+    found = !((name && strcasestr(name, key))
+              || (user && strcasestr(user, key)));
+
+    g_free(name);
+    g_free(user);
+
+    return found;
+}
+
+
+
+GtkWidget *
+proctable_new (ProcData * const procdata)
+{
+    GtkWidget *proctree;
+    GtkTreeStore *model;
+    GtkTreeSelection *selection;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell_renderer;
+
+    const gchar *titles[] = {
+        N_("Process Name"),
+        N_("User"),
+        N_("Status"),
+        N_("Virtual Memory"),
+        N_("Resident Memory"),
+        N_("Writable Memory"),
+        N_("Shared Memory"),
+        N_("X Server Memory"),
+        /* xgettext:no-c-format */ N_("% CPU"),
+        N_("CPU Time"),
+        N_("Started"),
+        N_("Nice"),
+        N_("ID"),
+        N_("Security Context"),
+        N_("Command Line"),
+        N_("Memory"),
+        /* xgettext: combined noun, the function the process is waiting in, see wchan ps(1) */
+        N_("Waiting Channel"),
+        N_("Control Group"),
+        N_("Unit"),
+        N_("Session"),
+        /* TRANSLATORS: Seat = i.e. the physical seat the session of the process belongs to, only
+	for multi-seat environments. See http://en.wikipedia.org/wiki/Multiseat_configuration */
+        N_("Seat"),
+        N_("Owner"),
+        N_("Disk Read Total"),
+        N_("Disk Write Total"),
+        N_("Disk Read"),
+        N_("Disk Write"),
+        N_("Priority"),
+        NULL,
+        "POINTER"
+    };
+
+    gint i;
+
+    model = gtk_tree_store_new (NUM_COLUMNS,
+                                G_TYPE_STRING,              /* Process Name */
+                                G_TYPE_STRING,              /* User         */
+                                G_TYPE_UINT,                /* Status       */
+                                G_TYPE_ULONG,               /* VM Size      */
+                                G_TYPE_ULONG,               /* Resident Memory */
+                                G_TYPE_ULONG,               /* Writable Memory */
+                                G_TYPE_ULONG,               /* Shared Memory */
+                                G_TYPE_ULONG,               /* X Server Memory */
+                                G_TYPE_UINT,                /* % CPU        */
+                                G_TYPE_UINT64,              /* CPU time     */
+                                G_TYPE_ULONG,               /* Started      */
+                                G_TYPE_INT,                 /* Nice         */
+                                G_TYPE_UINT,                /* ID           */
+                                G_TYPE_STRING,              /* Security Context */
+                                G_TYPE_STRING,              /* Arguments    */
+                                G_TYPE_ULONG,               /* Memory       */
+                                G_TYPE_STRING,              /* wchan        */
+                                G_TYPE_STRING,              /* Cgroup       */
+                                G_TYPE_STRING,              /* Unit         */
+                                G_TYPE_STRING,              /* Session      */
+                                G_TYPE_STRING,              /* Seat         */
+                                G_TYPE_STRING,              /* Owner        */
+                                G_TYPE_UINT64,              /* Disk read total */
+                                G_TYPE_UINT64,              /* Disk write total*/
+                                G_TYPE_UINT64,              /* Disk read    */
+                                G_TYPE_UINT64,              /* Disk write   */
+                                G_TYPE_STRING,              /* Priority     */
+                                CAIRO_GOBJECT_TYPE_SURFACE, /* Icon         */
+                                G_TYPE_POINTER,             /* ProcInfo     */
+                                G_TYPE_STRING               /* Sexy tooltip */
+        );
+
+    proctree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (proctree), COL_TOOLTIP);
+    g_object_set(G_OBJECT(proctree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+    gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (proctree),
+                                         search_equal_func,
+                                         NULL,
+                                         NULL);
+    g_object_unref (G_OBJECT (model));
+
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree));
+    gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+
+    column = gtk_tree_view_column_new ();
+
+    cell_renderer = gtk_cell_renderer_pixbuf_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "surface", COL_SURFACE,
+                                         NULL);
+
+    cell_renderer = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "text", COL_NAME,
+                                         NULL);
+    gtk_tree_view_column_set_title (column, _(titles[0]));
+    gtk_tree_view_column_set_sort_column_id (column, COL_NAME);
+    gtk_tree_view_column_set_resizable (column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+    gtk_tree_view_column_set_min_width (column, 20);
+    gtk_tree_view_column_set_reorderable (column, TRUE);
+    g_signal_connect(G_OBJECT(column), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (proctree), column);
+    gtk_tree_view_set_expander_column (GTK_TREE_VIEW (proctree), column);
+
+
+    for (i = COL_USER; i <= COL_PRIORITY; i++) {
+
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+#ifndef HAVE_WNCK
+        if (i == COL_MEMXSERVER) {
+          continue;
+        }
+#endif
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(proctree), col);
+
+        // type
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_CPU_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::duration_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_START_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::time_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_STATUS:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::status_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::io_rate_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_PRIORITY:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::priority_cell_data_func,
+                                                        GUINT_TO_POINTER(COL_NICE),
+                                                        NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+        }
+
+        // sorting
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+            case COL_CPU:
+            case COL_CPU_TIME:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_START_TIME:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::number_compare_func, GUINT_TO_POINTER(i),
+                                                NULL);
+                break;
+            case COL_PRIORITY:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::priority_compare_func,
+                                                GUINT_TO_POINTER(COL_NICE), NULL);
+                break;
+            default:
+                break;
+        }
+
+        // xalign
+        switch(i)
+        {
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMWRITABLE:
+            case COL_MEMSHARED:
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_CPU:
+            case COL_NICE:
+            case COL_PID:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_CPU_TIME:
+            case COL_MEM:
+                g_object_set(G_OBJECT(cell), "xalign", 1.0f, NULL);
+                break;
+        }
+
+        // sizing
+        switch (i) {
+            case COL_ARGS:
+                gtk_tree_view_column_set_min_width(col, 150);
+                break;
+            default:
+                gtk_tree_view_column_set_min_width(col, 20);
+                break;
+        }
+    }
+
+    procdata->tree = proctree;
+
+    procman_get_tree_state (procdata->settings, proctree, "proctree");
+
+    /* Override column settings by hiding this column if it's meaningless: */
+    if (!can_show_security_context_column ()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id (GTK_TREE_VIEW (proctree), COL_SECURITYCONTEXT);
+        gtk_tree_view_column_set_visible (column, FALSE);
+    }
+
+    if (!cgroups_enabled()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), COL_CGROUP);
+        gtk_tree_view_column_set_visible(column, FALSE);
+    }
+
+#ifdef HAVE_SYSTEMD
+    if (!LOGIND_RUNNING())
+#endif
+    {
+        for (i = COL_UNIT; i <= COL_OWNER; i++) {
+            column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), i);
+            gtk_tree_view_column_set_visible(column, FALSE);
+        }
+    }
+
+    g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree))),
+                      "changed",
+                      G_CALLBACK (cb_row_selected), procdata);
+    g_signal_connect (G_OBJECT (proctree), "popup_menu",
+                      G_CALLBACK (cb_tree_popup_menu), procdata);
+    g_signal_connect (G_OBJECT (proctree), "button_press_event",
+                      G_CALLBACK (cb_tree_button_pressed), procdata);
+
+    g_signal_connect (G_OBJECT(proctree), "columns-changed",
+                      G_CALLBACK(cb_columns_changed), procdata);
+
+    g_signal_connect (G_OBJECT (model), "sort-column-changed",
+                      G_CALLBACK (cb_sort_changed), procdata);
+
+    return proctree;
+}
+
+
+ProcInfo::~ProcInfo()
+{
+    g_free(this->name);
+    g_free(this->tooltip);
+    g_free(this->arguments);
+    g_free(this->security_context);
+    g_free(this->cgroup_name);
+    g_free(this->unit);
+    g_free(this->session);
+    g_free(this->seat);
+    cairo_surface_destroy(this->surface);
+}
+
+
+static void
+get_process_name (ProcInfo *info,
+                  const gchar *cmd, const GStrv args)
+{
+    if (args) {
+        // look for /usr/bin/very_long_name
+        // and also /usr/bin/interpreter /usr/.../very_long_name
+        // which may have use prctl to alter 'cmd' name
+        for (int i = 0; i != 2 && args[i]; ++i) {
+            char* basename;
+            basename = g_path_get_basename(args[i]);
+
+            if (g_str_has_prefix(basename, cmd)) {
+                info->name = basename;
+                return;
+            }
+
+            g_free(basename);
+        }
+    }
+
+    info->name = g_strdup (cmd);
+}
+
+std::string
+ProcInfo::lookup_user(guint uid)
+{
+    typedef std::pair<ProcInfo::UserMap::iterator, bool> Pair;
+    ProcInfo::UserMap::value_type hint(uid, "");
+    Pair p(ProcInfo::users.insert(hint));
+
+    // procman_debug("User lookup for uid %u: %s", uid, (p.second ? "MISS" : "HIT"));
+
+    if (p.second) {
+        struct passwd* pwd;
+        pwd = getpwuid(uid);
+
+        if (pwd && pwd->pw_name)
+            p.first->second = pwd->pw_name;
+        else {
+            char username[16];
+            g_sprintf(username, "%u", uid);
+            p.first->second = username;
+        }
+    }
+
+    return p.first->second;
+}
+
+void
+ProcInfo::set_user(guint uid)
+{
+    if (G_LIKELY(this->uid == uid))
+        return;
+
+    this->uid = uid;
+    this->user = lookup_user(uid);
+}
+
+static void get_process_memory_writable(ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info(ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+
+static void
+update_info_mutable_cols(ProcInfo *info)
+{
+    ProcData * const procdata = ProcData::get_instance();
+    GtkTreeModel *model;
+    model = gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->tree));
+
+    using procman::tree_store_update;
+
+    tree_store_update(model, &info->node, COL_STATUS, info->status);
+    tree_store_update(model, &info->node, COL_USER, info->user.c_str());
+    tree_store_update(model, &info->node, COL_VMSIZE, info->vmsize);
+    tree_store_update(model, &info->node, COL_MEMRES, info->memres);
+    tree_store_update(model, &info->node, COL_MEMWRITABLE, info->memwritable);
+    tree_store_update(model, &info->node, COL_MEMSHARED, info->memshared);
+#ifdef HAVE_WNCK
+    tree_store_update(model, &info->node, COL_MEMXSERVER, info->memxserver);
+#endif
+    tree_store_update(model, &info->node, COL_CPU, info->pcpu);
+    tree_store_update(model, &info->node, COL_CPU_TIME, info->cpu_time);
+    tree_store_update(model, &info->node, COL_DISK_READ_TOTAL, info->disk_read_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_TOTAL, info->disk_write_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_READ_CURRENT, info->disk_read_bytes_current);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_CURRENT, info->disk_write_bytes_current);
+    tree_store_update(model, &info->node, COL_START_TIME, info->start_time);
+    tree_store_update(model, &info->node, COL_NICE, info->nice);
+    tree_store_update(model, &info->node, COL_MEM, info->mem);
+    tree_store_update(model, &info->node, COL_WCHAN, info->wchan);
+    tree_store_update(model, &info->node, COL_CGROUP, info->cgroup_name);
+    tree_store_update(model, &info->node, COL_UNIT, info->unit);
+    tree_store_update(model, &info->node, COL_SESSION, info->session);
+    tree_store_update(model, &info->node, COL_SEAT, info->seat);
+    tree_store_update(model, &info->node, COL_OWNER, info->owner.c_str());
+}
+
+
+
+static void
+insert_info_to_tree (ProcInfo *info, ProcData *procdata, bool forced = false)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    if (procdata->config.show_tree) {
+
+        ProcInfo *parent = 0;
+
+        if (not forced)
+            parent = ProcInfo::find(info->ppid);
+
+        if (parent) {
+            GtkTreePath *parent_node = gtk_tree_model_get_path(model, &parent->node);
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, &parent->node, 0);
+
+            if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(procdata->tree), parent_node)
+#ifdef __linux__
+                // on linuxes we don't want to expand kthreadd by default (always has pid 2)
+                && (parent->pid != 2)
+#endif
+            )
+                gtk_tree_view_expand_row(GTK_TREE_VIEW(procdata->tree), parent_node, FALSE);
+            gtk_tree_path_free(parent_node);
+        } else
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, NULL, 0);
+    }
+    else
+        gtk_tree_store_insert (GTK_TREE_STORE (model), &info->node, NULL, 0);
+
+    gtk_tree_store_set (GTK_TREE_STORE (model), &info->node,
+                        COL_POINTER, info,
+                        COL_NAME, info->name,
+                        COL_ARGS, info->arguments,
+                        COL_TOOLTIP, info->tooltip,
+                        COL_PID, info->pid,
+                        COL_SECURITYCONTEXT, info->security_context,
+                        -1);
+
+    procdata->pretty_table.set_icon(*info);
+
+    procman_debug("inserted %d%s", info->pid, (forced ? " (forced)" : ""));
+}
+
+
+/* Removing a node with children - make sure the children are queued
+** to be readded.
+*/
+template<typename List>
+static void
+remove_info_from_tree (ProcData *procdata, GtkTreeModel *model,
+                       ProcInfo *current, List &orphans, unsigned lvl = 0)
+{
+    GtkTreeIter child_node;
+
+    if (std::find(orphans.begin(), orphans.end(), current) != orphans.end()) {
+        procman_debug("[%u] %d already removed from tree", lvl, int(current->pid));
+        return;
+    }
+
+    procman_debug("[%u] pid %d, %d children", lvl, int(current->pid),
+                  gtk_tree_model_iter_n_children(model, &current->node));
+
+    // it is not possible to iterate&erase over a treeview so instead we
+    // just pop one child after another and recursively remove it and
+    // its children
+
+    while (gtk_tree_model_iter_children(model, &child_node, &current->node)) {
+        ProcInfo *child = 0;
+        gtk_tree_model_get(model, &child_node, COL_POINTER, &child, -1);
+        remove_info_from_tree(procdata, model, child, orphans, lvl + 1);
+    }
+
+    g_assert(not gtk_tree_model_iter_has_child(model, &current->node));
+
+    if (procdata->selected_process == current)
+        procdata->selected_process = NULL;
+
+    orphans.push_back(current);
+    gtk_tree_store_remove(GTK_TREE_STORE(model), &current->node);
+    procman::poison(current->node, 0x69);
+}
+
+static void
+get_process_systemd_info(ProcInfo *info)
+{
+#ifdef HAVE_SYSTEMD
+    uid_t uid;
+
+    if (!LOGIND_RUNNING())
+        return;
+
+    free(info->unit);
+    info->unit = NULL;
+    sd_pid_get_unit(info->pid, &info->unit);
+
+    free(info->session);
+    info->session = NULL;
+    sd_pid_get_session(info->pid, &info->session);
+
+    free(info->seat);
+    info->seat = NULL;
+
+    if (info->session != NULL)
+        sd_session_get_seat(info->session, &info->seat);
+
+    if (sd_pid_get_owner_uid(info->pid, &uid) >= 0)
+        info->owner = info->lookup_user(uid);
+    else
+        info->owner = "";
+#endif
+}
+
+static void
+update_info (ProcData *procdata, ProcInfo *info)
+{
+    glibtop_proc_state procstate;
+    glibtop_proc_uid procuid;
+    glibtop_proc_time proctime;
+    glibtop_proc_kernel prockernel;
+    glibtop_proc_io procio;
+
+    glibtop_get_proc_kernel(&prockernel, info->pid);
+    g_strlcpy(info->wchan, prockernel.wchan, sizeof info->wchan);
+
+    glibtop_get_proc_state (&procstate, info->pid);
+    info->status = procstate.state;
+
+    glibtop_get_proc_uid (&procuid, info->pid);
+    glibtop_get_proc_time (&proctime, info->pid);
+    glibtop_get_proc_io (&procio, info->pid);
+
+    get_process_memory_info(info);
+
+    info->set_user(procstate.uid);
+
+    // if the cpu time has increased reset the status to running
+    // regardless of kernel state (https://bugzilla.gnome.org/606579)
+    guint64 difference = proctime.rtime - info->cpu_time;
+    if (difference > 0)
+        info->status = GLIBTOP_PROCESS_RUNNING;
+    info->pcpu = difference * 100 / procdata->cpu_total_time;
+    info->pcpu = MIN(info->pcpu, 100);
+
+    if (not procdata->config.solaris_mode)
+      info->pcpu *= procdata->config.num_cpus;
+
+    ProcInfo::cpu_times[info->pid] = info->cpu_time = proctime.rtime;
+    info->nice = procuid.nice;
+
+    gdouble update_interval_seconds = procdata->config.update_interval / 1000.0;
+    difference = procio.disk_wbytes - info->disk_write_bytes_total;
+    info->disk_write_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+    difference = procio.disk_rbytes - info->disk_read_bytes_total;
+    info->disk_read_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+
+    info->disk_write_bytes_total = procio.disk_wbytes;
+    info->disk_read_bytes_total = procio.disk_rbytes;
+
+    // set the ppid only if one can exist
+    // i.e. pid=0 can never have a parent
+    if (info->pid > 0) {
+        info->ppid = procuid.ppid;
+    }
+
+    g_assert(info->pid != info->ppid);
+    g_assert(info->ppid != -1 || info->pid == 0);
+
+    /* get cgroup data */
+    get_process_cgroup_info(info);
+
+    get_process_systemd_info(info);
+}
+
+
+ProcInfo::ProcInfo(pid_t pid)
+    : node(),
+      surface(),
+      tooltip(NULL),
+      name(NULL),
+      arguments(NULL),
+      security_context(NULL),
+      pid(pid),
+      ppid(-1),
+      uid(-1)
+{
+    ProcInfo * const info = this;
+    glibtop_proc_state procstate;
+    glibtop_proc_time proctime;
+    glibtop_proc_args procargs;
+    gchar** arguments;<--- Shadow variable
+
+    glibtop_get_proc_state (&procstate, pid);
+    glibtop_get_proc_time (&proctime, pid);
+    arguments = glibtop_get_proc_argv (&procargs, pid, 0);
+
+    /* FIXME : wrong. name and arguments may change with exec* */
+    get_process_name (info, procstate.cmd, static_cast<const GStrv>(arguments));
+
+    std::string tooltip = make_string(g_strjoinv(" ", arguments));<--- Shadow variable
+    if (tooltip.empty())
+        tooltip = procstate.cmd;
+
+    info->tooltip = g_markup_escape_text(tooltip.c_str(), -1);
+
+    info->arguments = g_strescape(tooltip.c_str(), "\\\"");
+    g_strfreev(arguments);
+
+    guint64 cpu_time = proctime.rtime;
+    std::map<pid_t, guint64>::iterator it(ProcInfo::cpu_times.find(pid));
+    if (it != ProcInfo::cpu_times.end())
+    {
+        if (proctime.rtime >= it->second)
+          cpu_time = it->second;
+    }
+    info->cpu_time = cpu_time;
+    info->start_time = proctime.start_time;
+
+    get_process_selinux_context (info);
+    info->cgroup_name = NULL;
+    get_process_cgroup_info(info);
+
+    info->unit = info->session = info->seat = NULL;
+    get_process_systemd_info(info);
+}
+
+static void
+refresh_list (ProcData *procdata, const pid_t* pid_list, const guint n)
+{
+    typedef std::list<ProcInfo*> ProcList;
+    ProcList addition;
+
+    GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+    guint i;
+
+    // Add or update processes in the process list
+    for(i = 0; i < n; ++i) {
+        ProcInfo *info = ProcInfo::find(pid_list[i]);
+
+        if (!info) {
+            info = new ProcInfo(pid_list[i]);
+            ProcInfo::all[info->pid] = info;
+            addition.push_back(info);
+        }
+
+        update_info (procdata, info);
+    }
+
+
+    // Remove dead processes from the process list and from the
+    // tree. children are queued to be readded at the right place
+    // in the tree.
+
+    const std::set<pid_t> pids(pid_list, pid_list + n);
+
+    ProcInfo::Iterator it(ProcInfo::begin());<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration
+
+    while (it != ProcInfo::end()) {
+        ProcInfo * const info = it->second;
+        ProcInfo::Iterator next(it);
+        ++next;
+
+        if (pids.find(info->pid) == pids.end()) {
+            procman_debug("ripping %d", info->pid);
+            remove_info_from_tree(procdata, model, info, addition);
+            addition.remove(info);
+            ProcInfo::all.erase(it);
+            delete info;
+        }
+
+        it = next;
+    }
+
+    // INVARIANT
+    // pid_list == ProcInfo::all + addition
+
+
+    if (procdata->config.show_tree) {
+
+        // insert process in the tree. walk through the addition list
+        // (new process + process that have a new parent). This loop
+        // handles the dependencies because we cannot insert a process
+        // until its parent is in the tree.
+
+        std::set<pid_t> in_tree(pids);
+
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            in_tree.erase((*it)->pid);
+
+
+        while (not addition.empty()) {
+            procman_debug("looking for %d parents", int(addition.size()));
+            ProcList::iterator it(addition.begin());<--- Shadow variable
+
+            while (it != addition.end()) {
+                procman_debug("looking for %d's parent with ppid %d",
+                              int((*it)->pid), int((*it)->ppid));
+
+
+                // inserts the process in the treeview if :
+                // - it has no parent (ppid = -1),
+                //   ie it is for example the [kernel] on FreeBSD
+                // - it is init
+                // - its parent is already in tree
+                // - its parent is unreachable
+                //
+                // rounds == 2 means that addition contains processes with
+                // unreachable parents
+                //
+                // FIXME: this is broken if the unreachable parent becomes active
+                // i.e. it gets active or changes ower
+                // so we just clear the tree on __each__ update
+                // see proctable_update_list (ProcData * const procdata)
+
+
+                if ((*it)->ppid <= 0 or in_tree.find((*it)->ppid) != in_tree.end()) {
+                    insert_info_to_tree(*it, procdata);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ProcInfo *parent = ProcInfo::find((*it)->ppid);
+                // if the parent is unreachable
+                if (not parent) {
+                    // or std::find(addition.begin(), addition.end(), parent) == addition.end()) {
+                    insert_info_to_tree(*it, procdata, true);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ++it;
+            }
+        }
+    }
+    else {
+        // don't care of the tree
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            insert_info_to_tree(*it, procdata);
+    }
+
+
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)<--- Shadow variable
+        update_info_mutable_cols(it->second);
+}
+
+
+static void
+proctable_update_list (ProcData * const procdata)
+{
+    pid_t* pid_list;
+    glibtop_proclist proclist;
+    glibtop_cpu cpu;
+    gint which, arg;
+    procman::SelectionMemento selection;
+
+    switch (procdata->config.whose_process) {
+        case ALL_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL;
+            arg = 0;
+            break;
+
+        case ACTIVE_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL | GLIBTOP_EXCLUDE_IDLE;
+            arg = 0;
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+
+        default:
+            which = GLIBTOP_KERN_PROC_UID;
+            arg = getuid ();
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+    }
+
+    pid_list = glibtop_get_proclist (&proclist, which, arg);
+
+    /* FIXME: total cpu time elapsed should be calculated on an individual basis here
+    ** should probably have a total_time_last gint in the ProcInfo structure */
+    glibtop_get_cpu (&cpu);
+    procdata->cpu_total_time = MAX(cpu.total - procdata->cpu_total_time_last, 1);
+    procdata->cpu_total_time_last = cpu.total;
+
+    // FIXME: not sure if glibtop always returns a sorted list of pid
+    // but it is important otherwise refresh_list won't find the parent
+    std::sort(pid_list, pid_list + proclist.number);
+
+    refresh_list (procdata, pid_list, proclist.number);
+
+    selection.restore(procdata->tree);
+
+    g_free (pid_list);
+
+    /* proclist.number == g_list_length(procdata->info) == g_hash_table_size(procdata->pids) */
+}
+
+
+void
+proctable_update (ProcData * const procdata)
+{
+    char* string;
+
+    string = make_loadavg_string();
+    gtk_label_set_text (GTK_LABEL(procdata->loadavg), string);
+    g_free (string);
+
+    proctable_update_list (procdata);
+}
+
+
+void
+proctable_free_table (ProcData * const procdata)
+{
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)
+        delete it->second;
+
+    ProcInfo::all.clear();
+}
+
+
+void
+proctable_clear_tree (ProcData * const procdata)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    gtk_tree_store_clear (GTK_TREE_STORE (model));
+
+    proctable_free_table (procdata);
+
+    update_sensitivity(procdata);
+}
+
+
+char*
+make_loadavg_string(void)
+{
+    glibtop_loadavg buf;
+
+    glibtop_get_loadavg(&buf);
+
+    return g_strdup_printf(
+        _("Load averages for the last 1, 5, 15 minutes: "
+          "%0.2f, %0.2f, %0.2f"),
+        buf.loadavg[0],
+        buf.loadavg[1],
+        buf.loadavg[2]);
+}
+
+
+
+void
+ProcInfo::set_icon(Glib::RefPtr<Gdk::Pixbuf> icon)
+{
+  this->surface = gdk_cairo_surface_create_from_pixbuf (icon->gobj(), 0, NULL);
+
+  GtkTreeModel *model;
+  model = gtk_tree_view_get_model(GTK_TREE_VIEW(ProcData::get_instance()->tree));
+  gtk_tree_store_set(GTK_TREE_STORE(model), &this->node,
+                     COL_SURFACE, this->surface,
+                    -1);
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/18.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/18.html new file mode 100644 index 00000000..4e691255 --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/18.html @@ -0,0 +1,405 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
#include <config.h>
+
+#include <glib.h>
+
+#include "selinux.h"
+#include "procman.h"
+#include "util.h"
+
+
+static int (*getpidcon)(pid_t, char**);
+static void (*freecon)(char*);
+static int (*is_selinux_enabled)(void);
+
+static gboolean has_selinux;
+
+static gboolean load_selinux(void)
+{
+    return load_symbols("libselinux.so.1",
+                        "getpidcon", &getpidcon,
+                        "freecon", &freecon,
+                        "is_selinux_enabled", &is_selinux_enabled,
+                        NULL);
+}
+
+
+
+void
+get_process_selinux_context (ProcInfo *info)
+{
+    char *con;
+
+    if (has_selinux && !getpidcon (info->pid, &con)) {
+        info->security_context = g_strdup (con);
+        freecon (con);
+    }
+}
+
+
+
+gboolean
+can_show_security_context_column (void)
+{
+    if (!(has_selinux = load_selinux()))
+        return FALSE;
+
+    switch (is_selinux_enabled()) {
+        case 1:
+            /* We're running on an SELinux kernel */
+            return TRUE;
+
+        case -1:
+            /* Error; hide the security context column */
+
+        case 0:
+            /* We're not running on an SELinux kernel:
+               hide the security context column */
+
+        default:
+            g_warning("SELinux was found but is not enabled.\n");
+            return FALSE;
+    }
+}
+
+
+
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/19.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/19.html new file mode 100644 index 00000000..913bbae3 --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/19.html @@ -0,0 +1,2359 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
#include <config.h>
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <glibmm.h>
+#include <glib/gi18n.h>
+
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+
+#include <glibtop/fsusage.h>
+#include <glibtop/mountlist.h>
+#include <glibtop/mem.h>
+#include <glibtop/sysinfo.h>
+
+#include <unistd.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#include <math.h>
+#include <errno.h>
+
+#include <exception>
+#include <string>
+#include <vector>
+#include <fstream>
+#include <sstream>
+#include <sys/utsname.h>
+
+#include "sysinfo.h"
+#include "procman.h"
+#include "util.h"
+
+
+using std::string;
+using std::vector;
+
+
+namespace {
+
+    class SysInfo
+    {
+    public:
+        string hostname;
+        string distro_name;
+        string distro_release;
+        string kernel;
+        string mate_version;
+        guint64 memory_bytes;
+        guint64 free_space_bytes;
+
+        string graphics;
+        string processors;
+
+        SysInfo()
+        {
+            this->load_processors_info();
+            this->load_graphics_info();
+            this->load_memory_info();
+            this->load_disk_info();
+            this->load_uname_info();
+            this->load_mate_version();
+        }
+
+        virtual ~SysInfo()
+        { }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Virtual function in base class
+        {
+            g_object_set(G_OBJECT(name),
+                        "label",
+                        ("<big><big><b>" + this->distro_name + "</b></big></big>").c_str(),
+                        NULL);
+
+            char* markup;
+#ifdef __linux__
+            if (this->distro_release != "")
+            {
+                /* Translators: The first string parameter is release version (codename),
+                 * the second one is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("Release %s %s"),
+                                         this->distro_release.c_str(),
+                                         SysInfo::get_os_type().c_str());
+            }
+            else
+            {
+                /* Translators: The string parameter is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("%s Version"),
+                                         SysInfo::get_os_type().c_str());
+            }
+#else
+            /* Translators: The string parameter is release version (codename) */
+            markup = g_strdup_printf(_("Release %s"),
+                                     this->distro_release.c_str());
+#endif
+
+            g_object_set(G_OBJECT(release),
+                         "label",
+                         markup,
+                         NULL);
+
+            g_free(markup);
+        }
+
+        static string release()
+        {
+            return uname().release;
+        }
+
+        static string system()
+        {
+            return uname().sysname;
+        }
+
+    private:
+
+        void load_memory_info()
+        {
+            glibtop_mem mem;
+
+            glibtop_get_mem(&mem);
+            this->memory_bytes = mem.total;
+        }
+
+        static string get_os_type ()<--- Unused private function: 'SysInfo::get_os_type'
+        {
+            int bits;
+
+            if (GLIB_SIZEOF_VOID_P == 8)
+                bits = 64;
+            else
+                bits = 32;
+
+            /* translators: This is the type of architecture, for example:
+             * "64-bit" or "32-bit" */
+            char* bytes = g_strdup_printf (_("%d-bit"), bits);
+            string retval(bytes);
+            g_free(bytes);
+            return retval;
+        }
+
+        typedef struct
+        {
+            const char* regex;
+            const char* replacement;
+        } ReplaceStrings;
+
+        static char* remove_duplicate_whitespace (const char* old)
+        {
+            char* result;
+            GRegex* re;
+            GError* error = NULL;
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+
+            re = g_regex_new ("[ \t\n\r]+", G_REGEX_MULTILINE, flags, &error);
+            if (re == NULL) {
+                g_warning ("Error building regex: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+            result = g_regex_replace (re, old, -1, 0, " ", flags, &error);
+            g_regex_unref (re);
+            if (result == NULL) {
+                g_warning ("Error replacing string: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+
+            return result;
+        }
+
+        static char* prettify_info (const char *info)
+        {
+            char* pretty;
+            const GRegexCompileFlags cflags = static_cast<GRegexCompileFlags>(0);
+            const GRegexMatchFlags mflags = static_cast<GRegexMatchFlags>(0);
+
+            static const ReplaceStrings rs[] = {
+                { "Intel[(]R[)]", "Intel\302\256"},
+                { "Core[(]TM[)]", "Core\342\204\242"},
+                { "Atom[(]TM[)]", "Atom\342\204\242"},
+            };
+
+            pretty = g_markup_escape_text (info, -1);
+
+            for (uint i = 0; i < G_N_ELEMENTS (rs); i++) {
+                GError* error;
+                GRegex* re;
+                char* result;
+
+                error = NULL;
+
+                re = g_regex_new (rs[i].regex, cflags, mflags, &error);
+                if (re == NULL) {
+                    g_warning ("Error building regex: %s", error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                result = g_regex_replace_literal (re, pretty, -1, 0,
+                                             rs[i].replacement, mflags, &error);
+
+                g_regex_unref (re);
+
+                if (error != NULL) {
+                    g_warning ("Error replacing %s: %s", rs[i].regex, error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                g_free (pretty);
+                pretty = result;
+            }
+
+            return pretty;
+        }
+
+        static char* get_renderer_from_helper (gboolean discrete_gpu)
+        {
+            int status;
+            const char *argv[] = { LIBEXECDIR "/mate-session-check-accelerated", NULL };
+            g_auto(GStrv) envp = NULL;
+            g_autofree char *renderer = NULL;
+            g_autoptr(GError) error = NULL;
+
+            if (discrete_gpu)
+            {
+                envp = g_get_environ ();
+                envp = g_environ_setenv (envp, "DRI_PRIME", "1", TRUE);
+            }
+
+            if (!g_spawn_sync (NULL, (char **) argv, envp, G_SPAWN_DEFAULT, NULL, NULL, &renderer, NULL, &status, &error))
+            {
+                g_debug ("Failed to get %s GPU: %s",
+                         discrete_gpu ? "discrete" : "integrated",
+                         error->message);
+                return NULL;
+            }
+
+            if (!g_spawn_check_exit_status (status, NULL))
+                return NULL;
+
+            if (renderer == NULL || *renderer == '\0')
+                return NULL;
+
+            return prettify_info (renderer);
+        }
+
+
+        void load_graphics_info()
+        {
+            g_autofree char *renderer = NULL;
+
+            try
+            {
+                g_autoptr(GDBusProxy) session_proxy = NULL;
+                g_autoptr(GVariant) renderer_variant = NULL;
+                g_autoptr(GError) error = NULL;
+
+                session_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                               G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL,
+                                                               "org.gnome.SessionManager",
+                                                               "/org/gnome/SessionManager",
+                                                               "org.gnome.SessionManager",
+                                                               NULL, &error);
+                if (error != NULL)
+                {
+                    throw std::runtime_error ("Unable to connect to create a proxy for org.gnome.SessionManager");
+                }
+
+                renderer_variant = g_dbus_proxy_get_cached_property (session_proxy, "Renderer");
+                if (!renderer_variant)
+                {
+                    throw std::runtime_error ("Unable to retrieve org.gnome.SessionManager.Renderer property.");
+                }
+
+                renderer = prettify_info (g_variant_get_string (renderer_variant, NULL));
+            }
+            catch (std::exception& e)
+            {
+                g_warning ("%s", e.what());
+            }
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (FALSE);
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (TRUE);
+
+            if (renderer)
+            {
+                this->graphics = g_strdup (renderer);
+            }
+            else
+            {
+                this->graphics = _("Unknown");
+            }
+        }
+
+        void load_processors_info()
+        {
+            const glibtop_sysinfo *info = glibtop_get_sysinfo();
+
+            GHashTable* counts;
+            GString* cpu;
+            GHashTableIter iter;
+            gpointer key, value;
+
+            counts = g_hash_table_new (g_str_hash, g_str_equal);
+
+            /* count duplicates */
+            for (uint i = 0; i != info->ncpu; ++i) {
+                const char* const keys[] = { "model name", "cpu", "Processor" };
+                char* model;
+                int* count;
+
+                model = NULL;
+
+                for (int j = 0; model == NULL && j != G_N_ELEMENTS (keys); ++j) {
+                    model = static_cast<char*>(g_hash_table_lookup (info->cpuinfo[i].values,
+                                                 keys[j]));
+                }
+
+                if (model == NULL)
+                    continue;
+
+                count = static_cast<int*>(g_hash_table_lookup (counts, model));
+                if (count == NULL)
+                    g_hash_table_insert (counts, model, GINT_TO_POINTER (1));
+                else
+                    g_hash_table_replace (counts, model, GINT_TO_POINTER (GPOINTER_TO_INT (count) + 1));
+            }
+
+            cpu = g_string_new (NULL);
+            g_hash_table_iter_init (&iter, counts);
+            while (g_hash_table_iter_next (&iter, &key, &value)) {
+                char* stripped;
+                int   count;
+
+                count = GPOINTER_TO_INT (value);
+                stripped = remove_duplicate_whitespace ((const char *)key);
+                if (count > 1)
+                    g_string_append_printf (cpu, "%s \303\227 %d ", stripped, count);
+                else
+                    g_string_append_printf (cpu, "%s ", stripped);
+                g_free (stripped);
+            }
+
+            g_hash_table_destroy (counts);
+            this->processors = string(prettify_info (cpu->str));
+            g_string_free (cpu, TRUE);
+        }
+
+        void load_disk_info()
+        {
+            GHashTable *devices;
+            glibtop_mountentry *entries;
+            glibtop_mountlist mountlist;
+
+            entries = glibtop_get_mountlist(&mountlist, 0);
+            devices = g_hash_table_new(g_str_hash, g_str_equal);
+            this->free_space_bytes = 0;
+
+            for (guint i = 0; i != mountlist.number; ++i) {
+                if ((string(entries[i].mountdir).compare("/") == 0) && \
+                    (string(entries[i].type).compare("zfs") == 0)) {
+                    // Root filesystem is ZFS based: Calculate usage based on "/".
+                    glibtop_fsusage usage;
+                    glibtop_get_fsusage(&usage, "/");
+                    this->free_space_bytes = usage.bavail * usage.block_size;
+                    break;
+                }
+
+                if (string(entries[i].devname).find("/dev/") != 0)
+                    continue;
+
+                if (string(entries[i].mountdir).find("/media/") == 0)
+                    continue;
+
+                /* avoid adding a device more than once such as for btrfs filesystem */
+                if (g_hash_table_contains (devices, entries[i].devname))
+                    continue;
+                else
+                    g_hash_table_insert (devices, entries[i].devname, entries[i].mountdir);
+
+                glibtop_fsusage usage;
+                glibtop_get_fsusage(&usage, entries[i].mountdir);
+                this->free_space_bytes += usage.bavail * usage.block_size;
+            }
+
+            g_hash_table_destroy (devices);
+            g_free(entries);
+        }
+
+        static const struct utsname & uname()
+        {
+            static struct utsname name;
+
+            if (!name.sysname[0]) {
+                ::uname(&name);
+            }
+
+            return name;
+        }
+
+        void load_uname_info()
+        {
+            this->hostname = uname().nodename;
+#if defined(__linux__)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().machine;
+#elif defined(__sun) && defined(__SVR4)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().version + ' ' + uname().machine;
+#else
+            this->kernel = string(uname().version) + ' ' + uname().machine;
+#endif
+        }
+
+
+        void load_mate_version()
+        {
+            xmlDocPtr document;
+            xmlXPathContextPtr context;
+            const string nodes[3] = { "string(/mate-version/platform)",
+                                      "string(/mate-version/minor)",
+                                      "string(/mate-version/micro)" };
+            string values[3];
+
+            if (not (document = xmlParseFile(DATADIR "/mate-about/mate-version.xml")))
+                return;
+
+            if (not (context = xmlXPathNewContext(document)))
+                return;
+
+            for (size_t i = 0; i != 3; ++i)
+            {
+                xmlXPathObjectPtr xpath;
+                xpath = xmlXPathEvalExpression(BAD_CAST nodes[i].c_str(), context);
+
+                if (xpath and xpath->type == XPATH_STRING)
+                    values[i] = reinterpret_cast<const char*>(xpath->stringval);
+
+                xmlXPathFreeObject(xpath);
+            }
+
+            xmlXPathFreeContext(context);
+            xmlFreeDoc(document);
+
+            if (!values[0].empty() && !values[1].empty() && !values[2].empty())
+                this->mate_version = values[0] + '.' + values[1] + '.' + values[2];
+        }
+    };
+
+    class FreeBSDSysInfo
+        : public SysInfo
+    {
+    public:
+	FreeBSDSysInfo()
+        {
+            this->load_freebsd_info();
+        }
+
+    private:
+        void load_freebsd_info()
+        {
+            this->distro_name = "FreeBSD";
+            this->distro_release = release();
+        }
+    };
+
+    class SolarisSysInfo
+        : public SysInfo
+    {
+    public:
+        SolarisSysInfo()
+        {
+            this->load_solaris_info();
+        }
+
+    private:
+        void load_solaris_info()
+        {
+            std::ifstream input("/etc/release");
+
+            if (input) {
+                std::string s;
+                std::getline(input, s);
+                std::size_t found = s.find("OpenIndiana ");
+                if (found!=std::string::npos) {
+                    this->distro_name = "OpenIndiana";
+                    this->distro_release = s.substr(found + strlen("OpenIndiana "));
+                } else if (!s.empty()) {
+                    this->distro_release = s;
+                }
+            }
+
+            if (this->distro_release.empty()) {
+                this->distro_name = "Solaris";
+            }
+        }
+    };
+
+
+    class LSBSysInfo
+        : public SysInfo
+    {
+    public:
+        LSBSysInfo()<--- Member variable 'LSBSysInfo::lsb_fd' is not initialized in the constructor.<--- Member variable 'LSBSysInfo::name' is not initialized in the constructor.<--- Member variable 'LSBSysInfo::release' is not initialized in the constructor.
+            : re(Glib::Regex::create("^.+?:\\s*(.+)\\s*$"))
+        {
+            // start();
+        }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Function in derived class
+        {
+            this->name = name;
+            this->release = release;
+
+            this->start();
+        }
+
+
+    private:
+
+        sigc::connection child_watch;
+        int lsb_fd;
+        GtkWidget* name;
+        GtkWidget* release;<--- Shadowed declaration<--- Shadowed declaration
+
+        void strip_description(string &s) const
+        {
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+            GMatchInfo* info = 0;
+
+           if (g_regex_match(this->re->gobj(), s.c_str(), flags, &info)) {
+               s = make_string(g_match_info_fetch(info, 1));
+               g_match_info_free(info);
+           }
+        }
+
+        std::istream& get_value(std::istream &is, string &s) const
+        {
+            if (std::getline(is, s))
+                this->strip_description(s);
+            return is;
+        }
+
+
+        void read_lsb(Glib::Pid pid, int status)
+        {
+            this->child_watch.disconnect();
+
+            if (!WIFEXITED(status) or WEXITSTATUS(status) != 0) {
+                g_error("Child %d failed with status %d", int(pid), status);
+                return;
+            }
+
+            Glib::RefPtr<Glib::IOChannel> channel = Glib::IOChannel::create_from_fd(this->lsb_fd);
+            Glib::ustring content;
+
+            while (channel->read_to_end(content) == Glib::IO_STATUS_AGAIN)
+                ;
+
+            channel->close();
+            Glib::spawn_close_pid(pid);
+
+            procman_debug("lsb_release output = '%s'", content.c_str());
+
+            string release, codename;<--- Shadow variable
+            std::istringstream input(content);
+
+            this->get_value(input, this->distro_name)
+                and this->get_value(input, release)
+                and this->get_value(input, codename);
+
+            this->distro_release = release;
+            if (codename != "" && codename != "n/a")
+                this->distro_release += " (" + codename + ')';
+
+            this->SysInfo::set_distro_labels(this->name, this->release);
+        }
+
+
+        void start()
+        {
+            std::vector<string> argv(2);
+            argv[0] = "lsb_release";
+            argv[1] = "-irc";
+
+            Glib::SpawnFlags flags = Glib::SPAWN_DO_NOT_REAP_CHILD
+                | Glib::SPAWN_SEARCH_PATH
+                | Glib::SPAWN_STDERR_TO_DEV_NULL;
+
+            Glib::Pid child;
+
+            try {
+                Glib::spawn_async_with_pipes("/", // wd
+                                             argv,
+                                             flags,
+                                             sigc::slot<void>(), // child setup
+                                             &child,
+                                             0, // stdin
+                                             &this->lsb_fd); // stdout
+            } catch (Glib::SpawnError &e) {
+                g_error("g_spawn_async_with_pipes error: %s", e.what().c_str());
+                return;
+            }
+
+            sigc::slot<void,GPid, int> slot = sigc::mem_fun(this, &LSBSysInfo::read_lsb);
+            this->child_watch = Glib::signal_child_watch().connect(slot, child);
+        }
+
+
+        void sync_lsb_release()<--- Unused private function: 'LSBSysInfo::sync_lsb_release'
+        {
+            char *out= 0;
+            GError *error = 0;
+            int status;
+
+            if (g_spawn_command_line_sync("lsb_release -irc",
+                                          &out,
+                                          0,
+                                          &status,
+                                          &error)) {
+                string release, codename;<--- Shadow variable
+                if (!error and WIFEXITED(status) and WEXITSTATUS(status) == 0) {
+                    std::istringstream input(out);
+                    this->get_value(input, this->distro_name)
+                        and this->get_value(input, release)
+                        and this->get_value(input, codename);
+                    this->distro_release = release;
+                if (codename != "" && codename != "n/a")
+                    this->distro_release += " (" + codename + ')';
+                }
+            }
+
+            if (error)
+                g_error_free(error);
+
+            g_free(out);
+        }
+
+    private:
+        Glib::RefPtr<Glib::Regex> re;
+    };
+
+
+    class NetBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        NetBSDSysInfo()
+        {
+            this->load_netbsd_info();
+        }
+
+    private:
+        void load_netbsd_info()
+        {
+            this->distro_name = "NetBSD";
+
+            std::ifstream input("/etc/release");
+
+            if (input)
+                std::getline(input, this->distro_release);
+        }
+    };
+
+
+    class GenericSysInfo
+        : public SysInfo
+    {
+    public:
+        GenericSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            std::ifstream input("/etc/os-release");
+
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int start;
+                    std::getline(input, s);
+                    if (s.find("NAME=") == 0) {
+                        start = strlen("NAME=");
+                        if ((s.at(start) == '\"') && (s.at(s.size() - 1) == '\"')) {
+                            this->distro_name = s.substr(start + 1, s.size() - start - 2);
+                        } else {
+                            this->distro_name = s.substr(start);
+                        }
+                    } else if (s.find("VERSION=") == 0) {
+                        start = strlen("VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    } else if (s.find("# VERSION=") == 0) {
+                        start = strlen("# VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    }
+                }
+                input.close();
+                input.clear();
+            }
+            if (this->distro_release.empty()) {
+                input.open("/etc/debian_version");
+                if (input) {
+                    getline(input, this->distro_release);
+                }
+            }
+        }
+    };
+
+    class MintSysInfo
+        : public SysInfo
+    {
+    public:
+        MintSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            this->distro_name = "Linux Mint";
+            std::ifstream input("/etc/linuxmint/info");
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int len;
+                    std::getline(input, s);
+                    if (s.find("DESCRIPTION=") == 0) {
+                        len = strlen("DESCRIPTION=");
+                        // also strip the surrounding quotes
+                       this->distro_release = s.substr(len + 1, s.size() - len - 2);
+                   }
+                }
+            }
+        }
+    };
+
+    class OpenBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        OpenBSDSysInfo()
+        {
+            this->load_openbsd_info();
+        }
+
+    private:
+        void load_openbsd_info()
+        {
+            this->distro_name = "OpenBSD";
+            this->distro_release = this->kernel;
+
+            std::ifstream input("/etc/motd");
+
+            if (input)
+                std::getline(input, this->kernel);
+        }
+    };
+
+    SysInfo* get_sysinfo()
+    {
+        if (g_file_test ("/etc/linuxmint/info", G_FILE_TEST_EXISTS)) {
+            return new MintSysInfo;
+        }
+        else if (g_file_test ("/etc/os-release", G_FILE_TEST_EXISTS)) {
+            return new GenericSysInfo;
+        }
+        else if (char *p = g_find_program_in_path("lsb_release")) {
+            g_free(p);
+            return new LSBSysInfo;
+        }
+        else if (SysInfo::system() == "FreeBSD") {
+            return new FreeBSDSysInfo;
+        }
+        else if (SysInfo::system() == "SunOS") {
+            return new SolarisSysInfo;
+        }
+        else if (SysInfo::system() == "NetBSD") {
+            return new NetBSDSysInfo;
+        }
+        else if (SysInfo::system() == "OpenBSD") {
+            return new OpenBSDSysInfo;
+        }
+
+        return new SysInfo;
+    }
+}
+
+
+#define X_PAD  0
+#define Y_PAD  0
+#define LOGO_W 92
+#define LOGO_H 351
+#define RADIUS 5
+
+static gboolean sysinfo_logo_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    GtkStyle *style;
+    cairo_t *cr;
+    cairo_pattern_t *cp;
+
+    cr = gdk_cairo_create(gtk_widget_get_window(widget));
+
+    gtk_widget_get_allocation (widget, &allocation);
+    cairo_translate(cr, allocation.x, allocation.y);
+
+    cairo_move_to(cr, X_PAD + RADIUS, Y_PAD);
+    cairo_line_to(cr, X_PAD + LOGO_W - RADIUS, Y_PAD);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + RADIUS, RADIUS, -0.5 * M_PI, 0);
+    cairo_line_to(cr, X_PAD + LOGO_W, Y_PAD + LOGO_H - RADIUS);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0, 0.5 * M_PI);
+    cairo_line_to(cr, X_PAD + RADIUS, Y_PAD + LOGO_H);
+    cairo_arc(cr, X_PAD + RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0.5 * M_PI, -1.0 * M_PI);
+    cairo_line_to(cr, X_PAD, Y_PAD + RADIUS);
+    cairo_arc(cr,  X_PAD + RADIUS, Y_PAD + RADIUS, RADIUS, -1.0 * M_PI, -0.5 * M_PI);
+
+    cp = cairo_pattern_create_linear(0, Y_PAD, 0, Y_PAD + LOGO_H);
+    style = gtk_widget_get_style (widget);
+    cairo_pattern_add_color_stop_rgba(cp, 0.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      1.0);
+    cairo_pattern_add_color_stop_rgba(cp, 1.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      0.0);
+    cairo_set_source(cr, cp);
+    cairo_fill(cr);
+
+    cairo_pattern_destroy(cp);
+    cairo_destroy(cr);
+
+    return FALSE;
+}
+
+static GtkWidget*
+add_section(GtkBox *vbox , const char * title, int num_row, int num_col, GtkWidget **out_frame)
+{
+    GtkWidget *table;
+
+    GtkWidget *frame = gtk_frame_new(title);
+    gtk_frame_set_label_align(GTK_FRAME(frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
+
+    table = gtk_grid_new();
+    gtk_grid_set_row_spacing(GTK_GRID(table), 6);
+    gtk_grid_set_column_spacing(GTK_GRID(table), 6);
+    gtk_widget_set_margin_start (GTK_WIDGET(table), 12);
+    gtk_container_set_border_width(GTK_CONTAINER(table), 6);
+    gtk_container_add(GTK_CONTAINER(frame), table);
+
+    if(out_frame)
+        *out_frame = frame;
+
+    return table;
+}
+
+
+static GtkWidget*
+add_row(GtkGrid * table, const char * label, const char * value, int row)
+{
+    GtkWidget *header = gtk_label_new(NULL);
+    gtk_label_set_markup(GTK_LABEL(header), label);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        table, header,
+        0, row, 1, 1);
+
+    GtkWidget *label_widget = gtk_label_new(value);
+    gtk_label_set_selectable(GTK_LABEL(label_widget), TRUE);
+    gtk_widget_set_can_focus(label_widget, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (label_widget), 0.0);
+    gtk_grid_attach(
+        table, label_widget,
+        1, row, 1, 1);
+
+    return label_widget;
+}
+
+
+static GtkWidget *
+procman_create_sysinfo_view(void)
+{
+    GtkWidget *hbox;
+    GtkWidget *vbox;
+
+    SysInfo *data = get_sysinfo();;
+
+    GtkWidget * logo;
+
+    GtkWidget *distro_frame;
+    GtkWidget *distro_release_label;
+    GtkWidget *distro_table;
+
+    GtkWidget *hardware_table;
+    GtkWidget *disk_space_table;
+
+    GtkWidget *header;
+
+    gchar *markup;
+
+    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);
+
+    /* left-side logo */
+    if (g_file_test (DATADIR "/pixmaps/mate-system-monitor/distribution/side.png", G_FILE_TEST_EXISTS)) {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/distribution/side.png");
+    }
+    else {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/side.png");
+    }
+    gtk_widget_set_valign (logo, GTK_ALIGN_START);
+    gtk_widget_set_margin_start (logo, 5);
+    gtk_widget_set_margin_end (logo, 5);
+    gtk_widget_set_margin_top (logo, 12);
+    gtk_widget_set_margin_bottom (logo, 12);
+    gtk_box_pack_start(GTK_BOX(hbox), logo, FALSE, FALSE, 0);
+
+    g_signal_connect(G_OBJECT(logo), "draw", G_CALLBACK(sysinfo_logo_draw), NULL);
+
+    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
+    gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
+
+    // hostname
+
+    markup = g_strdup_printf("<big><big><b><u>%s</u></b></big></big>",
+                             data->hostname.c_str());
+    GtkWidget *hostname_frame = gtk_frame_new(markup);
+    g_free(markup);
+    gtk_frame_set_label_align(GTK_FRAME(hostname_frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(hostname_frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(hostname_frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), hostname_frame, FALSE, FALSE, 0);
+
+
+    /* distro section */
+
+    unsigned table_size = 2;
+    if (data->mate_version != "")
+        table_size++;
+    distro_table = add_section(GTK_BOX(vbox), "???", table_size, 1, &distro_frame);
+
+    unsigned table_count = 0;
+
+    distro_release_label = gtk_label_new("???");
+    gtk_label_set_selectable(GTK_LABEL(distro_release_label), TRUE);
+    gtk_widget_set_can_focus(distro_release_label, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (distro_release_label), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), distro_release_label,
+        0, table_count, 1, 1);
+    table_count++;
+    data->set_distro_labels(gtk_frame_get_label_widget(GTK_FRAME(distro_frame)), distro_release_label);
+
+    markup = g_strdup_printf(_("Kernel %s"), data->kernel.c_str());
+    header = gtk_label_new(markup);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    g_free(markup);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), header,
+        0, table_count, 1, 1);
+    table_count++;
+
+    if (data->mate_version != "")
+    {
+        markup = g_strdup_printf(_("MATE %s"), data->mate_version.c_str());
+        header = gtk_label_new(markup);
+        gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+        gtk_widget_set_can_focus(header, FALSE);
+        g_free(markup);
+        gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+        gtk_grid_attach(
+            GTK_GRID(distro_table), header,
+            0, table_count, 1, 1);
+        table_count++;<--- Variable 'table_count' is assigned a value that is never used.
+    }
+
+    /* hardware section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("Hardware"));
+    hardware_table = add_section(GTK_BOX(vbox), markup, 1, 3, NULL);
+    g_free(markup);
+
+    markup = g_format_size_full(data->memory_bytes, G_FORMAT_SIZE_IEC_UNITS);
+    add_row(GTK_GRID(hardware_table), _("Memory:"), markup, 0);
+    g_free(markup);
+
+    add_row(GTK_GRID(hardware_table), _("Processor:"),
+            data->processors.c_str(), 1);
+    add_row(GTK_GRID(hardware_table), _("Graphics:"),
+            data->graphics.c_str(), 2);
+
+    /* disk space section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("System Status"));
+    disk_space_table = add_section(GTK_BOX(vbox), markup, 1, 2, NULL);
+    g_free(markup);
+
+    markup = g_format_size(data->free_space_bytes);
+    add_row(GTK_GRID(disk_space_table), _("Available disk space:"), markup, 0);
+    g_free(markup);
+
+    return hbox;
+}
+
+
+
+namespace procman
+{
+    void build_sysinfo_ui()
+    {
+        static GtkWidget* ui;
+
+        if (!ui) {
+            ProcData* procdata = ProcData::get_instance();
+            ui = procman_create_sysinfo_view();
+            GtkBox* box = GTK_BOX(gtk_notebook_get_nth_page(GTK_NOTEBOOK(procdata->notebook),
+                                                            PROCMAN_TAB_SYSINFO));
+            gtk_box_pack_start(box, ui, TRUE, TRUE, 0);
+            gtk_widget_show_all(ui);
+        }
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/2.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/2.html new file mode 100644 index 00000000..0154b48f --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/2.html @@ -0,0 +1,489 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
#ifndef _PROCMAN_LOAD_GRAPH_H_
+#define _PROCMAN_LOAD_GRAPH_H_
+
+#include <glib.h>
+#include <glibtop/cpu.h>
+
+enum
+{
+    LOAD_GRAPH_CPU,
+    LOAD_GRAPH_MEM,
+    LOAD_GRAPH_NET
+};
+
+enum {
+    CPU_TOTAL,
+    CPU_USED,
+    N_CPU_STATES
+};
+
+struct LoadGraphLabels
+{
+    GtkWidget *cpu[GLIBTOP_NCPU];
+    GtkWidget *memory;
+    GtkWidget *swap;
+    GtkWidget *net_in;
+    GtkWidget *net_in_total;
+    GtkWidget *net_out;
+    GtkWidget *net_out_total;
+};
+
+struct LoadGraph {
+
+    static const unsigned NUM_POINTS = 60 + 2;
+    static const unsigned GRAPH_MIN_HEIGHT = 40;
+
+    LoadGraph(guint type);
+    ~LoadGraph();
+
+    unsigned num_bars() const;
+    void clear_background();
+
+    double fontsize;
+    double rmargin;
+    double indent;
+
+    guint n;
+    gint type;
+    guint speed;
+    guint draw_width, draw_height;
+    guint render_counter;
+    guint frames_per_unit;
+    guint graph_dely;
+    guint real_draw_height;
+    double graph_delx;
+    guint graph_buffer_offset;
+
+    std::vector<GdkRGBA> colors;
+
+    std::vector<float> data_block;
+    gfloat* data[NUM_POINTS];
+
+    GtkWidget *main_widget;
+    GtkWidget *disp;
+
+    cairo_pattern_t *background;
+
+    guint timer_index;
+
+    gboolean draw;
+
+    LoadGraphLabels labels;
+    GtkWidget *mem_color_picker;
+    GtkWidget *swap_color_picker;
+
+    /* union { */
+        struct {
+            guint now; /* 0 -> current, 1 -> last
+                    now ^ 1 each time */
+            /* times[now], times[now ^ 1] is last */
+            guint64 times[2][GLIBTOP_NCPU][N_CPU_STATES];
+        } cpu;
+
+        struct {
+            guint64 last_in, last_out;
+#if GLIB_CHECK_VERSION(2,61,2)
+            gint64 time;
+#else
+            GTimeVal time;
+#endif
+            guint64 max;
+            unsigned values[NUM_POINTS];
+            size_t cur;
+        } net;
+    /* }; */
+};
+
+/* Force a drawing update */
+void
+load_graph_queue_draw (LoadGraph *g);
+
+/* Start load graph. */
+void
+load_graph_start (LoadGraph *g);
+
+/* Stop load graph. */
+void
+load_graph_stop (LoadGraph *g);
+
+/* Change load graph speed and restart it if it has been previously started */
+void
+load_graph_change_speed (LoadGraph *g,
+                         guint new_speed);
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+#endif /* _PROCMAN_LOAD_GRAPH_H_ */
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/3.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/3.html new file mode 100644 index 00000000..e0d59e5d --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/3.html @@ -0,0 +1,645 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
#include <config.h>
+
+#include <cstring>
+#include <glib/gi18n.h>
+
+#include "cgroups.h"
+#include "util.h"
+
+gboolean
+cgroups_enabled(void)
+{
+    static gboolean initialized = FALSE;
+    static gboolean has_cgroups;
+
+    if (!initialized) {
+        initialized = TRUE;
+        has_cgroups = g_file_test("/proc/cgroups", G_FILE_TEST_EXISTS);
+    }
+
+    return has_cgroups;
+}
+
+static void
+append_cgroup_name(char *line, gchar **current_cgroup_name)
+{
+    gchar *controller, *path, *tmp, *path_plus_space;
+    int paren_offset, off, tmp_size;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return;
+
+    *(path - 1) = '\0';
+    g_strdelimit(controller, ",", '/');
+
+    if ((std::strcmp(path, "/") == 0) || (std::strncmp(controller, "name=", 5) == 0))
+        return;
+
+    if (*current_cgroup_name == NULL) {
+        *current_cgroup_name = g_strdup_printf("%s (%s)", path, controller);
+        return;
+    }
+
+    /* add a space to the end of the path string */
+    path_plus_space = g_strdup_printf("%s ", path);
+
+    if ((tmp = g_strstr_len(*current_cgroup_name, -1, path_plus_space))) {
+        tmp_size = strlen(*current_cgroup_name) + strlen(controller) + 1;
+        paren_offset = g_strstr_len(tmp + strlen(path), -1, ")") - *current_cgroup_name;
+        *(*current_cgroup_name + paren_offset) = '\0';
+        tmp = (gchar *)g_strnfill(tmp_size, '\0');
+        off = g_strlcat(tmp, *current_cgroup_name, tmp_size);
+        *(tmp + off) = '/';
+        off++;
+        off += g_strlcat(tmp + off, controller, tmp_size);
+        *(tmp + off) = ')';
+        off++;
+        g_strlcat(tmp + off, *current_cgroup_name + paren_offset + 1, tmp_size);
+    } else
+        tmp = g_strdup_printf("%s, %s(%s)", *current_cgroup_name, path_plus_space, controller);
+
+    g_free(path_plus_space);
+    g_free(*current_cgroup_name);
+    *current_cgroup_name = tmp;
+}
+
+static int
+check_cgroup_changed(gchar *line, gchar *current_cgroup_set)
+{
+    /* check if line is contained in current_cgroup_set */
+    gchar *controller, *path, *tmp, *found, *close_paren, *open_paren;
+    int ret = 0;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return 1;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return 1;
+
+    *(path - 1) = '\0';
+
+    if (std::strncmp(controller, "name=", 5) == 0)
+        goto out;
+
+    /* if there are multiple controllers just report string has changed */
+    if (g_strstr_len(controller, -1, ",")) {
+        ret = 1;
+        goto out;
+    }
+
+    if (!current_cgroup_set) {
+        if (std::strcmp(path, "/") != 0)
+            ret = 1;
+        goto out;
+    }
+
+    /* special case for root cgroup */
+    tmp = current_cgroup_set;
+    if (std::strcmp(path, "/") == 0) {
+        while ((found = g_strstr_len(tmp, -1, controller))) {
+            close_paren = g_strstr_len(found, -1, ")");
+            open_paren = g_strstr_len(found, -1, "(");
+            if (close_paren) {
+                if (!open_paren || (close_paren < open_paren)) {
+                    ret = 1;
+                    goto out;
+                }
+            }
+            tmp = found + strlen(controller);
+        }
+        goto out;
+    }
+
+    tmp = current_cgroup_set;
+    while ((found = g_strstr_len(tmp, -1, path))) {
+            found = found + strlen(path);
+            close_paren = g_strstr_len(found, -1, ")");
+            if (*found == ' ') {
+                if (g_strstr_len(found + 1, close_paren - found, controller))
+                    goto out;
+            }
+            tmp = close_paren + 1;
+    }
+    ret = 1;
+out:
+    *(path - 1) = ':';
+    return ret;
+}
+
+void
+get_process_cgroup_info(ProcInfo *info)
+{
+    gchar *path;
+    gchar *cgroup_name = NULL;
+    int cgroups_changed = 0;
+    gchar *text;
+    char **lines;
+    int i;
+
+    if (!cgroups_enabled())
+        return;
+
+    /* read out of /proc/pid/cgroup */
+    path = g_strdup_printf("/proc/%d/cgroup", info->pid);
+    if (!path)
+        return;
+    if(!g_file_get_contents(path, &text, NULL, NULL))
+        goto out;
+    lines = g_strsplit(text, "\n", -1);
+    g_free(text);
+    if (!lines)
+        goto out;
+
+    for (i = 0; lines[i] != NULL; i++) {
+        if (lines[i][0] == '\0')
+            continue;
+        if (check_cgroup_changed(lines[i], info->cgroup_name)) {
+            cgroups_changed = 1;
+            break;
+        }
+    }
+
+    if (cgroups_changed) {
+        for (i = 0; lines[i] != NULL; i++) {
+            if (lines[i][0] == '\0')
+                continue;
+            append_cgroup_name(lines[i], &cgroup_name);
+        }
+        if (info->cgroup_name)
+            g_free(info->cgroup_name);
+        if (!cgroup_name)
+            info->cgroup_name = g_strdup("");
+        else
+            info->cgroup_name = cgroup_name;
+    }
+
+    g_strfreev(lines);
+out:
+    g_free(path);
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/4.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/4.html new file mode 100644 index 00000000..cc9dbf88 --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/4.html @@ -0,0 +1,1277 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
#include <config.h>
+
+#ifdef __linux__
+#include <mntent.h>
+#endif // __linux__
+
+#include <giomm.h>
+#include <giomm/themedicon.h>
+#include <gtk/gtk.h>
+#include <glibtop/mountlist.h>
+#include <glibtop/fsusage.h>
+#include <glib/gi18n.h>
+
+#include "procman.h"
+#include "disks.h"
+#include "util.h"
+#include "interface.h"
+#include "iconthemewrapper.h"
+
+namespace
+{
+  const unsigned DISK_ICON_SIZE = 24;
+}
+
+enum DiskColumns
+{
+    /* string columns* */
+    DISK_DEVICE,
+    DISK_DIR,
+    DISK_TYPE,
+    DISK_SUBVOLUME,
+    DISK_TOTAL,
+    DISK_FREE,
+    DISK_AVAIL,
+    /* USED has to be the last column */
+    DISK_USED,
+    // then unvisible columns
+    /* Surface column */
+    DISK_ICON,
+    /* numeric columns */
+    DISK_USED_PERCENTAGE,
+    DISK_N_COLUMNS
+};
+
+
+
+static void
+fsusage_stats(const glibtop_fsusage *buf,
+              guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
+              gint *percentage)
+{
+    guint64 total = buf->blocks * buf->block_size;
+
+    if (!total) {
+        /* not a real device */
+        *btotal = *bfree = *bavail = *bused = 0ULL;
+        *percentage = 0;
+    } else {
+        int percent;
+        *btotal = total;
+        *bfree = buf->bfree * buf->block_size;
+        *bavail = buf->bavail * buf->block_size;
+        *bused = *btotal - *bfree;
+        /* percent = 100.0f * *bused / *btotal; */
+        percent = 100 * *bused / (*bused + *bavail);
+        *percentage = CLAMP(percent, 0, 100);
+    }
+}
+
+
+namespace
+{
+    string get_icon_for_path(const std::string& path)
+    {
+        using namespace Glib;
+        using namespace Gio;
+
+        // FIXME: I don't know whether i should use Volume or Mount or UnixMount
+        // all i need an icon name.
+        RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+        std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
+
+        for (size_t i = 0; i != mounts.size(); ++i) {
+            if (mounts[i]->get_name() != path)
+                continue;
+
+            RefPtr<Icon> icon = mounts[i]->get_icon();
+            RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
+
+            if (themed_icon) {
+                char* name = 0;
+                // FIXME: not wrapped yet
+                g_object_get(G_OBJECT(themed_icon->gobj()), "name", &name, NULL);
+                return make_string(name);
+            }
+        }
+
+        return "";
+    }
+}
+
+
+static Glib::RefPtr<Gdk::Pixbuf>
+get_icon_for_device(const char *mountpoint)
+{
+    procman::IconThemeWrapper icon_theme;
+    string icon_name = get_icon_for_path(mountpoint);
+    if (icon_name == "")
+        // FIXME: defaults to a safe value
+        icon_name = "drive-harddisk"; // get_icon_for_path("/");
+    return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
+}
+
+
+static gboolean
+find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
+                   GtkTreeIter *result)
+{
+    GtkTreeIter iter;
+    gboolean found = FALSE;
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        do {
+            char *dir;
+
+            gtk_tree_model_get(model, &iter,
+                               DISK_DIR, &dir,
+                               -1);
+
+            if (dir && !strcmp(dir, mountpoint)) {
+                *result = iter;
+                found = TRUE;
+            }
+
+            g_free(dir);
+
+        } while (!found && gtk_tree_model_iter_next(model, &iter));
+    }
+
+    return found;
+}
+
+
+
+static void
+remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
+{
+    GtkTreeIter iter;
+
+    if (!gtk_tree_model_get_iter_first(model, &iter))
+        return;
+
+    while (true) {
+        char *dir;
+        guint i;
+        gboolean found = FALSE;
+
+        gtk_tree_model_get(model, &iter,
+                           DISK_DIR, &dir,
+                           -1);
+
+        for (i = 0; i != n; ++i) {
+            if (!strcmp(dir, entries[i].mountdir)) {
+                found = TRUE;
+                break;
+            }
+        }
+
+        g_free(dir);
+
+        if (!found) {
+            if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                break;
+            else
+                continue;
+        }
+
+        if (!gtk_tree_model_iter_next(model, &iter))
+            break;
+    }
+}
+
+#ifdef __linux__
+static char *
+get_mount_opt(const glibtop_mountentry *entry, const char* opt)
+{
+    char *opt_value = NULL;
+    const struct mntent *mnt;
+    FILE *fp;
+
+    if (!(fp = setmntent(MOUNTED, "r"))) {
+        goto out;
+    }
+
+    while ((mnt = getmntent(fp))) {
+        if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
+            (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
+            char *res;
+
+            res = hasmntopt(mnt, "subvol");<--- res is assigned
+            if ((res = hasmntopt(mnt, "subvol")) != NULL) {<--- res is overwritten
+                char **strs = g_strsplit_set(res, "=", 2);
+
+                if (g_strv_length(strs) == 2) {
+                    char *value = strs[1];
+                    if (g_strcmp0 (value,"/root") == 0)
+                       opt_value = g_strdup("/");
+                    else
+                        opt_value = g_strdup(strs[1]);
+                    g_strfreev(strs);
+                }
+            }
+            break;
+        }
+    }
+
+    endmntent(fp);
+
+  out:
+     return opt_value;
+}
+#endif // __linux__
+
+
+static void
+add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
+{
+    Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+    cairo_surface_t *surface;
+    GtkTreeIter iter;
+    glibtop_fsusage usage;
+    guint64 bused, bfree, bavail, btotal;
+    gint percentage;
+#ifdef __linux__
+    char *subvol = NULL;
+#endif // __linux__
+
+    glibtop_get_fsusage(&usage, entry->mountdir);
+
+    if (not show_all_fs and usage.blocks == 0) {
+        if (find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+            gtk_list_store_remove(list, &iter);
+        return;
+    }
+
+    fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
+#ifdef __linux__
+    subvol = get_mount_opt(entry, "subvol");
+#endif // __linux__
+    pixbuf = get_icon_for_device(entry->mountdir);
+    surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL);
+
+    /* if we can find a row with the same mountpoint, we get it but we
+       still need to update all the fields.
+       This makes selection persistent.
+    */
+    if (!find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+        gtk_list_store_append(list, &iter);
+
+    gtk_list_store_set(list, &iter,
+                       DISK_ICON, surface,
+                       DISK_DEVICE, entry->devname,
+                       DISK_DIR, entry->mountdir,
+                       DISK_TYPE, entry->type,
+#ifdef __linux__
+
+                       DISK_SUBVOLUME, subvol != NULL ? subvol : "",
+#else
+                       DISK_SUBVOLUME, "",
+#endif // __linux__
+                       DISK_USED_PERCENTAGE, percentage,
+                       DISK_TOTAL, btotal,
+                       DISK_FREE, bfree,
+                       DISK_AVAIL, bavail,
+                       DISK_USED, bused,
+                       -1);
+#ifdef __linux__
+    g_free (subvol);
+#endif // __linux__
+}
+
+
+
+int
+cb_update_disks(gpointer data)
+{
+    ProcData *const procdata = static_cast<ProcData*>(data);
+
+    GtkListStore *list;
+    glibtop_mountentry * entries;
+    glibtop_mountlist mountlist;
+    guint i;
+
+    list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)));
+
+    entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
+
+    remove_old_disks(GTK_TREE_MODEL(list), entries, mountlist.number);
+
+    for (i = 0; i < mountlist.number; i++)
+        add_disk(list, &entries[i], procdata->config.show_all_fs);
+
+    g_free(entries);
+
+    return TRUE;
+}
+
+
+static void
+cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "disktreenew");
+}
+
+
+static void
+open_dir(GtkTreeView       *tree_view,
+         GtkTreePath       *path,
+         GtkTreeViewColumn *column,
+         gpointer           user_data)
+{
+    GtkTreeIter iter;
+    GtkTreeModel *model;
+    char *dir, *url;
+
+    model = gtk_tree_view_get_model(tree_view);
+
+    if (!gtk_tree_model_get_iter(model, &iter, path)) {
+        char *p;
+        p = gtk_tree_path_to_string(path);
+        g_warning("Cannot get iter for path '%s'\n", p);
+        g_free(p);
+        return;
+    }
+
+    gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
+
+    url = g_strdup_printf("file://%s", dir);
+
+    GError* error = 0;
+    if (!g_app_info_launch_default_for_uri(url, NULL, &error)) {
+        g_warning("Cannot open '%s' : %s\n", url, error->message);
+        g_error_free(error);
+    }
+
+    g_free(url);
+    g_free(dir);
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "disktreenew");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+void
+create_disk_view(ProcData *procdata, GtkBuilder *builder)
+{
+    GtkWidget *scrolled;
+    GtkWidget *disk_tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *col;
+    GtkCellRenderer *cell;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Device"),
+        N_("Directory"),
+        N_("Type"),
+        N_("SubVolume"),
+        N_("Total"),
+        N_("Free"),
+        N_("Available"),
+        N_("Used")
+    };
+
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"));
+
+    model = gtk_list_store_new(DISK_N_COLUMNS,             /* n columns */
+                               G_TYPE_STRING,              /* DISK_DEVICE */
+                               G_TYPE_STRING,              /* DISK_DIR */
+                               G_TYPE_STRING,              /* DISK_TYPE */
+                               G_TYPE_STRING,              /* DISK_SUBVOLUME */
+                               G_TYPE_UINT64,              /* DISK_TOTAL */
+                               G_TYPE_UINT64,              /* DISK_FREE */
+                               G_TYPE_UINT64,              /* DISK_AVAIL */
+                               G_TYPE_UINT64,              /* DISK_USED */
+                               CAIRO_GOBJECT_TYPE_SURFACE, /* DISK_ICON */
+                               G_TYPE_INT);                /* DISK_USED_PERCENTAGE */
+
+    disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL);
+    procdata->disk_list = disk_tree;
+    gtk_container_add(GTK_CONTAINER(scrolled), disk_tree);
+    g_object_unref(G_OBJECT(model));
+
+    /* icon + device */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
+                                        NULL);
+
+    cell = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
+                                        NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 30);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* sizes - used */
+
+    for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_min_width (col, 30);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+        switch (i) {
+            case DISK_TOTAL:
+            case DISK_FREE:
+            case DISK_AVAIL:
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+        default:
+            gtk_tree_view_column_set_attributes(col, cell,
+                                                "text", i,
+                                                NULL);
+            break;
+        }
+    }
+
+    /* used + percentage */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_text_new();
+    g_object_set(cell, "xalign", 1.0f, NULL);
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_cell_data_func(col, cell,
+                                            &procman::storage_size_cell_data_func,
+                                            GUINT_TO_POINTER(DISK_USED),
+                                            NULL);
+
+    cell = gtk_cell_renderer_progress_new();
+    gtk_tree_view_column_pack_start(col, cell, TRUE);
+    gtk_tree_view_column_set_attributes(col, cell, "value",
+                                        DISK_USED_PERCENTAGE, NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_USED]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 150);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* numeric sort */
+
+    procman_get_tree_state(procdata->settings, disk_tree,
+                   "disktreenew");
+
+    g_signal_connect (G_OBJECT(disk_tree), "columns-changed",
+                      G_CALLBACK(cb_disk_columns_changed), procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/5.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/5.html new file mode 100644 index 00000000..17de817b --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/5.html @@ -0,0 +1,2141 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
+852
+853
+854
+855
+856
+857
+858
+859
+860
+861
+862
+863
+864
+865
+866
+867
+868
+869
+870
+871
+872
+873
+874
+875
+876
+877
+878
+879
+880
+881
+882
+883
+884
+885
+886
+887
+888
+889
+890
+891
+892
+893
+894
+895
+896
+897
+898
+899
+900
+901
+902
+903
+904
+905
+906
+907
+908
+909
+910
+911
+912
+913
+914
+915
+916
+917
+918
+919
+920
+921
+922
+923
+924
+925
+926
+927
+928
+929
+930
+931
+932
+933
+934
+935
+936
+937
+938
+939
+940
+941
+942
+943
+944
+945
+946
/*
+ * Mate system monitor color pickers
+ * Copyright (C) 2007 Karl Lattimer <karl@qdh.org.uk>
+ * Copyright (C) 2012-2021 MATE Developers
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with the software; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <gdk/gdkkeysyms.h>
+#include <math.h>
+#include <cairo.h>
+#include <librsvg/rsvg.h>
+
+#include "gsm_color_button.h"
+
+typedef struct {
+    GtkWidget *cc_dialog;		/* Color chooser dialog */
+
+    gchar *title;            /* Title for the color selection window */
+
+    GdkRGBA color;
+
+    gdouble fraction;        /* Only used by GSMCP_TYPE_PIE */
+    guint type;
+    cairo_surface_t *image_buffer;
+    gdouble highlight;
+    gboolean button_down;
+    gboolean in_button;
+} GSMColorButtonPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GSMColorButton, gsm_color_button, GTK_TYPE_DRAWING_AREA)
+
+/* Properties */
+enum
+{
+    PROP_0,
+    PROP_PERCENTAGE,
+    PROP_TITLE,
+    PROP_COLOR,
+    PROP_TYPE
+};
+
+/* Signals */
+enum
+{
+    COLOR_SET,
+    LAST_SIGNAL
+};
+
+#define GSMCP_MIN_WIDTH 15
+#define GSMCP_MIN_HEIGHT 15
+
+static void gsm_color_button_finalize (GObject * object);
+static void gsm_color_button_set_property (GObject * object, guint param_id,
+                                           const GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_get_property (GObject * object, guint param_id,
+                                           GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_realize (GtkWidget * widget);
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width);
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height);
+static void gsm_color_button_size_allocate (GtkWidget * widget,
+                                            GtkAllocation * allocation);
+static void gsm_color_button_unrealize (GtkWidget * widget);
+static void gsm_color_button_state_changed (GtkWidget * widget,
+                                            GtkStateType previous_state);
+static void gsm_color_button_style_set (GtkWidget * widget,
+                                        GtkStyle * previous_style);
+static gint gsm_color_button_pressed (GtkWidget * widget,
+                                      GdkEventButton * event);
+static gint gsm_color_button_released (GtkWidget * widget,
+                                       GdkEventButton * event);
+static gboolean gsm_color_button_enter_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+static gboolean gsm_color_button_leave_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+/* source side drag signals */
+static void gsm_color_button_drag_begin (GtkWidget * widget,
+                                         GdkDragContext * context,
+                                         gpointer data);
+static void gsm_color_button_drag_data_get (GtkWidget * widget,
+                                            GdkDragContext * context,
+                                            GtkSelectionData * selection_data,
+                                            guint info, guint time,
+                                            GSMColorButton * color_button);
+
+/* target side drag signals */
+static void gsm_color_button_drag_data_received (GtkWidget * widget,
+                                                 GdkDragContext * context,
+                                                 gint x,
+                                                 gint y,
+                                                 GtkSelectionData *
+                                                 selection_data, guint info,
+                                                 guint32 time,
+                                                 GSMColorButton *
+                                                 color_button);
+
+static guint color_button_signals[LAST_SIGNAL] = { 0 };
+
+static const GtkTargetEntry drop_types[] = { {"application/x-color", 0, 0} };
+
+static void
+gsm_color_button_class_init (GSMColorButtonClass * klass)
+{
+    GObjectClass *gobject_class;
+    GtkWidgetClass *widget_class;
+
+    gobject_class = G_OBJECT_CLASS (klass);
+    widget_class = GTK_WIDGET_CLASS (klass);
+
+    gobject_class->get_property = gsm_color_button_get_property;
+    gobject_class->set_property = gsm_color_button_set_property;
+    gobject_class->finalize = gsm_color_button_finalize;
+    widget_class->state_changed = gsm_color_button_state_changed;
+    widget_class->get_preferred_width = gsm_color_button_get_preferred_width;
+    widget_class->get_preferred_height = gsm_color_button_get_preferred_height;
+    widget_class->size_allocate = gsm_color_button_size_allocate;
+    widget_class->realize = gsm_color_button_realize;
+    widget_class->unrealize = gsm_color_button_unrealize;
+    widget_class->style_set = gsm_color_button_style_set;
+    widget_class->button_release_event = gsm_color_button_released;
+    widget_class->button_press_event = gsm_color_button_pressed;
+    widget_class->enter_notify_event = gsm_color_button_enter_notify;
+    widget_class->leave_notify_event = gsm_color_button_leave_notify;
+
+    klass->color_set = NULL;
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_PERCENTAGE,
+                                     g_param_spec_double ("fraction",
+                                                          _("Fraction"),
+                                     // TRANSLATORS: description of the pie color picker's (mem, swap) filled percentage property
+                                                          _("Percentage full for pie color pickers"),
+                                                          0, 1, 0.5,
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TITLE,
+                                     g_param_spec_string ("title",
+                                                          _("Title"),
+                                                          _("The title of the color selection dialog"),
+                                                          _("Pick a Color"),
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_COLOR,
+                                     g_param_spec_boxed ("color",
+                                                         _("Current Color"),
+                                                         _("The selected color"),
+                                                         GDK_TYPE_RGBA,
+                                                         G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TYPE,
+                                     g_param_spec_uint ("type", _("Type"),
+                                                        _("Type of color picker"),
+                                                        0, 4, 0,
+                                                        G_PARAM_READWRITE));
+
+    color_button_signals[COLOR_SET] = g_signal_new ("color_set",
+                                                    G_TYPE_FROM_CLASS
+                                                    (gobject_class),
+                                                    G_SIGNAL_RUN_FIRST,
+                                                    G_STRUCT_OFFSET
+                                                    (GSMColorButtonClass,
+                                                    color_set), NULL, NULL,
+                                                    g_cclosure_marshal_VOID__VOID,
+                                                    G_TYPE_NONE, 0);
+
+}
+
+static cairo_surface_t *
+fill_image_buffer_from_file (cairo_t *cr, const char *filePath)
+{
+    GError *error = NULL;
+    RsvgHandle *handle;
+    cairo_surface_t *tmp_surface;
+    cairo_t *tmp_cr;
+
+    handle = rsvg_handle_new_from_file (filePath, &error);
+
+    if (handle == NULL) {
+        g_warning("rsvg_handle_new_from_file(\"%s\") failed: %s",
+              filePath, (error ? error->message : "unknown error"));
+    if (error)
+          g_error_free(error);
+    return NULL;
+    }
+
+    tmp_surface = cairo_surface_create_similar (cairo_get_target (cr),
+                                                CAIRO_CONTENT_COLOR_ALPHA,
+                                                32, 32);
+    tmp_cr = cairo_create (tmp_surface);
+    rsvg_handle_render_cairo (handle, tmp_cr);
+    cairo_destroy (tmp_cr);
+    g_object_unref (handle);
+    return tmp_surface;
+}
+
+static void
+render (GtkWidget * widget)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GdkRGBA *color;
+    GdkRGBA tmp_color = priv->color;
+    color = &tmp_color;
+    cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
+    cairo_path_t *path = NULL;
+    gint width, height;
+    gdouble radius, arc_start, arc_end;
+    gdouble highlight_factor;
+
+    if (priv->highlight > 0) {
+        highlight_factor = 0.125 * priv->highlight;
+
+    if (color->red + highlight_factor > 1.0)
+        color->red = 1.0;
+    else
+        color->red = color->red + highlight_factor;
+
+    if (color->blue + highlight_factor > 1.0)
+        color->blue = 1.0;
+    else
+      color->blue = color->blue + highlight_factor;
+
+    if (color->green + highlight_factor > 1.0)
+        color->green = 1.0;
+    else
+        color->green = color->green + highlight_factor;
+    }
+    gdk_cairo_set_source_rgba (cr, color);
+
+    width = gdk_window_get_width(gtk_widget_get_window(widget));
+    height = gdk_window_get_height(gtk_widget_get_window(widget));
+
+    switch (priv->type)
+        {
+        case GSMCP_TYPE_CPU:
+            //gtk_widget_set_size_request (widget, GSMCP_MIN_WIDTH, GSMCP_MIN_HEIGHT);
+            cairo_paint (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1);
+            cairo_stroke (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.4);
+            cairo_rectangle (cr, 1.5, 1.5, width - 3, height - 3);
+            cairo_stroke (cr);
+            break;
+        case GSMCP_TYPE_PIE:
+            if (width < 32)        // 32px minimum size
+                gtk_widget_set_size_request (widget, 32, 32);
+            if (width < height)
+                radius = width / 2;
+            else
+                radius = height / 2;
+
+            arc_start = -G_PI_2 + 2 * G_PI * priv->fraction;
+            arc_end = -G_PI_2;
+
+            cairo_set_line_width (cr, 1);
+
+            // Draw external stroke and fill
+            if (priv->fraction < 0.01) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_end);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    arc_end, arc_start);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_start);
+            }
+            cairo_fill_preserve (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.7);
+            cairo_stroke (cr);
+
+            // Draw internal highlight
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.45);
+            cairo_set_line_width (cr, 1);
+
+            if (priv->fraction < 0.03) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_end - (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    arc_end - (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+            }
+            cairo_stroke (cr);
+
+            // Draw external shape
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.2);
+            cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 1.25, 0,
+                G_PI * 2);
+            cairo_stroke (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_IN:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                    fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/download.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 8.5, 1.5);
+            cairo_line_to (cr, 23.5, 1.5);
+            cairo_line_to (cr, 23.5, 11.5);
+            cairo_line_to (cr, 29.5, 11.5);
+            cairo_line_to (cr, 16.5, 27.5);
+            cairo_line_to (cr, 15.5, 27.5);
+            cairo_line_to (cr, 2.5, 11.5);
+            cairo_line_to (cr, 8.5, 11.5);
+            cairo_line_to (cr, 8.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_OUT:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/upload.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 16.5, 1.5);
+            cairo_line_to (cr, 29.5, 17.5);
+            cairo_line_to (cr, 23.5, 17.5);
+            cairo_line_to (cr, 23.5, 27.5);
+            cairo_line_to (cr, 8.5, 27.5);
+            cairo_line_to (cr, 8.5, 17.5);
+            cairo_line_to (cr, 2.5, 17.5);
+            cairo_line_to (cr, 15.5, 1.5);
+            cairo_line_to (cr, 16.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        }
+    cairo_destroy (cr);
+}
+
+/* Handle exposure events for the color picker's drawing area */
+static gboolean draw (GtkWidget * widget, cairo_t * cr, gpointer data)
+{
+    render (GTK_WIDGET (data));
+
+    return FALSE;
+}
+
+static void
+gsm_color_button_realize (GtkWidget * widget)
+{
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->realize (widget);
+    render (widget);
+}
+
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width)
+{
+    g_return_if_fail (widget != NULL && minimum_width != NULL && natural_width != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_width = GSMCP_MIN_WIDTH;
+    *natural_width = GSMCP_MIN_WIDTH;
+}
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height)
+{
+    g_return_if_fail (widget != NULL && minimum_height != NULL && natural_height != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_height = GSMCP_MIN_HEIGHT;
+    *natural_height = GSMCP_MIN_HEIGHT;
+}
+
+static void
+gsm_color_button_size_allocate (GtkWidget * widget,
+                                GtkAllocation * allocation)
+{
+    g_return_if_fail (widget != NULL || allocation != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    gtk_widget_set_allocation (widget, allocation);
+
+    if (gtk_widget_get_realized (widget))
+    {
+        gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y,
+                                allocation->width, allocation->height);
+    }
+}
+
+static void
+gsm_color_button_unrealize (GtkWidget * widget)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->unrealize (widget);
+}
+
+static void
+gsm_color_button_style_set (GtkWidget * widget, GtkStyle * previous_style)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->style_set (widget,
+                                                                 previous_style);
+
+}
+
+static void
+gsm_color_button_state_changed (GtkWidget * widget,
+                                GtkStateType previous_state)
+{
+}
+
+static void
+gsm_color_button_drag_data_received (GtkWidget * widget,
+                                     GdkDragContext * context,
+                                     gint x,
+                                     gint y,
+                                     GtkSelectionData * selection_data,
+                                     guint info,
+                                     guint32 time,
+                                     GSMColorButton * color_button)
+{
+    gint length;
+    guint16 *dropped;
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    length = gtk_selection_data_get_length (selection_data);
+
+    if (length < 0)
+        return;
+
+    /* We accept drops with the wrong format, since the KDE color
+     * chooser incorrectly drops application/x-color with format 8.
+     */
+    if (length != 8)
+    {
+        g_warning (_("Received invalid color data\n"));
+        return;
+    }
+
+    dropped = (guint16 *) gtk_selection_data_get_data (selection_data);
+
+    priv->color.red =   ((double) dropped[0]) / 65535.0;
+    priv->color.green = ((double) dropped[1]) / 65535.0;
+    priv->color.blue =  ((double) dropped[2]) / 65535.0;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+    g_object_freeze_notify (G_OBJECT (color_button));
+    g_object_notify (G_OBJECT (color_button), "color");
+    g_object_thaw_notify (G_OBJECT (color_button));
+}
+
+static void
+set_color_icon (GdkDragContext * context, GdkRGBA * color)
+{
+    GdkPixbuf *pixbuf;
+    guint32 pixel;
+
+    pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 48, 32);
+
+    pixel = ((guint32)(color->red * 0xff) << 24) |
+            ((guint32)(color->green * 0xff) << 16) |
+            ((guint32)(color->blue * 0xff) << 8);
+
+    gdk_pixbuf_fill (pixbuf, pixel);
+
+    gtk_drag_set_icon_pixbuf (context, pixbuf, -2, -2);
+    g_object_unref (pixbuf);
+}
+
+static void
+gsm_color_button_drag_begin (GtkWidget * widget,
+                             GdkDragContext * context, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = data;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    set_color_icon (context, &priv->color);
+}
+
+static void
+gsm_color_button_drag_data_get (GtkWidget * widget,
+                                GdkDragContext * context,
+                                GtkSelectionData * selection_data,
+                                guint info,
+                                guint time, GSMColorButton * color_button)
+{
+    guint16 dropped[4];
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    dropped[0] = (guint16) (65535.0 * priv->color.red);
+    dropped[1] = (guint16) (65535.0 * priv->color.green);
+    dropped[2] = (guint16) (65535.0 * priv->color.blue);
+    dropped[3] = 65535;        // This widget doesn't care about alpha
+
+    gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data),
+                            16, (guchar *) dropped, 8);
+}
+
+static void
+gsm_color_button_init (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = 0;
+    priv->color.green = 0;
+    priv->color.blue = 0;
+    priv->fraction = 0.5;
+    priv->type = GSMCP_TYPE_CPU;
+    priv->image_buffer = NULL;
+    priv->title = g_strdup (_("Pick a Color"));     /* default title */
+    priv->in_button = FALSE;
+    priv->button_down = FALSE;
+
+    gtk_drag_dest_set (GTK_WIDGET (color_button),
+                       GTK_DEST_DEFAULT_MOTION |
+                       GTK_DEST_DEFAULT_HIGHLIGHT |
+                       GTK_DEST_DEFAULT_DROP, drop_types, 1, GDK_ACTION_COPY);
+    gtk_drag_source_set (GTK_WIDGET (color_button),
+                         GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
+                         drop_types, 1, GDK_ACTION_COPY);
+    g_signal_connect (color_button, "drag_begin",
+                      G_CALLBACK (gsm_color_button_drag_begin), color_button);
+    g_signal_connect (color_button, "drag_data_received",
+                      G_CALLBACK (gsm_color_button_drag_data_received),
+                      color_button);
+    g_signal_connect (color_button, "drag_data_get",
+                      G_CALLBACK (gsm_color_button_drag_data_get),
+                      color_button);
+
+    gtk_widget_add_events (GTK_WIDGET(color_button), GDK_ENTER_NOTIFY_MASK
+                              | GDK_LEAVE_NOTIFY_MASK);
+
+    gtk_widget_set_tooltip_text (GTK_WIDGET(color_button), _("Click to set graph colors"));
+
+    g_signal_connect (color_button, "draw", G_CALLBACK (draw), color_button);
+}
+
+static void
+gsm_color_button_finalize (GObject * object)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    if (priv->cc_dialog != NULL)
+        gtk_widget_destroy (priv->cc_dialog);
+    priv->cc_dialog = NULL;
+
+    g_free (priv->title);
+    priv->title = NULL;
+
+    cairo_surface_destroy (priv->image_buffer);
+    priv->image_buffer = NULL;
+
+    G_OBJECT_CLASS (gsm_color_button_parent_class)->finalize (object);
+}
+
+GtkWidget *
+gsm_color_button_new (const GdkRGBA * color, guint type)
+{
+    return g_object_new (GSM_TYPE_COLOR_BUTTON, "color", color, "type", type,
+                         NULL);
+}
+
+static void
+dialog_response (GtkWidget * widget, GtkResponseType response, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GtkColorChooser *color_chooser;
+
+    if (response == GTK_RESPONSE_OK) {
+        color_chooser = GTK_COLOR_CHOOSER (priv->cc_dialog);
+
+        gtk_color_chooser_get_rgba (color_chooser, &priv->color);
+
+        gtk_widget_hide (priv->cc_dialog);
+
+        gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+        g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+        g_object_freeze_notify (G_OBJECT (color_button));
+        g_object_notify (G_OBJECT (color_button), "color");
+        g_object_thaw_notify (G_OBJECT (color_button));
+    }
+    else  /* (response == GTK_RESPONSE_CANCEL) */
+        gtk_widget_hide (priv->cc_dialog);
+}
+
+static gboolean
+dialog_destroy (GtkWidget * widget, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->cc_dialog = NULL;
+
+    return FALSE;
+}
+
+static gint
+gsm_color_button_clicked (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    /* if dialog already exists, make sure it's shown and raised */
+    if (!priv->cc_dialog)
+    {
+        /* Create the dialog and connects its buttons */
+        GtkWidget *cc_dialog;
+        GtkWidget *parent;
+
+        parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));
+        if (!gtk_widget_is_toplevel (parent))
+            parent = NULL;
+
+        cc_dialog = gtk_color_chooser_dialog_new (priv->title, GTK_WINDOW (parent));
+
+        gtk_window_set_modal (GTK_WINDOW (cc_dialog), TRUE);
+
+        g_signal_connect (cc_dialog, "response",
+                          G_CALLBACK (dialog_response), color_button);
+
+        g_signal_connect (cc_dialog, "destroy",
+                          G_CALLBACK (dialog_destroy), color_button);
+
+        priv->cc_dialog = cc_dialog;
+    }
+
+    gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (priv->cc_dialog),
+                                &priv->color);
+
+    gtk_window_present (GTK_WINDOW (priv->cc_dialog));
+
+    return 0;
+}
+
+static gint
+gsm_color_button_pressed (GtkWidget * widget, GdkEventButton * event)
+{
+    if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) )
+    {
+	GSMColorButtonPrivate *priv;
+        GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+	priv = gsm_color_button_get_instance_private (color_button);
+	priv->button_down = TRUE;
+    }
+  return 0;
+}
+
+static gint
+gsm_color_button_released (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    if (priv->button_down && priv->in_button)
+        gsm_color_button_clicked (widget, event);
+    priv->button_down = FALSE;
+    return 0;
+}
+
+static gboolean
+gsm_color_button_enter_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 1.0;
+    priv->in_button = TRUE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+static gboolean
+gsm_color_button_leave_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 0;
+    priv->in_button = FALSE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+guint
+gsm_color_button_get_cbtype (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->type;
+}
+
+void
+gsm_color_button_set_cbtype (GSMColorButton * color_button, guint type)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->type = type;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "type");
+}
+
+gdouble
+gsm_color_button_get_fraction (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->fraction;
+}
+
+void
+gsm_color_button_set_fraction (GSMColorButton * color_button,
+                               gdouble fraction)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->fraction = fraction;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "fraction");
+}
+
+void
+gsm_color_button_get_color (GSMColorButton * color_button, GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    color->red = priv->color.red;
+    color->green = priv->color.green;
+    color->blue = priv->color.blue;
+    color->alpha = priv->color.alpha;
+}
+
+void
+gsm_color_button_set_color (GSMColorButton * color_button,
+                            const GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    g_return_if_fail (color != NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = color->red;
+    priv->color.green = color->green;
+    priv->color.blue = color->blue;
+    priv->color.alpha = color->alpha;
+
+    gtk_widget_queue_draw (GTK_WIDGET (color_button));
+
+    g_object_notify (G_OBJECT (color_button), "color");
+}
+
+void
+gsm_color_button_set_title (GSMColorButton * color_button,
+                            const gchar * title)
+{
+    gchar *old_title;
+    GSMColorButtonPrivate *priv;
+
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    old_title = priv->title;
+    priv->title = g_strdup (title);
+    g_free (old_title);
+
+    if (priv->cc_dialog)
+        gtk_window_set_title (GTK_WINDOW (priv->cc_dialog),
+                              priv->title);
+
+    g_object_notify (G_OBJECT (color_button), "title");
+}
+
+const gchar* gsm_color_button_get_title(GSMColorButton* color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail(GSM_IS_COLOR_BUTTON(color_button), NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->title;
+}
+
+static void
+gsm_color_button_set_property (GObject * object,
+                               guint param_id,
+                               const GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            gsm_color_button_set_fraction (color_button,
+                                           g_value_get_double (value));
+            break;
+        case PROP_TITLE:
+            gsm_color_button_set_title (color_button, g_value_get_string (value));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_set_color (color_button, g_value_get_boxed (value));
+            break;
+        case PROP_TYPE:
+            gsm_color_button_set_cbtype (color_button, g_value_get_uint (value));
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+static void
+gsm_color_button_get_property (GObject * object,
+                               guint param_id,
+                               GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+    GdkRGBA color;
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            g_value_set_double (value,
+                                gsm_color_button_get_fraction (color_button));
+            break;
+        case PROP_TITLE:
+            g_value_set_string (value, gsm_color_button_get_title (color_button));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_get_color (color_button, &color);
+                                        g_value_set_boxed (value, &color);
+            break;
+        case PROP_TYPE:
+            g_value_set_uint (value, gsm_color_button_get_cbtype (color_button));
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/6.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/6.html new file mode 100644 index 00000000..f73c90ba --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/6.html @@ -0,0 +1,1599 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
/* Procman - main window
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <gdk/gdkkeysyms.h>
+#include <math.h>
+
+#include "procman.h"
+#include "callbacks.h"
+#include "interface.h"
+#include "proctable.h"
+#include "procactions.h"
+#include "load-graph.h"
+#include "util.h"
+#include "disks.h"
+#include "sysinfo.h"
+#include "gsm_color_button.h"
+
+static void    cb_toggle_tree (GtkAction *action, gpointer data);
+static void    cb_proc_goto_tab (gint tab);
+
+static const GtkActionEntry menu_entries[] =
+{
+    // xgettext: noun, top level menu.
+    // "File" did not make sense for system-monitor
+    { "Monitor", NULL, N_("_Monitor") },
+    { "Edit", NULL, N_("_Edit") },
+    { "View", NULL, N_("_View") },
+    { "Help", NULL, N_("_Help") },
+
+    { "Lsof", "edit-find", N_("Search for _Open Files"), "<control>O",
+      N_("Search for open files"), G_CALLBACK(cb_show_lsof) },
+    { "Quit", "application-exit", N_("_Quit"), "<control>Q",
+      N_("Quit the program"), G_CALLBACK (cb_app_exit) },
+
+
+    { "StopProcess", NULL, N_("_Stop Process"), "<control>S",
+      N_("Stop process"), G_CALLBACK(cb_kill_sigstop) },
+    { "ContProcess", NULL, N_("_Continue Process"), "<control>C",
+      N_("Continue process if stopped"), G_CALLBACK(cb_kill_sigcont) },
+
+    { "EndProcess", NULL, N_("_End Process"), "<control>E",
+      N_("Force process to finish normally"), G_CALLBACK (cb_end_process) },
+    { "KillProcess", NULL, N_("_Kill Process"), "<control>K",
+      N_("Force process to finish immediately"), G_CALLBACK (cb_kill_process) },
+    { "ChangePriority", NULL, N_("_Change Priority"), NULL,
+      N_("Change the order of priority of process"), NULL },
+    { "Preferences", "preferences-desktop", N_("_Preferences"), NULL,
+      N_("Configure the application"), G_CALLBACK (cb_edit_preferences) },
+
+    { "Refresh", "view-refresh", N_("_Refresh"), "<control>R",
+      N_("Refresh the process list"), G_CALLBACK(cb_user_refresh) },
+
+    { "MemoryMaps", NULL, N_("_Memory Maps"), "<control>M",
+      N_("Open the memory maps associated with a process"), G_CALLBACK (cb_show_memory_maps) },
+    // Translators: this means 'Files that are open' (open is no verb here
+    { "OpenFiles", NULL, N_("Open _Files"), "<control>F",
+      N_("View the files opened by a process"), G_CALLBACK (cb_show_open_files) },
+    { "ProcessProperties", NULL, N_("_Properties"), NULL,
+      N_("View additional information about a process"), G_CALLBACK (cb_show_process_properties) },
+
+
+    { "HelpContents", "help-browser", N_("_Contents"), "F1",
+      N_("Open the manual"), G_CALLBACK (cb_help_contents) },
+    { "About", "help-about", N_("_About"), NULL,
+      N_("About this application"), G_CALLBACK (cb_about) }
+};
+
+static const GtkToggleActionEntry toggle_menu_entries[] =
+{
+    { "ShowDependencies", NULL, N_("_Dependencies"), "<control>D",
+      N_("Show parent/child relationship between processes"),
+      G_CALLBACK (cb_toggle_tree), TRUE },
+};
+
+
+static const GtkRadioActionEntry radio_menu_entries[] =
+{
+  { "ShowActiveProcesses", NULL, N_("_Active Processes"), NULL,
+    N_("Show active processes"), ACTIVE_PROCESSES },
+  { "ShowAllProcesses", NULL, N_("A_ll Processes"), NULL,
+    N_("Show all processes"), ALL_PROCESSES },
+  { "ShowMyProcesses", NULL, N_("M_y Processes"), NULL,
+    N_("Show only user-owned processes"), MY_PROCESSES }
+};
+
+static const GtkRadioActionEntry priority_menu_entries[] =
+{
+    { "VeryHigh", NULL, N_("Very High"), NULL,
+      N_("Set process priority to very high"), VERY_HIGH_PRIORITY },
+    { "High", NULL, N_("High"), NULL,
+      N_("Set process priority to high"), HIGH_PRIORITY },
+    { "Normal", NULL, N_("Normal"), NULL,
+      N_("Set process priority to normal"), NORMAL_PRIORITY },
+    { "Low", NULL, N_("Low"), NULL,
+      N_("Set process priority to low"), LOW_PRIORITY },
+    { "VeryLow", NULL, N_("Very Low"), NULL,
+      N_("Set process priority to very low"), VERY_LOW_PRIORITY },
+    { "Custom", NULL, N_("Custom"), NULL,
+      N_("Set process priority manually"), CUSTOM_PRIORITY }
+};
+
+
+static const char ui_info[] =
+    "  <menubar name=\"MenuBar\">"
+    "    <menu name=\"MonitorMenu\" action=\"Monitor\">"
+    "      <menuitem name=\"MonitorLsofMenu\" action=\"Lsof\" />"
+    "      <menuitem name=\"MonitorQuitMenu\" action=\"Quit\" />"
+    "    </menu>"
+    "    <menu name=\"EditMenu\" action=\"Edit\">"
+    "      <menuitem name=\"EditStopProcessMenu\" action=\"StopProcess\" />"
+    "      <menuitem name=\"EditContProcessMenu\" action=\"ContProcess\" />"
+    "      <separator />"
+    "      <menuitem name=\"EditEndProcessMenu\" action=\"EndProcess\" />"
+    "      <menuitem name=\"EditKillProcessMenu\" action=\"KillProcess\" />"
+    "      <separator />"
+    "      <menu name=\"EditChangePriorityMenu\" action=\"ChangePriority\" >"
+    "        <menuitem action=\"VeryHigh\" />"
+    "        <menuitem action=\"High\" />"
+    "        <menuitem action=\"Normal\" />"
+    "        <menuitem action=\"Low\" />"
+    "        <menuitem action=\"VeryLow\" />"
+    "        <separator />"
+    "        <menuitem action=\"Custom\"/>"
+    "      </menu>"
+    "      <separator />"
+    "      <menuitem name=\"EditPreferencesMenu\" action=\"Preferences\" />"
+    "    </menu>"
+    "    <menu name=\"ViewMenu\" action=\"View\">"
+    "      <menuitem name=\"ViewActiveProcesses\" action=\"ShowActiveProcesses\" />"
+    "      <menuitem name=\"ViewAllProcesses\" action=\"ShowAllProcesses\" />"
+    "      <menuitem name=\"ViewMyProcesses\" action=\"ShowMyProcesses\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewDependenciesMenu\" action=\"ShowDependencies\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewMemoryMapsMenu\" action=\"MemoryMaps\" />"
+    "      <menuitem name=\"ViewOpenFilesMenu\" action=\"OpenFiles\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewProcessPropertiesMenu\" action=\"ProcessProperties\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewRefresh\" action=\"Refresh\" />"
+    "    </menu>"
+    "    <menu name=\"HelpMenu\" action=\"Help\">"
+    "      <menuitem name=\"HelpContentsMenu\" action=\"HelpContents\" />"
+    "      <menuitem name=\"HelpAboutMenu\" action=\"About\" />"
+    "    </menu>"
+    "  </menubar>"
+    "  <popup name=\"PopupMenu\" action=\"Popup\">"
+    "    <menuitem action=\"StopProcess\" />"
+    "    <menuitem action=\"ContProcess\" />"
+    "    <separator />"
+    "    <menuitem action=\"EndProcess\" />"
+    "    <menuitem action=\"KillProcess\" />"
+    "    <separator />"
+    "    <menu name=\"ChangePriorityMenu\" action=\"ChangePriority\" >"
+    "      <menuitem action=\"VeryHigh\" />"
+    "      <menuitem action=\"High\" />"
+    "      <menuitem action=\"Normal\" />"
+    "      <menuitem action=\"Low\" />"
+    "      <menuitem action=\"VeryLow\" />"
+    "      <separator />"
+    "      <menuitem action=\"Custom\"/>"
+    "    </menu>"
+    "    <separator />"
+    "    <menuitem action=\"MemoryMaps\" />"
+    "    <menuitem action=\"OpenFiles\" />"
+    "    <separator />"
+    "    <menuitem action=\"ProcessProperties\" />"
+
+    "  </popup>";
+
+
+static void
+create_proc_view(ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *proctree;
+    GtkWidget *scrolled;
+    char* string;
+
+    /* create the processes tab */
+    string = make_loadavg_string ();
+    procdata->loadavg = GTK_WIDGET (gtk_builder_get_object (builder, "load_avg_label"));
+    gtk_label_set_text (GTK_LABEL (procdata->loadavg), string);
+    g_free (string);
+
+    proctree = proctable_new (procdata);
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "processes_scrolled"));
+
+    gtk_container_add (GTK_CONTAINER (scrolled), proctree);
+
+    procdata->endprocessbutton = GTK_WIDGET (gtk_builder_get_object (builder, "endprocessbutton"));
+    g_signal_connect (G_OBJECT (procdata->endprocessbutton), "clicked",
+                      G_CALLBACK (cb_end_process_button_pressed), procdata);
+
+    /* create popup_menu for the processes tab */
+    procdata->popup_menu = gtk_ui_manager_get_widget (procdata->uimanager, "/PopupMenu");
+}
+
+
+GtkWidget *
+make_title_label (const char *text)
+{
+    GtkWidget *label;
+    char *full;
+
+    full = g_strdup_printf ("<span weight=\"bold\">%s</span>", text);
+    label = gtk_label_new (full);
+    g_free (full);
+
+    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+
+    return label;
+}
+
+
+static void
+create_sys_view (ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *cpu_graph_box, *mem_graph_box, *net_graph_box;
+    GtkWidget *label,*cpu_label;
+    GtkWidget *table;
+    GtkWidget *color_picker;
+    GtkWidget *picker_alignment;
+    LoadGraph *cpu_graph, *mem_graph, *net_graph;
+
+    gint i;
+    gchar *title_text;
+    gchar *label_text;
+    gchar *title_template;
+
+    // Translators: color picker title, %s is CPU, Memory, Swap, Receiving, Sending
+    title_template = g_strdup(_("Pick a Color for '%s'"));
+
+    /* The CPU BOX */
+
+    cpu_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_graph_box"));
+
+    cpu_graph = new LoadGraph(LOAD_GRAPH_CPU);
+    gtk_box_pack_start (GTK_BOX (cpu_graph_box),
+                        load_graph_get_widget(cpu_graph),
+                        TRUE,
+                        TRUE,
+                         0);
+
+    GtkWidget* flowbox = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_flow_box"));
+    gtk_box_reorder_child (GTK_BOX (cpu_graph_box), flowbox, 1);
+    for (i=0;i<procdata->config.num_cpus; i++) {
+        GtkWidget *temp_hbox;
+
+        temp_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
+        gtk_container_add (GTK_CONTAINER (flowbox), temp_hbox);
+
+        color_picker = gsm_color_button_new (&cpu_graph->colors.at(i), GSMCP_TYPE_CPU);
+        g_signal_connect (G_OBJECT (color_picker), "color_set",
+                          G_CALLBACK (cb_cpu_color_changed), GINT_TO_POINTER (i));
+        gtk_box_pack_start (GTK_BOX (temp_hbox), color_picker, FALSE, TRUE, 0);
+        gtk_widget_set_size_request(GTK_WIDGET(color_picker), 32, -1);
+        if(procdata->config.num_cpus == 1) {
+            label_text = g_strdup (_("CPU"));
+        } else {
+            label_text = g_strdup_printf (_("CPU%d"), i+1);
+        }
+        title_text = g_strdup_printf(title_template, label_text);
+        label = gtk_label_new (label_text);
+        gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+        g_free(title_text);
+        gtk_box_pack_start (GTK_BOX (temp_hbox), label, FALSE, FALSE, 6);
+        g_free (label_text);
+
+        cpu_label = gtk_label_new (NULL);
+        gtk_label_set_width_chars (GTK_LABEL (cpu_label), 7);
+        gtk_label_set_xalign (GTK_LABEL (cpu_label), 0.0);
+
+        gtk_box_pack_start (GTK_BOX (temp_hbox), cpu_label, TRUE, TRUE, 0);
+        load_graph_get_labels(cpu_graph)->cpu[i] = cpu_label;
+
+    }
+
+    procdata->cpu_graph = cpu_graph;
+
+    /** The memory box */
+    mem_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "mem_graph_box"));
+
+    mem_graph = new LoadGraph(LOAD_GRAPH_MEM);
+    gtk_box_pack_start (GTK_BOX (mem_graph_box),
+                        load_graph_get_widget(mem_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "mem_table"));
+
+    color_picker = load_graph_get_mem_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_mem_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Memory"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 0, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->memory;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 1, 1, 1, 1);
+
+    color_picker = load_graph_get_swap_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_swap_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Swap"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 2, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->swap;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 3, 1, 1, 1);
+
+    procdata->mem_graph = mem_graph;
+
+    /* The net box */
+    net_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "net_graph_box"));
+
+    net_graph = new LoadGraph(LOAD_GRAPH_NET);
+    gtk_box_pack_start (GTK_BOX (net_graph_box),
+                        load_graph_get_widget(net_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "net_table"));
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(0), GSMCP_TYPE_NETWORK_IN);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_in_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Receiving"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "receiving_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_in;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_in_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 1, 1, 1);
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(1), GSMCP_TYPE_NETWORK_OUT);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_out_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Sending"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "sending_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_out;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_out_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 1, 1, 1);
+
+    procdata->net_graph = net_graph;
+    g_free(title_template);
+}
+
+static void
+menu_item_select_cb (GtkMenuItem *proxy,
+                     ProcData *procdata)
+{
+    GtkAction *action;
+    char *message;
+
+    action = gtk_activatable_get_related_action (GTK_ACTIVATABLE(proxy));
+    g_assert(action);
+
+    g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
+    if (message)
+    {
+        gtk_statusbar_push (GTK_STATUSBAR (procdata->statusbar),
+                    procdata->tip_message_cid, message);
+        g_free (message);
+    }
+}
+
+static void
+menu_item_deselect_cb (GtkMenuItem *proxy,
+                       ProcData *procdata)
+{
+    gtk_statusbar_pop (GTK_STATUSBAR (procdata->statusbar),
+               procdata->tip_message_cid);
+}
+
+static void
+connect_proxy_cb (GtkUIManager *manager,
+                  GtkAction *action,
+                  GtkWidget *proxy,
+                  ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_connect (proxy, "select",
+                          G_CALLBACK (menu_item_select_cb), procdata);
+        g_signal_connect (proxy, "deselect",
+                          G_CALLBACK (menu_item_deselect_cb), procdata);
+    }
+}
+
+static void
+disconnect_proxy_cb (GtkUIManager *manager,
+                     GtkAction *action,
+                     GtkWidget *proxy,
+                     ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_select_cb)), procdata);
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_deselect_cb)), procdata);
+    }
+}
+
+void
+create_main_window (ProcData *procdata)
+{
+    gint i;
+    gint width, height, xpos, ypos;
+    GtkWidget *app;
+    GtkAction *action;
+    GtkWidget *menubar;
+    GtkWidget *main_box;
+    GtkWidget *notebook;
+    GtkBuilder *builder;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/interface.ui");
+
+    app = GTK_WIDGET (gtk_builder_get_object (builder, "main_window"));
+    main_box = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
+
+    GdkScreen* screen = gtk_widget_get_screen(app);
+    /* use visual, if available */
+    GdkVisual* visual = gdk_screen_get_rgba_visual(screen);
+    if (visual)
+        gtk_widget_set_visual(app, visual);
+
+    width = procdata->config.width;
+    height = procdata->config.height;
+    xpos = procdata->config.xpos;
+    ypos = procdata->config.ypos;
+    gtk_window_set_default_size (GTK_WINDOW (app), width, height);
+    gtk_window_move(GTK_WINDOW (app), xpos, ypos);
+
+    if (procdata->config.maximized) {
+        gtk_window_maximize(GTK_WINDOW(app));
+    }
+
+    /* create the menubar */
+    procdata->uimanager = gtk_ui_manager_new ();
+
+    /* show tooltips in the statusbar */
+    g_signal_connect (procdata->uimanager, "connect_proxy",
+                      G_CALLBACK (connect_proxy_cb), procdata);
+    g_signal_connect (procdata->uimanager, "disconnect_proxy",
+                      G_CALLBACK (disconnect_proxy_cb), procdata);
+
+    gtk_window_add_accel_group (GTK_WINDOW (app),
+                                gtk_ui_manager_get_accel_group (procdata->uimanager));
+
+    if (!gtk_ui_manager_add_ui_from_string (procdata->uimanager,
+                                            ui_info,
+                                            -1,
+                                            NULL)) {
+        g_error("building menus failed");
+    }
+
+    procdata->action_group = gtk_action_group_new ("ProcmanActions");
+    gtk_action_group_set_translation_domain (procdata->action_group, NULL);
+    gtk_action_group_add_actions (procdata->action_group,
+                                  menu_entries,
+                                  G_N_ELEMENTS (menu_entries),
+                                  procdata);
+    gtk_action_group_add_toggle_actions (procdata->action_group,
+                                         toggle_menu_entries,
+                                         G_N_ELEMENTS (toggle_menu_entries),
+                                         procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                        radio_menu_entries,
+                        G_N_ELEMENTS (radio_menu_entries),
+                        procdata->config.whose_process,
+                        G_CALLBACK(cb_radio_processes),
+                        procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                                        priority_menu_entries,
+                                        G_N_ELEMENTS (priority_menu_entries),
+                                        NORMAL_PRIORITY,
+                                        G_CALLBACK(cb_renice),
+                                        procdata);
+
+    gtk_ui_manager_insert_action_group (procdata->uimanager,
+                                        procdata->action_group,
+                                        0);
+
+    menubar = gtk_ui_manager_get_widget (procdata->uimanager, "/MenuBar");
+    gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0);
+    gtk_box_reorder_child (GTK_BOX (main_box), menubar, 0);
+
+    /* create the main notebook */
+    procdata->notebook = notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
+
+    create_proc_view(procdata, builder);
+    create_sys_view (procdata, builder);
+    create_disk_view (procdata, builder);
+
+    g_signal_connect (G_OBJECT (notebook), "switch-page",
+              G_CALLBACK (cb_switch_page), procdata);
+    g_signal_connect (G_OBJECT (notebook), "change-current-page",
+              G_CALLBACK (cb_change_current_page), procdata);
+
+    gtk_widget_show_all(notebook); // need to make page switch work
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab);
+    cb_change_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab, procdata);
+    g_signal_connect (G_OBJECT (app), "delete_event",
+                      G_CALLBACK (cb_app_delete),
+                      procdata);
+
+    GtkAccelGroup *accel_group;
+    GClosure *goto_tab_closure[4];
+    accel_group = gtk_accel_group_new ();
+    gtk_window_add_accel_group (GTK_WINDOW(app), accel_group);
+    for (i = 0; i < 4; ++i) {
+        goto_tab_closure[i] = g_cclosure_new_swap (G_CALLBACK (cb_proc_goto_tab),
+                                                   GINT_TO_POINTER (i), NULL);
+        gtk_accel_group_connect (accel_group, '0'+(i+1),
+                                 GDK_MOD1_MASK, GTK_ACCEL_VISIBLE,
+                                 goto_tab_closure[i]);
+    }
+
+    /* create the statusbar */
+    procdata->statusbar = GTK_WIDGET (gtk_builder_get_object (builder, "statusbar"));
+    procdata->tip_message_cid = gtk_statusbar_get_context_id
+        (GTK_STATUSBAR (procdata->statusbar), "tip_message");
+
+    action = gtk_action_group_get_action (procdata->action_group, "ShowDependencies");
+    gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+                      procdata->config.show_tree);
+
+    gtk_builder_connect_signals (builder, NULL);
+
+    gtk_widget_show_all(app);
+    procdata->app = app;
+
+    g_object_unref (G_OBJECT (builder));
+}
+
+void
+do_popup_menu (ProcData *procdata, GdkEventButton *event)
+{
+    gtk_menu_popup_at_pointer (GTK_MENU (procdata->popup_menu), NULL);
+}
+
+void
+update_sensitivity(ProcData *data)
+{
+    const char * const selected_actions[] = { "StopProcess",
+                                              "ContProcess",
+                                              "EndProcess",
+                                              "KillProcess",
+                                              "ChangePriority",
+                                              "MemoryMaps",
+                                              "OpenFiles",
+                                              "ProcessProperties" };
+
+    const char * const processes_actions[] = { "ShowActiveProcesses",
+                                               "ShowAllProcesses",
+                                               "ShowMyProcesses",
+                                               "ShowDependencies",
+                                               "Refresh"
+    };
+
+    size_t i;
+    gboolean processes_sensitivity, selected_sensitivity;
+    GtkAction *action;
+
+    processes_sensitivity = (data->config.current_tab == PROCMAN_TAB_PROCESSES);
+    selected_sensitivity = (processes_sensitivity && data->selection && gtk_tree_selection_count_selected_rows (data->selection) > 0);
+
+    if(data->endprocessbutton) {
+        /* avoid error on startup if endprocessbutton
+           has not been built yet */
+        gtk_widget_set_sensitive(data->endprocessbutton, selected_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(processes_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             processes_actions[i]);
+        gtk_action_set_sensitive(action, processes_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(selected_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             selected_actions[i]);
+        gtk_action_set_sensitive(action, selected_sensitivity);
+    }
+}
+
+void
+block_priority_changed_handlers(ProcData *data, bool block)
+{
+    gint i;
+    if (block) {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_block_by_func(action, (gpointer)cb_renice, data);
+        }
+    } else {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_unblock_by_func(action, (gpointer)cb_renice, data);
+        }
+    }
+}
+
+static void
+cb_toggle_tree (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GSettings *settings = procdata->settings;
+    gboolean show;
+
+    show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+    if (show == procdata->config.show_tree)
+        return;
+
+    g_settings_set_boolean (settings, "show-tree", show);
+}
+
+static void
+cb_proc_goto_tab (gint tab)
+{
+    ProcData *data = ProcData::get_instance ();
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (data->notebook), tab);
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/7.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/7.html new file mode 100644 index 00000000..8b385037 --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/7.html @@ -0,0 +1,1939 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
#include <config.h>
+
+#include <gdkmm/pixbuf.h>
+
+#include <stdio.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <signal.h>
+#include <dirent.h>
+#include <string.h>
+#include <time.h>
+
+#include <glib/gi18n.h>
+
+#include <glibtop.h>
+#include <glibtop/cpu.h>
+#include <glibtop/mem.h>
+#include <glibtop/swap.h>
+#include <glibtop/netload.h>
+#include <glibtop/netlist.h>
+#include <math.h>
+
+#include <algorithm>
+
+#include "procman.h"
+#include "load-graph.h"
+#include "util.h"
+#include "gsm_color_button.h"
+
+void LoadGraph::clear_background()
+{
+    if (background) {
+        cairo_pattern_destroy (background);
+        this->background = NULL;
+    }
+}
+
+
+unsigned LoadGraph::num_bars() const
+{
+    unsigned n;<--- Shadow variable
+
+    // keep 100 % num_bars == 0
+    switch (static_cast<int>(this->draw_height / (fontsize + 14)))
+    {
+    case 0:
+    case 1:
+        n = 1;
+        break;
+    case 2:
+    case 3:
+        n = 2;
+        break;
+    case 4:
+        n = 4;
+        break;
+    default:
+        n = 5;
+    }
+
+    return n;
+}
+
+
+
+#define FRAME_WIDTH 4
+static void draw_background(LoadGraph *graph) {
+    GtkAllocation allocation;
+    cairo_t *cr;
+    guint i;<--- Shadowed declaration
+    unsigned num_bars;
+    g_autofree gchar *caption;
+    PangoLayout* layout;
+    PangoFontDescription* font_desc;
+    PangoRectangle extents;
+    cairo_surface_t *surface;
+    GdkRGBA fg, bg;
+
+    num_bars = graph->num_bars();
+    graph->graph_dely = (graph->draw_height - 15) / num_bars; /* round to int to avoid AA blur */
+    graph->real_draw_height = graph->graph_dely * num_bars;
+    graph->graph_delx = (graph->draw_width - 2.0 - graph->rmargin - graph->indent) / (LoadGraph::NUM_POINTS - 3);
+    graph->graph_buffer_offset = (int) (1.5 * graph->graph_delx) + FRAME_WIDTH ;
+
+    gtk_widget_get_allocation (graph->disp, &allocation);
+    surface = gdk_window_create_similar_surface (gtk_widget_get_window (graph->disp), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height);
+    cr = cairo_create (surface);
+
+    GtkStyleContext *context = gtk_widget_get_style_context (ProcData::get_instance()->notebook);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get_background_color (context, gtk_style_context_get_state (context), &bg);
+    gtk_style_context_get_color (context, gtk_style_context_get_state (context), &fg);
+    gtk_style_context_restore (context);
+
+    // set the background color
+    gdk_cairo_set_source_rgba (cr, &bg);
+    cairo_paint (cr);
+
+    layout = pango_cairo_create_layout (cr);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get (context,
+                           gtk_style_context_get_state (context),
+                           GTK_STYLE_PROPERTY_FONT,
+                           &font_desc, NULL);
+    gtk_style_context_restore (context);
+    pango_font_description_set_size (font_desc, 0.8 * graph->fontsize * PANGO_SCALE);
+    pango_layout_set_font_description (layout, font_desc);
+    pango_font_description_free (font_desc);
+
+    /* draw frame */
+    cairo_translate (cr, FRAME_WIDTH, FRAME_WIDTH);
+
+    /* Draw background rectangle */
+    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+    cairo_rectangle (cr, graph->rmargin + graph->indent, 0,
+                     graph->draw_width - graph->rmargin - graph->indent, graph->real_draw_height);
+    cairo_fill(cr);
+
+    cairo_set_line_width (cr, 1.0);
+    cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    for (i = 0; i <= num_bars; ++i) {
+        double y;
+
+        if (i == 0)
+            y = 0.5 + graph->fontsize / 2.0;
+        else if (i == num_bars)
+            y = i * graph->graph_dely + 0.5;
+        else
+            y = i * graph->graph_dely + graph->fontsize / 2.0;
+
+        gdk_cairo_set_source_rgba (cr, &fg);
+        if (graph->type == LOAD_GRAPH_NET) {
+            // operation orders matters so it's 0 if i == num_bars
+            guint64 rate = graph->net.max - (i * graph->net.max / num_bars);
+            caption = g_format_size_full (network_in_bits ? rate*8 : rate, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        } else {
+            // operation orders matters so it's 0 if i == num_bars
+            caption = g_strdup_printf("%d%%", 100 - i * (100 / num_bars));
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        }
+
+        if (i==0 || i==num_bars)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, graph->rmargin + graph->indent - 3, i * graph->graph_dely + 0.5);
+        cairo_line_to (cr, graph->draw_width - 0.5, i * graph->graph_dely + 0.5);
+        cairo_stroke (cr);
+    }
+
+    const unsigned total_seconds = graph->speed * (LoadGraph::NUM_POINTS - 2) / 1000;
+
+    for (unsigned int i = 0; i < 7; i++) {<--- Shadow variable
+        double x = (i) * (graph->draw_width - graph->rmargin - graph->indent) / 6;
+        if (i==0 || i==6)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, 0.5);
+        cairo_line_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, graph->real_draw_height + 4.5);
+        cairo_stroke(cr);
+        unsigned seconds = total_seconds - i * total_seconds / 6;
+        const char* format;
+        if (i == 0)
+            format = dngettext(GETTEXT_PACKAGE, "%u second", "%u seconds", seconds);
+        else
+            format = "%u";
+        caption = g_strdup_printf(format, seconds);
+        pango_layout_set_text (layout, caption, -1);
+        pango_layout_get_extents (layout, NULL, &extents);
+        cairo_move_to (cr, ((ceil(x) + 0.5) + graph->rmargin + graph->indent) - (1.0 * extents.width / PANGO_SCALE/2), graph->draw_height - 1.0 * extents.height / PANGO_SCALE);
+        gdk_cairo_set_source_rgba (cr, &fg);
+        pango_cairo_show_layout (cr, layout);
+    }
+    g_object_unref(layout);
+    cairo_stroke (cr);
+    cairo_destroy (cr);
+    graph->background = cairo_pattern_create_for_surface (surface);
+    cairo_surface_destroy (surface);
+}
+
+/* Redraws the backing buffer for the load graph and updates the window */
+void
+load_graph_queue_draw (LoadGraph *graph)
+{
+    /* repaint */
+    gtk_widget_queue_draw (graph->disp);
+}
+
+static int load_graph_update (gpointer user_data); // predeclare load_graph_update so we can compile ;)
+
+static gboolean
+load_graph_configure (GtkWidget *widget,
+                      GdkEventConfigure *event,
+                      gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    gtk_widget_get_allocation (widget, &allocation);
+    graph->draw_width = allocation.width - 2 * FRAME_WIDTH;
+    graph->draw_height = allocation.height - 2 * FRAME_WIDTH;
+
+    graph->clear_background();
+
+    load_graph_queue_draw (graph);
+
+    return TRUE;
+}
+
+static gboolean load_graph_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+    GdkWindow *window;
+
+    guint i, j;
+    gdouble sample_width, x_offset;
+
+    window = gtk_widget_get_window (graph->disp);
+
+    /* Number of pixels wide for one graph point */
+    sample_width = (float)(graph->draw_width - graph->rmargin - graph->indent) / (float)LoadGraph::NUM_POINTS;
+    /* General offset */
+    x_offset = graph->draw_width - graph->rmargin + (sample_width*2);
+
+    /* Subframe offset */
+    x_offset += graph->rmargin - ((sample_width / graph->frames_per_unit) * graph->render_counter);
+
+    /* draw the graph */
+    cairo_t* cr;
+
+    cr = gdk_cairo_create (window);
+
+    if (graph->background == NULL) {
+        draw_background(graph);
+    }
+    cairo_set_source (cr, graph->background);
+    cairo_paint (cr);
+
+    cairo_set_line_width (cr, 1);
+    cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+    cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+    cairo_rectangle (cr, graph->rmargin + graph->indent + FRAME_WIDTH + 1, FRAME_WIDTH - 1,
+             graph->draw_width - graph->rmargin - graph->indent - 1, graph->real_draw_height + FRAME_WIDTH - 1);
+    cairo_clip(cr);
+
+    for (j = 0; j < graph->n; ++j) {
+        cairo_move_to (cr, x_offset, (1.0f - graph->data[0][j]) * graph->real_draw_height);
+        gdk_cairo_set_source_rgba (cr, &(graph->colors [j]));
+
+        for (i = 1; i < LoadGraph::NUM_POINTS; ++i) {
+            if (graph->data[i][j] == -1.0f)
+                continue;
+            cairo_curve_to (cr,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i-1][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - (i * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f);
+        }
+        cairo_stroke (cr);
+
+    }
+
+    cairo_destroy (cr);
+
+    return TRUE;
+}
+
+static void
+get_load (LoadGraph *graph)
+{
+    guint i;
+    glibtop_cpu cpu;
+
+    glibtop_get_cpu (&cpu);
+
+#undef NOW
+#undef LAST
+#define NOW  (graph->cpu.times[graph->cpu.now])
+#define LAST (graph->cpu.times[graph->cpu.now ^ 1])
+
+    if (graph->n == 1) {
+        NOW[0][CPU_TOTAL] = cpu.total;
+        NOW[0][CPU_USED] = cpu.user + cpu.nice + cpu.sys;
+    } else {
+        for (i = 0; i < graph->n; i++) {
+            NOW[i][CPU_TOTAL] = cpu.xcpu_total[i];
+            NOW[i][CPU_USED] = cpu.xcpu_user[i] + cpu.xcpu_nice[i]
+                + cpu.xcpu_sys[i];
+        }
+    }
+
+    // on the first call, LAST is 0
+    // which means data is set to the average load since boot
+    // that value has no meaning, we just want all the
+    // graphs to be aligned, so the CPU graph needs to start
+    // immediately
+
+    for (i = 0; i < graph->n; i++) {
+        float load;
+        float total, used;
+        gchar *text;
+
+        total = NOW[i][CPU_TOTAL] - LAST[i][CPU_TOTAL];
+        used  = NOW[i][CPU_USED]  - LAST[i][CPU_USED];
+
+        load = used / MAX(total, 1.0f);
+        graph->data[0][i] = load;
+
+        /* Update label */
+        text = g_strdup_printf("%.1f%%", load * 100.0f);
+        gtk_label_set_text(GTK_LABEL(graph->labels.cpu[i]), text);
+        g_free(text);
+    }
+
+    graph->cpu.now ^= 1;
+
+#undef NOW
+#undef LAST
+}
+
+
+namespace
+{
+
+    void set_memory_label_and_picker(GtkLabel* label, GSMColorButton* picker,
+                                   guint64 used, guint64 total, double percent)
+    {
+        char* used_text;
+        char* total_text;
+        char* text;
+
+        used_text = g_format_size_full(used, G_FORMAT_SIZE_IEC_UNITS);
+        total_text = g_format_size_full(total, G_FORMAT_SIZE_IEC_UNITS);
+        if (total == 0) {
+            text = g_strdup(_("not available"));
+        } else {
+            // xgettext: 540MiB (53 %) of 1.0 GiB
+            text = g_strdup_printf(_("%s (%.1f%%) of %s"), used_text, 100.0 * percent, total_text);
+        }
+        gtk_label_set_text(label, text);
+        g_free(used_text);
+        g_free(total_text);
+        g_free(text);
+
+        if (picker)
+            gsm_color_button_set_fraction(picker, percent);
+    }
+}
+
+static void
+get_memory (LoadGraph *graph)
+{
+    float mempercent, swappercent;
+
+    glibtop_mem mem;
+    glibtop_swap swap;
+
+    glibtop_get_mem (&mem);
+    glibtop_get_swap (&swap);
+
+    /* There's no swap on LiveCD : 0.0f is better than NaN :) */
+    swappercent = (swap.total ? (float)swap.used / (float)swap.total : 0.0f);
+    mempercent  = (float)mem.user  / (float)mem.total;
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.memory),
+                                GSM_COLOR_BUTTON(graph->mem_color_picker),
+                                mem.user, mem.total, mempercent);
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.swap),
+                                GSM_COLOR_BUTTON(graph->swap_color_picker),
+                                swap.used, swap.total, swappercent);
+
+    graph->data[0][0] = mempercent;
+    graph->data[0][1] = swappercent;
+}
+
+/* Nice Numbers for Graph Labels after Paul Heckbert
+   nicenum: find a "nice" number approximately equal to x.
+   Round the number if round=1, take ceiling if round=0    */
+
+static double
+nicenum (double x, int round)
+{
+    int expv;				/* exponent of x */
+    double f;				/* fractional part of x */
+    double nf;				/* nice, rounded fraction */
+
+    expv = floor( log10(x) );
+    f = x/pow( 10.0, expv );		/* between 1 and 10 */
+    if (round) {
+        if ( f < 1.5 ) nf = 1.0;
+        else if ( f < 3.0 ) nf = 2.0;
+        else if ( f < 7.0 ) nf = 5.0;
+        else nf = 10.0;
+    } else {
+        if ( f <= 1.0 ) nf = 1.0;
+        else if ( f <= 2.0 ) nf = 2.0;
+        else if ( f <= 5.0 ) nf = 5.0;
+        else nf = 10.0;
+    }
+    return nf * pow(10.0, expv);
+}
+
+static void
+net_scale (LoadGraph *graph, guint64 din, guint64 dout)
+{
+    graph->data[0][0] = 1.0f * din / graph->net.max;
+    graph->data[0][1] = 1.0f * dout / graph->net.max;
+
+    guint64 dmax = std::max(din, dout);
+    graph->net.values[graph->net.cur] = dmax;
+    graph->net.cur = (graph->net.cur + 1) % LoadGraph::NUM_POINTS;
+
+    guint64 new_max;
+    // both way, new_max is the greatest value
+    if (dmax >= graph->net.max)
+        new_max = dmax;
+    else
+        new_max = *std::max_element(&graph->net.values[0],
+                                    &graph->net.values[LoadGraph::NUM_POINTS]);
+
+    //
+    // Round network maximum
+    //
+
+    const guint64 bak_max(new_max);
+
+    if (ProcData::get_instance()->config.network_in_bits) {
+        // nice number is for the ticks
+        unsigned ticks = graph->num_bars();
+
+        // gets messy at low values due to division by 8
+        guint64 bit_max = std::max( new_max*8, G_GUINT64_CONSTANT(10000) );
+
+        // our tick size leads to max
+        double d = nicenum(bit_max/ticks, 0);
+        bit_max = ticks * d;
+        new_max = bit_max / 8;
+
+        procman_debug("bak*8 %" G_GUINT64_FORMAT ", ticks %d, d %f"
+                      ", bit_max %" G_GUINT64_FORMAT ", new_max %" G_GUINT64_FORMAT,
+                      bak_max*8, ticks, d, bit_max, new_max );
+    } else {
+        // round up to get some extra space
+        // yes, it can overflow
+        new_max = 1.1 * new_max;
+        // make sure max is not 0 to avoid / 0
+        // default to 1 KiB
+        new_max = std::max(new_max, G_GUINT64_CONSTANT(1024));
+
+        // decompose new_max = coef10 * 2**(base10 * 10)
+        // where coef10 and base10 are integers and coef10 < 2**10
+        //
+        // e.g: ceil(100.5 KiB) = 101 KiB = 101 * 2**(1 * 10)
+        //      where base10 = 1, coef10 = 101, pow2 = 16
+
+        guint64 pow2 = std::floor(log2(new_max));
+        guint64 base10 = pow2 / 10.0;
+        guint64 coef10 = std::ceil(new_max / double(G_GUINT64_CONSTANT(1) << (base10 * 10)));
+        g_assert(new_max <= (coef10 * (G_GUINT64_CONSTANT(1) << (base10 * 10))));
+
+        // then decompose coef10 = x * 10**factor10
+        // where factor10 is integer and x < 10
+        // so we new_max has only 1 significant digit
+
+        guint64 factor10 = std::pow(10.0, std::floor(std::log10(coef10)));
+        coef10 = std::ceil(coef10 / double(factor10)) * factor10;
+
+        // then make coef10 divisible by num_bars
+        if (coef10 % graph->num_bars() != 0)
+            coef10 = coef10 + (graph->num_bars() - coef10 % graph->num_bars());
+        g_assert(coef10 % graph->num_bars() == 0);
+        new_max = coef10 * (G_GUINT64_CONSTANT(1) << guint64(base10 * 10));
+        procman_debug("bak %" G_GUINT64_FORMAT " new_max %" G_GUINT64_FORMAT
+                      "pow2 %" G_GUINT64_FORMAT " coef10 %" G_GUINT64_FORMAT,
+                      bak_max, new_max, pow2, coef10);
+    }
+
+    if (bak_max > new_max) {
+        procman_debug("overflow detected: bak=%" G_GUINT64_FORMAT
+                      " new=%" G_GUINT64_FORMAT,
+                      bak_max, new_max);
+        new_max = bak_max;
+    }
+
+    // if max is the same or has decreased but not so much, don't
+    // do anything to avoid rescaling
+    if ((0.8 * graph->net.max) < new_max && new_max <= graph->net.max)
+        return;
+
+    const double scale = 1.0f * graph->net.max / new_max;
+
+    for (size_t i = 0; i < LoadGraph::NUM_POINTS; i++) {
+        if (graph->data[i][0] >= 0.0f) {
+            graph->data[i][0] *= scale;
+            graph->data[i][1] *= scale;
+        }
+    }
+
+    procman_debug("rescale dmax = %" G_GUINT64_FORMAT
+                  " max = %" G_GUINT64_FORMAT
+                  " new_max = %" G_GUINT64_FORMAT,
+                  dmax, graph->net.max, new_max);
+
+    graph->net.max = new_max;
+
+    // force the graph background to be redrawn now that scale has changed
+    graph->clear_background();
+}
+
+static void
+get_net (LoadGraph *graph)
+{
+    glibtop_netlist netlist;
+    char **ifnames;
+    guint32 i;
+    guint64 in = 0, out = 0;
+#if GLIB_CHECK_VERSION(2,61,2)
+    gint64 time;
+#else
+    GTimeVal time;
+#endif
+    guint64 din, dout;
+
+    ifnames = glibtop_get_netlist(&netlist);
+
+    for (i = 0; i < netlist.number; ++i)
+    {
+        glibtop_netload netload;
+        glibtop_get_netload (&netload, ifnames[i]);
+
+        if (netload.if_flags & (1 << GLIBTOP_IF_FLAGS_LOOPBACK))
+            continue;
+
+        /* Skip interfaces without any IPv4/IPv6 address (or
+         those with only a LINK ipv6 addr) However we need to
+         be able to exclude these while still keeping the
+         value so when they get online (with NetworkManager
+         for example) we don't get a suddent peak.  Once we're
+         able to get this, ignoring down interfaces will be
+         possible too.  */
+        if (not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS6)
+             and netload.scope6 != GLIBTOP_IF_IN6_SCOPE_LINK)
+            and not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS)))
+            continue;
+
+        /* Don't skip interfaces that are down (GLIBTOP_IF_FLAGS_UP)
+           to avoid spikes when they are brought up */
+
+        in  += netload.bytes_in;
+        out += netload.bytes_out;
+    }
+
+    g_strfreev(ifnames);
+
+#if GLIB_CHECK_VERSION(2,61,2)
+    time = g_get_real_time ();
+
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time != 0) {
+        float dtime = (double) (time - graph->net.time) / G_USEC_PER_SEC;
+#else
+    g_get_current_time (&time);
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time.tv_sec != 0) {
+        float dtime;
+        dtime = time.tv_sec - graph->net.time.tv_sec +
+            (double) (time.tv_usec - graph->net.time.tv_usec) / G_USEC_PER_SEC;
+#endif
+        din   = static_cast<guint64>((in  - graph->net.last_in)  / dtime);
+        dout  = static_cast<guint64>((out - graph->net.last_out) / dtime);
+    } else {
+        /* Don't calc anything if new data is less than old (interface
+           removed, counters reset, ...) or if it is the first time */
+        din  = 0;
+        dout = 0;
+    }
+
+    graph->net.last_in  = in;
+    graph->net.last_out = out;
+    graph->net.time     = time;
+
+    net_scale(graph, din, dout);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    g_autofree gchar *str=NULL, *formatted_str=NULL;
+
+    str = g_format_size_full (network_in_bits ? din*8 : din, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? in*8 : in, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in_total), str);
+
+    str = g_format_size_full (network_in_bits ? dout*8 : dout, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? out*8 : out, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out_total), str);
+}
+
+
+/* Updates the load graph when the timeout expires */
+static gboolean
+load_graph_update (gpointer user_data)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(user_data);
+
+    if (graph->render_counter == graph->frames_per_unit - 1) {
+        std::rotate(&graph->data[0], &graph->data[LoadGraph::NUM_POINTS - 1], &graph->data[LoadGraph::NUM_POINTS]);
+
+        switch (graph->type) {
+        case LOAD_GRAPH_CPU:
+            get_load(graph);
+            break;
+        case LOAD_GRAPH_MEM:
+            get_memory(graph);
+            break;
+        case LOAD_GRAPH_NET:
+            get_net(graph);
+            break;
+        default:
+            g_assert_not_reached();
+        }
+    }
+
+    if (graph->draw)
+        load_graph_queue_draw (graph);
+
+    graph->render_counter++;
+
+    if (graph->render_counter >= graph->frames_per_unit)
+        graph->render_counter = 0;
+
+    return TRUE;
+}
+
+
+
+LoadGraph::~LoadGraph()
+{
+  load_graph_stop(this);
+
+  if (timer_index)
+    g_source_remove(timer_index);
+
+  clear_background();
+}
+
+
+
+static gboolean
+load_graph_destroy (GtkWidget *widget, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    delete graph;
+
+    return FALSE;
+}
+
+
+LoadGraph::LoadGraph(guint type)
+  : fontsize(8.0),
+    rmargin(3.5 * fontsize),
+    indent(24.0),
+    n(0),
+    type(type),
+    speed(0),
+    draw_width(0),
+    draw_height(0),
+    render_counter(0),
+    frames_per_unit(10), // this will be changed but needs initialising
+    graph_dely(0),
+    real_draw_height(0),
+    graph_delx(0.0),
+    graph_buffer_offset(0),
+    main_widget(NULL),
+    disp(NULL),
+    background(NULL),
+    timer_index(0),
+    draw(FALSE),
+    mem_color_picker(NULL),
+    swap_color_picker(NULL)
+{
+    LoadGraph * const graph = this;
+
+    // FIXME:
+    // on configure, graph->frames_per_unit = graph->draw_width/(LoadGraph::NUM_POINTS);
+    // knock FRAMES down to 5 until cairo gets faster
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memset(&cpu, 0, sizeof cpu);
+        n = ProcData::get_instance()->config.num_cpus;
+
+        for(guint i = 0; i < G_N_ELEMENTS(labels.cpu); ++i)
+            labels.cpu[i] = gtk_label_new(NULL);
+
+        break;
+
+    case LOAD_GRAPH_MEM:
+        n = 2;
+        labels.memory = gtk_label_new(NULL);
+        labels.swap = gtk_label_new(NULL);
+        break;
+
+    case LOAD_GRAPH_NET:
+        memset(&net, 0, sizeof net);
+        n = 2;
+        net.max = 1;
+        labels.net_in = gtk_label_new(NULL);
+        labels.net_in_total = gtk_label_new(NULL);
+        labels.net_out = gtk_label_new(NULL);
+        labels.net_out_total = gtk_label_new(NULL);
+        break;
+    }
+
+    speed  = ProcData::get_instance()->config.graph_update_interval;
+
+    colors.resize(n);
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memcpy(&colors[0], ProcData::get_instance()->config.cpu_color,
+               n * sizeof colors[0]);
+        break;
+    case LOAD_GRAPH_MEM:
+        colors[0] = ProcData::get_instance()->config.mem_color;
+        colors[1] = ProcData::get_instance()->config.swap_color;
+        mem_color_picker = gsm_color_button_new (&colors[0],
+                                                 GSMCP_TYPE_PIE);
+        swap_color_picker = gsm_color_button_new (&colors[1],
+                                                  GSMCP_TYPE_PIE);
+        break;
+    case LOAD_GRAPH_NET:
+        colors[0] = ProcData::get_instance()->config.net_in_color;
+        colors[1] = ProcData::get_instance()->config.net_out_color;
+        break;
+    }
+
+    timer_index = 0;
+    render_counter = (frames_per_unit - 1);
+    draw = FALSE;
+
+    main_widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+    gtk_widget_set_size_request(main_widget, -1, LoadGraph::GRAPH_MIN_HEIGHT);
+    gtk_widget_show (main_widget);
+
+    disp = gtk_drawing_area_new ();
+    gtk_widget_show (disp);
+    g_signal_connect (G_OBJECT (disp), "draw", G_CALLBACK (load_graph_draw), graph);
+    g_signal_connect (G_OBJECT(disp), "configure_event",
+                      G_CALLBACK (load_graph_configure), graph);
+    g_signal_connect (G_OBJECT(disp), "destroy",
+                      G_CALLBACK (load_graph_destroy), graph);
+
+    gtk_widget_set_events (disp, GDK_EXPOSURE_MASK);
+
+    gtk_box_pack_start (GTK_BOX (main_widget), disp, TRUE, TRUE, 0);
+
+
+    /* Allocate data in a contiguous block */
+    data_block = std::vector<float>(n * LoadGraph::NUM_POINTS, -1.0f);
+
+    for (guint i = 0; i < LoadGraph::NUM_POINTS; ++i)
+        data[i] = &data_block[0] + i * n;
+
+    gtk_widget_show_all (main_widget);
+}
+
+void
+load_graph_start (LoadGraph *graph)
+{
+    if(!graph->timer_index) {
+
+        load_graph_update(graph);
+
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->draw = TRUE;
+}
+
+void
+load_graph_stop (LoadGraph *graph)
+{
+    /* don't draw anymore, but continue to poll */
+    graph->draw = FALSE;
+}
+
+void
+load_graph_change_speed (LoadGraph *graph,
+             guint new_speed)
+{
+    if (graph->speed == new_speed)
+        return;
+
+    graph->speed = new_speed;
+
+    if(graph->timer_index) {
+        g_source_remove (graph->timer_index);
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->clear_background();
+}
+
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *graph)
+{
+    return &graph->labels;
+}
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *graph)
+{
+    return graph->main_widget;
+}
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *graph)
+{
+    return graph->mem_color_picker;
+}
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *graph)
+{
+    return graph->swap_color_picker;
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/8.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/8.html new file mode 100644 index 00000000..6bd78123 --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/8.html @@ -0,0 +1,1075 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
#include <config.h>
+
+#include <gtkmm/messagedialog.h>
+#include <glibmm/regex.h>
+#include <glib/gi18n.h>
+#include <glibtop/procopenfiles.h>
+
+#include <sys/wait.h>
+
+#include <set>
+#include <string>
+#include <sstream>
+#include <iterator>
+
+#include <glibmm/regex.h>
+
+#include "procman.h"
+#include "lsof.h"
+#include "util.h"
+
+
+using std::string;
+
+
+namespace
+{
+
+    class Lsof
+    {
+        Glib::RefPtr<Glib::Regex> re;
+
+        bool matches(const string &filename) const
+        {
+            return this->re->match(filename);
+        }
+
+    public:
+
+        Lsof(const string &pattern, bool caseless)
+        {
+            Glib::RegexCompileFlags flags = static_cast<Glib::RegexCompileFlags>(0);
+
+            if (caseless)
+                flags |= Glib::REGEX_CASELESS;
+
+            this->re = Glib::Regex::create(pattern, flags);
+        }
+
+
+        template<typename OutputIterator>
+        void search(const ProcInfo &info, OutputIterator out) const
+        {
+            glibtop_open_files_entry *entries;
+            glibtop_proc_open_files buf;
+
+            entries = glibtop_get_proc_open_files(&buf, info.pid);
+
+            for (unsigned i = 0; i != buf.number; ++i) {
+                if (entries[i].type & GLIBTOP_FILE_TYPE_FILE) {
+                    const string filename(entries[i].info.file.name);
+                    if (this->matches(filename))
+                        *out++ = filename;
+                }
+            }
+
+            g_free(entries);
+        }
+    };
+
+
+
+    // GUI Stuff
+
+
+    enum ProcmanLsof {
+        PROCMAN_LSOF_COL_SURFACE,
+        PROCMAN_LSOF_COL_PROCESS,
+        PROCMAN_LSOF_COL_PID,
+        PROCMAN_LSOF_COL_FILENAME,
+        PROCMAN_LSOF_NCOLS
+    };
+
+
+    struct GUI {
+
+        GtkListStore *model;
+        GtkEntry *entry;
+        GtkWindow *window;
+        GtkLabel *count;<--- Shadowed declaration
+        ProcData *procdata;
+        bool case_insensitive;
+
+
+        GUI()
+        {
+            procman_debug("New Lsof GUI %p", this);
+        }
+
+
+        ~GUI()
+        {
+            procman_debug("Destroying Lsof GUI %p", this);
+        }
+
+
+        void clear_results()
+        {
+            gtk_list_store_clear(this->model);
+            gtk_label_set_text(this->count, "");
+        }
+
+
+        void clear()
+        {
+            this->clear_results();
+            gtk_entry_set_text(this->entry, "");
+        }
+
+
+        void display_regex_error(const Glib::RegexError& error)
+        {
+            char * msg = g_strdup_printf ("<b>%s</b>\n%s\n%s",
+                                          _("Error"),
+                                          _("'%s' is not a valid Perl regular expression."),
+                                          "%s");
+            std::string message = make_string(g_strdup_printf(msg, this->pattern().c_str(), error.what().c_str()));
+            g_free(msg);
+
+            Gtk::MessageDialog dialog(message,
+                                      true, // use markup
+                                      Gtk::MESSAGE_ERROR,
+                                      Gtk::BUTTONS_OK,
+                                      true); // modal
+            dialog.run();
+        }
+
+
+        void update_count(unsigned count)
+        {
+            std::ostringstream ss;
+            ss << count;
+            string s = ss.str();
+            gtk_label_set_text(this->count, s.c_str());
+        }
+
+
+        string pattern() const
+        {
+            return gtk_entry_get_text(this->entry);
+        }
+
+
+        void search()
+        {
+            typedef std::set<string> MatchSet;
+            typedef MatchSet::const_iterator iterator;
+
+            this->clear_results();
+
+
+            try {
+                Lsof lsof(this->pattern(), this->case_insensitive);
+
+                unsigned count = 0;<--- Shadow variable
+
+                for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it) {
+                    const ProcInfo &info(*it->second);
+
+                    MatchSet matches;
+                    lsof.search(info, std::inserter(matches, matches.begin()));
+                    count += matches.size();
+
+                    for (iterator it(matches.begin()), end(matches.end()); it != end; ++it) {
+                        GtkTreeIter file;
+                        gtk_list_store_append(this->model, &file);
+                        gtk_list_store_set(this->model, &file,
+                                           PROCMAN_LSOF_COL_SURFACE, info.surface,
+                                           PROCMAN_LSOF_COL_PROCESS, info.name,
+                                           PROCMAN_LSOF_COL_PID, info.pid,
+                                           PROCMAN_LSOF_COL_FILENAME, it->c_str(),
+                                           -1);
+                    }
+                }
+
+                this->update_count(count);
+            }
+            catch (Glib::RegexError& error) {
+                this->display_regex_error(error);
+            }
+        }
+
+
+        static void search_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void search_entry_activate(GtkEntry *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void clear_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->clear();
+        }
+
+
+        static void close_button_clicked(GtkButton *, gpointer data)
+        {
+            GUI *gui = static_cast<GUI*>(data);
+            gtk_widget_destroy(GTK_WIDGET(gui->window));
+            delete gui;
+        }
+
+
+        static void case_button_toggled(GtkToggleButton *button, gpointer data)
+        {
+            bool state = gtk_toggle_button_get_active(button);
+            static_cast<GUI*>(data)->case_insensitive = state;
+        }
+
+
+        static gboolean window_delete_event(GtkWidget *, GdkEvent *, gpointer data)
+        {
+            delete static_cast<GUI*>(data);
+            return FALSE;
+        }
+
+    };
+}
+
+
+
+
+void procman_lsof(ProcData *procdata)
+{
+    GtkListStore *model = \
+        gtk_list_store_new(PROCMAN_LSOF_NCOLS,
+                           CAIRO_GOBJECT_TYPE_SURFACE, // PROCMAN_LSOF_COL_SURFACE
+                           G_TYPE_STRING,              // PROCMAN_LSOF_COL_PROCESS
+                           G_TYPE_UINT,                // PROCMAN_LSOF_COL_PID
+                           G_TYPE_STRING               // PROCMAN_LSOF_COL_FILENAME
+        );
+
+    GtkWidget *tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_object_unref(model);
+
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *renderer;
+
+    // SURFACE / PROCESS
+
+    column = gtk_tree_view_column_new();
+
+    renderer = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "surface", PROCMAN_LSOF_COL_SURFACE,
+                                        NULL);
+
+    renderer = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "text", PROCMAN_LSOF_COL_PROCESS,
+                                        NULL);
+
+    gtk_tree_view_column_set_title(column, _("Process"));
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PROCESS);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_column_set_min_width(column, 10);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), PROCMAN_LSOF_COL_PROCESS,
+                                         GTK_SORT_ASCENDING);
+
+
+    // PID
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("PID"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_PID,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PID);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    // FILENAME
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("Filename"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_FILENAME,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_FILENAME);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    GtkWidget *dialog; /* = gtk_dialog_new_with_buttons(_("Search for Open Files"), NULL,
+                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+                                                        NULL); */
+    dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(procdata->app));
+    gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
+    // gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_title(GTK_WINDOW(dialog), _("Search for Open Files"));
+
+    // g_signal_connect(G_OBJECT(dialog), "response",
+    //                           G_CALLBACK(close_dialog), NULL);
+    gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(dialog), 575, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(dialog), 12);
+    GtkWidget *mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_add(GTK_CONTAINER(dialog), mainbox);
+    gtk_box_set_spacing(GTK_BOX(mainbox), 6);
+
+
+    // Label, entry and search button
+
+    GtkWidget *hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), hbox1, FALSE, FALSE, 0);
+
+    GtkWidget *image = gtk_image_new_from_icon_name("edit-find", GTK_ICON_SIZE_DIALOG);
+    gtk_box_pack_start(GTK_BOX(hbox1), image, FALSE, FALSE, 0);
+
+
+    GtkWidget *vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox1), vbox2, TRUE, TRUE, 0);
+
+
+    GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox, TRUE, TRUE, 0);
+    GtkWidget *label = gtk_label_new_with_mnemonic(_("_Name contains:"));
+    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+    GtkWidget *entry = gtk_entry_new();
+
+    gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
+
+    GtkWidget *search_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                         "label", "gtk-find",
+                                                         "use-stock", TRUE,
+                                                         "use-underline", TRUE,
+                                                         NULL));
+
+    gtk_box_pack_start(GTK_BOX(hbox), search_button, FALSE, FALSE, 0);
+
+    GtkWidget *clear_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-clear",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    /* The default accelerator collides with the default close accelerator. */
+    gtk_button_set_label(GTK_BUTTON(clear_button), _("C_lear"));
+    gtk_box_pack_start(GTK_BOX(hbox), clear_button, FALSE, FALSE, 0);
+
+
+    GtkWidget *case_button = gtk_check_button_new_with_mnemonic(_("Case insensitive matching"));
+    GtkWidget *hbox3 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox3), case_button, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox3, FALSE, FALSE, 0);
+
+
+    GtkWidget *results_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), results_box, FALSE, FALSE, 0);
+    GtkWidget *results_label = gtk_label_new_with_mnemonic(_("S_earch results:"));
+    gtk_box_pack_start(GTK_BOX(results_box), results_label, FALSE, FALSE, 0);
+    GtkWidget *count_label = gtk_label_new(NULL);
+    gtk_box_pack_end(GTK_BOX(results_box), count_label, FALSE, FALSE, 0);
+
+    // Scrolled TreeView
+    GtkWidget *scrolled = gtk_scrolled_window_new(NULL, NULL);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
+                                   GTK_POLICY_AUTOMATIC,
+                                   GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled),
+                                        GTK_SHADOW_IN);
+    gtk_container_add(GTK_CONTAINER(scrolled), tree);
+    gtk_box_pack_start(GTK_BOX(mainbox), scrolled, TRUE, TRUE, 0);
+
+    GtkWidget *bottom_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+
+    GtkWidget *close_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-close",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    gtk_box_pack_start(GTK_BOX(mainbox), bottom_box, FALSE, FALSE, 0);
+    gtk_box_pack_end(GTK_BOX(bottom_box), close_button, FALSE, FALSE, 0);
+
+
+    GUI *gui = new GUI; // wil be deleted by the close button or delete-event
+    gui->procdata = procdata;
+    gui->model = model;
+    gui->window = GTK_WINDOW(dialog);
+    gui->entry = GTK_ENTRY(entry);
+    gui->count = GTK_LABEL(count_label);
+
+    g_signal_connect(G_OBJECT(entry), "activate",
+                     G_CALLBACK(GUI::search_entry_activate), gui);
+    g_signal_connect(G_OBJECT(clear_button), "clicked",
+                     G_CALLBACK(GUI::clear_button_clicked), gui);
+    g_signal_connect(G_OBJECT(search_button), "clicked",
+                     G_CALLBACK(GUI::search_button_clicked), gui);
+    g_signal_connect(G_OBJECT(close_button), "clicked",
+                     G_CALLBACK(GUI::close_button_clicked), gui);
+    g_signal_connect(G_OBJECT(case_button), "toggled",
+                     G_CALLBACK(GUI::case_button_toggled), gui);
+    g_signal_connect(G_OBJECT(dialog), "delete-event",
+                     G_CALLBACK(GUI::window_delete_event), gui);
+
+
+    gtk_widget_show_all(dialog);
+}
+
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/9.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/9.html new file mode 100644 index 00000000..b1d95a0b --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/9.html @@ -0,0 +1,1197 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
#include <config.h>
+
+#include <glibtop/procmap.h>
+#include <glibtop/mountlist.h>
+#include <sys/stat.h>
+#include <glib/gi18n.h>
+
+#include <string>
+#include <map>
+#include <sstream>
+#include <iomanip>
+#include <stdexcept>
+
+using std::string;
+
+
+#include "procman.h"
+#include "memmaps.h"
+#include "proctable.h"
+#include "util.h"
+
+
+/* be careful with this enum, you could break the column names */
+enum
+{
+    MMAP_COL_FILENAME,
+    MMAP_COL_VMSTART,
+    MMAP_COL_VMEND,
+    MMAP_COL_VMSZ,
+    MMAP_COL_FLAGS,
+    MMAP_COL_VMOFFSET,
+    MMAP_COL_PRIVATE_CLEAN,
+    MMAP_COL_PRIVATE_DIRTY,
+    MMAP_COL_SHARED_CLEAN,
+    MMAP_COL_SHARED_DIRTY,
+    MMAP_COL_DEVICE,
+    MMAP_COL_INODE,
+    MMAP_COL_MAX
+};
+
+
+namespace
+{
+    class OffsetFormater
+    {
+        string format;
+
+    public:
+
+        void set(const glibtop_map_entry &last_map)
+        {
+            this->format = (last_map.end <= G_MAXUINT32) ? "%08" G_GINT64_MODIFIER "x" : "%016" G_GINT64_MODIFIER "x";
+        }
+
+        string operator()(guint64 v) const
+        {
+            char buffer[17];
+            g_snprintf(buffer, sizeof buffer, this->format.c_str(), v);
+            return buffer;
+        }
+    };
+
+
+    class InodeDevices
+    {
+        typedef std::map<guint16, string> Map;
+        Map devices;
+
+    public:
+
+        void update()
+        {
+            this->devices.clear();
+
+            glibtop_mountlist list;
+            glibtop_mountentry *entries = glibtop_get_mountlist(&list, 1);
+
+            for (unsigned i = 0; i != list.number; ++i) {
+                struct stat buf;
+
+                if (stat(entries[i].devname, &buf) != -1)
+                    this->devices[buf.st_rdev] = entries[i].devname;
+            }
+
+            g_free(entries);
+        }
+
+        string get(guint64 dev64)
+        {
+            if (dev64 == 0)
+                return "";
+
+            guint16 dev = dev64 & 0xffff;
+
+            if (dev != dev64)
+                g_warning("weird device %" G_GINT64_MODIFIER "x", dev64);
+
+            Map::iterator it(this->devices.find(dev));
+
+            if (it != this->devices.end())
+                return it->second;
+
+            guint8 major, minor;
+            major = dev >> 8;
+            minor = dev;
+
+            std::ostringstream out;
+            out << std::hex
+                << std::setfill('0')
+                << std::setw(2) << unsigned(major)
+                << ':'
+                << std::setw(2) << unsigned(minor);
+
+            this->devices[dev] = out.str();
+            return out.str();
+        }
+    };
+
+
+    class MemMapsData
+    {
+    public:
+        guint timer;
+        GtkWidget *tree;
+        GSettings *settings;
+        ProcInfo *info;
+        OffsetFormater format;
+        mutable InodeDevices devices;
+        const char * const schema;
+
+        MemMapsData(GtkWidget *a_tree, GSettings *a_settings)
+            : tree(a_tree),
+            settings(a_settings),
+            schema("memmapstree")
+        {
+            procman_get_tree_state(this->settings, this->tree, this->schema);
+        }
+
+        ~MemMapsData()
+        {
+            procman_save_tree_state(this->settings, this->tree, this->schema);
+        }
+    };
+}
+
+
+struct glibtop_map_entry_cmp
+{
+    bool operator()(const glibtop_map_entry &a, const guint64 start) const
+    {
+        return a.start < start;
+    }
+
+    bool operator()(const guint64 &start, const glibtop_map_entry &a) const
+    {
+        return start < a.start;
+    }
+
+};
+
+
+static void
+update_row(GtkTreeModel *model, GtkTreeIter &row, const MemMapsData &mm, const glibtop_map_entry *memmaps)
+{
+    guint64 size;
+    string filename, device;
+    string vmstart, vmend, vmoffset;
+    char flags[5] = "----";
+
+    size = memmaps->end - memmaps->start;
+
+    if(memmaps->perm & GLIBTOP_MAP_PERM_READ)    flags [0] = 'r';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_WRITE)   flags [1] = 'w';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_EXECUTE) flags [2] = 'x';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_SHARED)  flags [3] = 's';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_PRIVATE) flags [3] = 'p';
+
+    if (memmaps->flags & (1 << GLIBTOP_MAP_ENTRY_FILENAME))
+      filename = memmaps->filename;
+
+    vmstart  = mm.format(memmaps->start);
+    vmend    = mm.format(memmaps->end);
+    vmoffset = mm.format(memmaps->offset);
+    device   = mm.devices.get(memmaps->device);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        MMAP_COL_FILENAME, filename.c_str(),
+                        MMAP_COL_VMSTART, vmstart.c_str(),
+                        MMAP_COL_VMEND, vmend.c_str(),
+                        MMAP_COL_VMSZ, size,
+                        MMAP_COL_FLAGS, flags,
+                        MMAP_COL_VMOFFSET, vmoffset.c_str(),
+                        MMAP_COL_PRIVATE_CLEAN, memmaps->private_clean,
+                        MMAP_COL_PRIVATE_DIRTY, memmaps->private_dirty,
+                        MMAP_COL_SHARED_CLEAN, memmaps->shared_clean,
+                        MMAP_COL_SHARED_DIRTY, memmaps->shared_dirty,
+                        MMAP_COL_DEVICE, device.c_str(),
+                        MMAP_COL_INODE, memmaps->inode,
+                        -1);
+}
+
+
+
+
+static void
+update_memmaps_dialog (MemMapsData *mmdata)
+{
+    GtkTreeModel *model;
+    glibtop_map_entry *memmaps;
+    glibtop_proc_map procmap;
+
+    memmaps = glibtop_get_proc_map (&procmap, mmdata->info->pid);
+    /* process has disappeared */
+    if(!memmaps or procmap.number == 0) return;
+
+    mmdata->format.set(memmaps[procmap.number - 1]);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+
+    GtkTreeIter iter;<--- Shadowed declaration
+
+    typedef std::map<guint64, GtkTreeIter> IterCache;
+    IterCache iter_cache;
+
+    /*
+      removes the old maps and
+      also fills a cache of start -> iter in order to speed
+      up add
+    */
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        while (true) {
+            char *vmstart = 0;
+            guint64 start;
+            gtk_tree_model_get(model, &iter,
+                               MMAP_COL_VMSTART, &vmstart,
+                               -1);
+
+            try {
+                std::istringstream(vmstart) >> std::hex >> start;
+            } catch (std::logic_error &e) {
+                g_warning("Could not parse %s", vmstart);
+                start = 0;
+            }
+
+            g_free(vmstart);
+
+            bool found = std::binary_search(memmaps, memmaps + procmap.number,
+                                            start, glibtop_map_entry_cmp());
+
+            if (found) {
+                iter_cache[start] = iter;
+                if (!gtk_tree_model_iter_next(model, &iter))
+                    break;
+            } else {
+                if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                    break;
+            }
+        }
+    }
+
+    mmdata->devices.update();
+
+    /*
+      add the new maps
+    */
+
+    for (guint i = 0; i != procmap.number; i++) {
+        GtkTreeIter iter;<--- Shadow variable
+        IterCache::iterator it(iter_cache.find(memmaps[i].start));
+
+        if (it != iter_cache.end())
+            iter = it->second;
+        else
+            gtk_list_store_prepend(GTK_LIST_STORE(model), &iter);
+
+        update_row(model, iter, *mmdata, &memmaps[i]);
+    }
+
+    g_free (memmaps);
+}
+
+
+
+static void
+dialog_response (GtkDialog * dialog, gint response_id, gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+
+    g_source_remove (mmdata->timer);
+
+    delete mmdata;
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+
+static MemMapsData*
+create_memmapsdata (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Filename"),
+        // xgettext: virtual memory start
+        N_("VM Start"),
+        // xgettext: virtual memory end
+        N_("VM End"),
+        // xgettext: virtual memory syze
+        N_("VM Size"),
+        N_("Flags"),
+        // xgettext: virtual memory offset
+        N_("VM Offset"),
+        // xgettext: memory that has not been modified since
+        // it has been allocated
+        N_("Private clean"),
+        // xgettext: memory that has been modified since it
+        // has been allocated
+        N_("Private dirty"),
+        // xgettext: shared memory that has not been modified
+        // since it has been allocated
+        N_("Shared clean"),
+        // xgettext: shared memory that has been modified
+        // since it has been allocated
+        N_("Shared dirty"),
+        N_("Device"),
+        N_("Inode")
+    };
+
+    model = gtk_list_store_new (MMAP_COL_MAX,
+                                G_TYPE_STRING, /* MMAP_COL_FILENAME  */
+                                G_TYPE_STRING, /* MMAP_COL_VMSTART     */
+                                G_TYPE_STRING, /* MMAP_COL_VMEND     */
+                                G_TYPE_UINT64, /* MMAP_COL_VMSZ     */
+                                G_TYPE_STRING, /* MMAP_COL_FLAGS     */
+                                G_TYPE_STRING, /* MMAP_COL_VMOFFSET  */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_DIRTY */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_DIRTY */
+                                G_TYPE_STRING, /* MMAP_COL_DEVICE     */
+                                G_TYPE_UINT64 /* MMAP_COL_INODE     */
+                                );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < MMAP_COL_MAX; i++) {
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(tree), col);
+
+        switch (i) {
+            case MMAP_COL_PRIVATE_CLEAN:
+            case MMAP_COL_PRIVATE_DIRTY:
+            case MMAP_COL_SHARED_CLEAN:
+            case MMAP_COL_SHARED_DIRTY:
+            case MMAP_COL_VMSZ:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                         &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+                break;
+        }
+
+
+        switch (i) {
+            case MMAP_COL_VMSTART:
+            case MMAP_COL_VMEND:
+            case MMAP_COL_FLAGS:
+            case MMAP_COL_VMOFFSET:
+            case MMAP_COL_DEVICE:
+                g_object_set(cell, "family", "monospace", NULL);
+                break;
+        }
+    }
+
+    return new MemMapsData(tree, procdata->settings);
+}
+
+
+static gboolean
+memmaps_timer (gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+    g_assert(model);
+
+    update_memmaps_dialog (mmdata);
+
+    return TRUE;
+}
+
+
+static void
+create_single_memmaps_dialog (GtkTreeModel *model, GtkTreePath *path,
+                              GtkTreeIter *iter, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    MemMapsData *mmdata;
+    GtkWidget *memmapsdialog;
+    GtkWidget *dialog_vbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    ProcInfo *info;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    mmdata = create_memmapsdata (procdata);
+    mmdata->info = info;
+
+    memmapsdialog = gtk_dialog_new_with_buttons (_("Memory Maps"), GTK_WINDOW (procdata->app),
+                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                 "gtk-close", GTK_RESPONSE_CLOSE,
+                                                 NULL);
+    gtk_window_set_resizable(GTK_WINDOW(memmapsdialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(memmapsdialog), 620, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(memmapsdialog), 5);
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG(memmapsdialog));
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Memory maps for process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), label, FALSE, TRUE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    gtk_container_add (GTK_CONTAINER (scrolled), mmdata->tree);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), mmdata->tree);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+
+    g_signal_connect(G_OBJECT(memmapsdialog), "response",
+                              G_CALLBACK(dialog_response), mmdata);
+
+    gtk_widget_show_all (memmapsdialog);
+
+    mmdata->timer = g_timeout_add_seconds (5, memmaps_timer, mmdata);
+
+    update_memmaps_dialog (mmdata);
+}
+
+
+void
+create_memmaps_dialog (ProcData *procdata)
+{
+    /* TODO: do we really want to open multiple dialogs ? */
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_memmaps_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/index.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/index.html new file mode 100644 index 00000000..02bb6ffc --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/index.html @@ -0,0 +1,323 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/cgroups.cpp
27variableScope398styleThe scope of the variable 'paren_offset' can be reduced.
27variableScope398styleThe scope of the variable 'off' can be reduced.
27variableScope398styleThe scope of the variable 'tmp_size' can be reduced.
55cstyleCast398styleC-style pointer casting
src/disks.cpp
202redundantAssignment563styleVariable 'res' is reassigned a value before the old one has been used.
src/gsm_color_button.c
648variableScope398styleThe scope of the variable 'color_chooser' can be reduced.
src/interface.cpp
452cstyleCast398styleC-style pointer casting
454cstyleCast398styleC-style pointer casting
src/load-graph.cpp
41shadowVariable398styleLocal variable 'n' shadows outer variable
164shadowVariable398styleLocal variable 'i' shadows outer variable
src/load-graph.h
36noExplicitConstructor398styleStruct 'LoadGraph' has a constructor with 1 argument that is not explicit.
src/lsof.cpp
164shadowVariable398styleLocal variable 'count' shadows outer variable
src/memmaps.cpp
269shadowVariable398styleLocal variable 'iter' shadows outer variable
src/msm-resources.c
9unusedStructMember563styleunion member 'Anonymous0::alignment' is never used.
9unusedStructMember563styleunion member 'Anonymous0::ptr' is never used.
src/openfiles.cpp
73nullPointerRedundantCheck476warningEither the condition 'res' is redundant or there is possible null pointer dereference: res.
205shadowVariable398styleLocal variable 'openfiles' shadows outer variable
247variableScope398styleThe scope of the variable 'column' can be reduced.
248variableScope398styleThe scope of the variable 'cell' can be reduced.
src/prettytable.h
39unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_opened'
40unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_closed'
src/procdialogs.cpp
294noExplicitConstructor398styleClass 'SpinButtonUpdater' has a constructor with 1 argument that is not explicit.
415shadowVariable398styleLocal variable 'column' shadows outer variable
475cstyleCast398styleC-style pointer casting
498cstyleCast398styleC-style pointer casting
513cstyleCast398styleC-style pointer casting
src/procman-app.cpp
348uninitMemberVar398warningMember variable 'ProcmanApp::procdata' is not initialized in the constructor.
src/procman.cpp
34uninitMemberVarPrivate398warningMember variable 'ProcData::uimanager' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::action_group' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::statusbar' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::loadavg' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::endprocessbutton' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::popup_menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::disk_list' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::notebook' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::config' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::selection' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::settings' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::app' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::frequency' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::smooth_refresh' is not initialized in the constructor.
112shadowVariable398styleLocal variable 'order' shadows outer variable
162shadowVariable398styleLocal variable 'order' shadows outer variable
src/procman.h
103uninitMemberVar398warningMember variable 'MutableProcInfo::cgroup_name' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::unit' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::session' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::seat' is not initialized in the constructor.
173noExplicitConstructor398styleClass 'ProcInfo' has a constructor with 1 argument that is not explicit.
src/procproperties.cpp
208variableScope398styleThe scope of the variable 'column' can be reduced.
209variableScope398styleThe scope of the variable 'cell' can be reduced.
src/proctable.cpp
920shadowVariable398styleLocal variable 'arguments' shadows outer variable
929shadowVariable398styleLocal variable 'tooltip' shadows outer variable
1016shadowVariable398styleLocal variable 'it' shadows outer variable
1022shadowVariable398styleLocal variable 'it' shadows outer variable
1068shadowVariable398styleLocal variable 'it' shadows outer variable
1073shadowVariable398styleLocal variable 'it' shadows outer variable
src/selinux.cpp
21varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
src/smooth_refresh.h
22noExplicitConstructor398styleClass 'SmoothRefresh' has a constructor with 1 argument that is not explicit.
src/sysinfo.cpp
126unusedPrivateFunction398styleUnused private function: 'SysInfo::get_os_type'
233cstyleCast398styleC-style pointer casting
343cstyleCast398styleC-style pointer casting
509uninitMemberVar398warningMember variable 'LSBSysInfo::lsb_fd' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::name' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::release' is not initialized in the constructor.
515missingOverridestyleThe function 'set_distro_labels' overrides a function in a base class but is not marked with a 'override' specifier.
570shadowVariable398styleLocal variable 'release' shadows outer variable
615unusedPrivateFunction398styleUnused private function: 'LSBSysInfo::sync_lsb_release'
626variableScope398styleThe scope of the variable 'codename' can be reduced.
626shadowVariable398styleLocal variable 'release' shadows outer variable
690stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
697stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
701stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
736variableScope398styleThe scope of the variable 'len' can be reduced.
738stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
1001unreadVariable563styleVariable 'table_count' is assigned a value that is never used.
+
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/stats.html b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/stats.html new file mode 100644 index 00000000..aa8922ed --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/stats.html @@ -0,0 +1,189 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+

Top 10 files for warning severity, total findings: 24
+   15  src/procman.cpp
+   4   src/procman.h
+   3   src/sysinfo.cpp
+   1   src/procman-app.cpp
+   1   src/openfiles.cpp
+

+

Top 10 files for portability severity, total findings: 1
+   1  src/selinux.cpp
+

+

Top 10 files for performance severity, total findings: 4
+   4  src/sysinfo.cpp
+

+

Top 10 files for style severity, total findings: 47
+   10  src/sysinfo.cpp
+   6   src/proctable.cpp
+   5   src/procdialogs.cpp
+   4   src/cgroups.cpp
+   3   src/openfiles.cpp
+   2   src/procproperties.cpp
+   2   src/procman.cpp
+   2   src/prettytable.h
+   2   src/msm-resources.c
+   2   src/load-graph.cpp
+

+ +
+ +
+ + diff --git a/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/style.css b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/style.css new file mode 100644 index 00000000..3897bfaf --- /dev/null +++ b/2023-09-11-112328-4957-cppcheck@3d354f8f4fd2_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/index.html b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/index.html new file mode 100644 index 00000000..f3b6ae82 --- /dev/null +++ b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/index.html @@ -0,0 +1,136 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@298ea2b81eac
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 16.0.6 (Fedora 16.0.6-3.fc38) +
Date:Mon Oct 2 17:01:48 2023
+

Bug Summary

+ + + + + + + +
Bug TypeQuantityDisplay?
All Bugs14
Logic error
Use of identical expressions1
Unused code
Dead assignment1
Unreachable code12
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
Unused codeDead assignmentrootdir/src/disks.cppget_mount_opt2011View Report
Unused codeUnreachable coderootdir/src/procman-app.cppon_command_line3811View Report
Unused codeUnreachable coderootdir/src/util.cppio_rate_cell_data_func4941View Report
Unused codeUnreachable coderootdir/src/util.cppstatus_cell_data_func5911View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_gicon421View Report
Unused codeUnreachable coderootdir/src/util.cppduration_cell_data_func5351View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_na_cell_data_func3841View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_na_cell_data_func4561View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_cell_data_func4221View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_icon131View Report
Unused codeUnreachable coderootdir/src/util.cpptime_cell_data_func5641View Report
Unused codeUnreachable coderootdir/src/procman-app.cpptimeouts_changed_cb1511View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_cell_data_func3501View Report
Logic errorUse of identical expressionsusr/include/sigc++-2.0/sigc++/visit_each.hoperator()981View Report
+ + diff --git a/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-22e004.html b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-22e004.html new file mode 100644 index 00000000..034692cc --- /dev/null +++ b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-22e004.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 381, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-02-170148-6118-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
This statement is never executed
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-491eb3.html b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-491eb3.html new file mode 100644 index 00000000..fa5f5d1f --- /dev/null +++ b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-491eb3.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 494, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-02-170148-6118-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-4d889d.html b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-4d889d.html new file mode 100644 index 00000000..cf5225d1 --- /dev/null +++ b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-4d889d.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 591, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-02-170148-6118-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-633ebf.html b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-633ebf.html new file mode 100644 index 00000000..9ad14f6b --- /dev/null +++ b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-633ebf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 42, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-02-170148-6118-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
This statement is never executed
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-6c54e6.html b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-6c54e6.html new file mode 100644 index 00000000..35862d47 --- /dev/null +++ b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-6c54e6.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 535, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-02-170148-6118-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-6c8186.html b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-6c8186.html new file mode 100644 index 00000000..a6c69baf --- /dev/null +++ b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-6c8186.html @@ -0,0 +1,886 @@ + + + +/usr/include/sigc++-2.0/sigc++/visit_each.h + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:usr/include/sigc++-2.0/sigc++/visit_each.h
Warning:line 98, column 64
identical expressions on both sides of logical operator
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-02-170148-6118-1 -x c++ procman.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright 2002, The libsigc++ Development Team
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18#ifndef _SIGC_VISIT_EACH_HPP_
19#define _SIGC_VISIT_EACH_HPP_
20
21#include <sigc++/type_traits.h>
22#include <type_traits>
23
24namespace sigc {
25
26#ifndef DOXYGEN_SHOULD_SKIP_THIS
27namespace internal {
28
29//This should really be an inner class of limit_derived_target, without the T_limit template type,
30//But the SUN CC 5.7 (not earlier versions) compiler finds it ambiguous when we specify a particular specialization of it.
31//and does not seem to allow us to tell it explicitly that it's an inner class.
32template <bool I_derived, class T_type, class T_limit>
33struct with_type;
34
35//Specialization for I_derived = false
36template <class T_type, class T_limit> struct
37with_type<false, T_type, T_limit>
38{
39 static void execute_(const T_type&, const T_limit&) {}
40};
41
42//Specialization for I_derived = true
43template <class T_type, class T_limit>
44struct with_type<true, T_type, T_limit>
45{
46 static void execute_(const T_type& _A_type, const T_limit& _A_action)
47 { _A_action.action_(_A_type); }
48};
49
50
51/// Helper struct for visit_each_type().
52template <class T_target, class T_action>
53struct limit_derived_target
54{
55 typedef limit_derived_target<T_target, T_action> T_self;
56
57 template <class T_type>
58 void operator()(const T_type& _A_type) const
59 {
60 with_type<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
61 }
62
63 limit_derived_target(const T_action& _A_action)
64 : action_(_A_action)
65 {}
66
67 T_action action_;
68};
69
70// Specialization for T_target pointer types, to provide a slightly different execute_() implementation.
71
72template <bool I_derived, class T_type, class T_limit>
73struct with_type_pointer;
74
75//Specialization for I_derived = false
76template <class T_type, class T_limit>
77struct with_type_pointer<false, T_type, T_limit>
78{
79 static void execute_(const T_type&, const T_limit&) {}
80};
81
82//Specialization for I_derived = true
83template <class T_type, class T_limit>
84struct with_type_pointer<true, T_type, T_limit>
85{
86 static void execute_(const T_type& _A_type, const T_limit& _A_action)
87 { _A_action.action_(&_A_type); }
88};
89
90template <class T_target, class T_action>
91struct limit_derived_target<T_target*, T_action>
92{
93 typedef limit_derived_target<T_target*, T_action> T_self;
94
95 template <class T_type>
96 void operator()(const T_type& _A_type) const
97 {
98 with_type_pointer<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
identical expressions on both sides of logical operator
99 }
100
101 limit_derived_target(const T_action& _A_action)
102 : action_(_A_action)
103 {}
104
105 T_action action_;
106};
107
108} /* namespace internal */
109#endif // DOXYGEN_SHOULD_SKIP_THIS
110
111// struct visitor was introduced as a result of https://bugzilla.gnome.org/show_bug.cgi?id=724496
112// The advantage of using specializations of a template struct instead of overloads of
113// a template function is described by Herb Sutter in http://www.gotw.ca/publications/mill17.htm
114// In libsigc++ the main reason for using this technique is that we can avoid using ADL
115// (argument-dependent lookup), and therefore there is no risk that a visit_each() overload
116// in e.g. Boost is selected by mistake.
117
118/** sigc::visitor<T_functor>::do_visit_each() performs a functor on each of the targets of a functor.
119 * All unknown types just call @a _A_action on them.
120 * Add specializations that specialize the @a T_functor argument for your own
121 * functor types, so that subobjects get visited. This is needed to enable
122 * auto-disconnection support for your functor types.
123 *
124 * @par Example:
125 * @code
126 * namespace some_ns
127 * {
128 * struct some_functor
129 * {
130 * void operator()() {}
131 * some_possibly_sigc_trackable_derived_type some_data_member;
132 * some_other_functor_type some_other_functor;
133 * };
134 * }
135 *
136 * namespace sigc
137 * {
138 * template <>
139 * struct visitor<some_ns::some_functor>
140 * {
141 * template <class T_action>
142 * static void do_visit_each(const T_action& _A_action,
143 * const some_ns::some_functor& _A_target)
144 * {
145 * sigc::visit_each(_A_action, _A_target.some_data_member);
146 * sigc::visit_each(_A_action, _A_target.some_other_functor);
147 * }
148 * };
149 * }
150 * @endcode
151 *
152 * @ingroup sigcfunctors
153 */
154template <class T_functor>
155struct visitor
156{
157 template <class T_action>
158 static void do_visit_each(const T_action& _A_action, const T_functor& _A_functor)
159 {
160 _A_action(_A_functor);
161 }
162};
163
164/** This function performs a functor on each of the targets of a functor.
165 *
166 * @ingroup sigcfunctors
167 */
168template <class T_action, class T_functor>
169void visit_each(const T_action& _A_action, const T_functor& _A_functor)
170{ sigc::visitor<T_functor>::do_visit_each(_A_action, _A_functor); }
171
172/** This function performs a functor on each of the targets
173 * of a functor limited to a restricted type.
174 *
175 * @ingroup sigcfunctors
176 */
177template <class T_type, class T_action, class T_functor>
178void visit_each_type(const T_action& _A_action, const T_functor& _A_functor)
179{
180 typedef internal::limit_derived_target<T_type, T_action> type_limited_action;
181
182 type_limited_action limited_action(_A_action);
183
184 //specifying the types of the template specialization prevents disconnection of bound trackable references (such as with std::ref()),
185 //probably because the visit_each<> specializations take various different template types,
186 //in various sequences, and we are probably specifying only a subset of them with this.
187 //
188 //But this is required by the AIX (and maybe IRIX MipsPro and Tru64) compilers.
189 //I guess that std::ref() therefore does not work on those platforms. murrayc
190 // sigc::visit_each<type_limited_action, T_functor>(limited_action, _A_functor);
191
192 //g++ (even slightly old ones) is our primary platform, so we could use the non-crashing version.
193 //However, the explicit version also fixes a crash in a slightly more common case: http://bugzilla.gnome.org/show_bug.cgi?id=169225
194 //Users (and distributors) of libsigc++ on AIX (and maybe IRIX MipsPro and Tru64) do
195 //need to use the version above instead, to allow compilation.
196
197 //Added 2014-03-20: The preceding comment probably does not apply any more,
198 //now when the visit_each<>() overloads have been replaced by visitor<> specializations.
199 //It's probably safe to add explicit template parameters on calls to visit_each(),
200 //visit_each_type() and visitor::do_visit_each(), if necessary.
201
202 sigc::visit_each(limited_action, _A_functor);
203}
204
205} /* namespace sigc */
206#endif
diff --git a/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-77634b.html b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-77634b.html new file mode 100644 index 00000000..8d30e7f9 --- /dev/null +++ b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-77634b.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 384, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-02-170148-6118-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-7bbc8c.html b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-7bbc8c.html new file mode 100644 index 00000000..1c494967 --- /dev/null +++ b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-7bbc8c.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 456, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-02-170148-6118-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-7ce786.html b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-7ce786.html new file mode 100644 index 00000000..05901eee --- /dev/null +++ b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-7ce786.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 422, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-02-170148-6118-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-802eaf.html b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-802eaf.html new file mode 100644 index 00000000..8a87ad69 --- /dev/null +++ b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-802eaf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 13, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-02-170148-6118-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
This statement is never executed
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-8e6c9c.html b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-8e6c9c.html new file mode 100644 index 00000000..bc07e31c --- /dev/null +++ b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-8e6c9c.html @@ -0,0 +1,1200 @@ + + + +disks.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/disks.cpp
Warning:line 201, column 13
Value stored to 'res' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name disks.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-02-170148-6118-1 -x c++ disks.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#ifdef __linux__1
4#include <mntent.h>
5#endif // __linux__
6
7#include <giomm.h>
8#include <giomm/themedicon.h>
9#include <gtk/gtk.h>
10#include <glibtop/mountlist.h>
11#include <glibtop/fsusage.h>
12#include <glib/gi18n.h>
13
14#include "procman.h"
15#include "disks.h"
16#include "util.h"
17#include "interface.h"
18#include "iconthemewrapper.h"
19
20namespace
21{
22 const unsigned DISK_ICON_SIZE = 24;
23}
24
25enum DiskColumns
26{
27 /* string columns* */
28 DISK_DEVICE,
29 DISK_DIR,
30 DISK_TYPE,
31 DISK_SUBVOLUME,
32 DISK_TOTAL,
33 DISK_FREE,
34 DISK_AVAIL,
35 /* USED has to be the last column */
36 DISK_USED,
37 // then unvisible columns
38 /* Surface column */
39 DISK_ICON,
40 /* numeric columns */
41 DISK_USED_PERCENTAGE,
42 DISK_N_COLUMNS
43};
44
45
46
47static void
48fsusage_stats(const glibtop_fsusage *buf,
49 guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
50 gint *percentage)
51{
52 guint64 total = buf->blocks * buf->block_size;
53
54 if (!total) {
55 /* not a real device */
56 *btotal = *bfree = *bavail = *bused = 0ULL;
57 *percentage = 0;
58 } else {
59 int percent;
60 *btotal = total;
61 *bfree = buf->bfree * buf->block_size;
62 *bavail = buf->bavail * buf->block_size;
63 *bused = *btotal - *bfree;
64 /* percent = 100.0f * *bused / *btotal; */
65 percent = 100 * *bused / (*bused + *bavail);
66 *percentage = CLAMP(percent, 0, 100)(((percent) > (100)) ? (100) : (((percent) < (0)) ? (0)
: (percent)))
;
67 }
68}
69
70
71namespace
72{
73 string get_icon_for_path(const std::string& path)
74 {
75 using namespace Glib;
76 using namespace Gio;
77
78 // FIXME: I don't know whether i should use Volume or Mount or UnixMount
79 // all i need an icon name.
80 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
81
82 std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
83
84 for (size_t i = 0; i != mounts.size(); ++i) {
85 if (mounts[i]->get_name() != path)
86 continue;
87
88 RefPtr<Icon> icon = mounts[i]->get_icon();
89 RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
90
91 if (themed_icon) {
92 char* name = 0;
93 // FIXME: not wrapped yet
94 g_object_get(G_OBJECT(themed_icon->gobj())((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((themed_icon->gobj())), (((GType) ((20) << (2)))
)))))
, "name", &name, NULL__null);
95 return make_string(name);
96 }
97 }
98
99 return "";
100 }
101}
102
103
104static Glib::RefPtr<Gdk::Pixbuf>
105get_icon_for_device(const char *mountpoint)
106{
107 procman::IconThemeWrapper icon_theme;
108 string icon_name = get_icon_for_path(mountpoint);
109 if (icon_name == "")
110 // FIXME: defaults to a safe value
111 icon_name = "drive-harddisk"; // get_icon_for_path("/");
112 return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
113}
114
115
116static gboolean
117find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
118 GtkTreeIter *result)
119{
120 GtkTreeIter iter;
121 gboolean found = FALSE(0);
122
123 if (gtk_tree_model_get_iter_first(model, &iter)) {
124 do {
125 char *dir;
126
127 gtk_tree_model_get(model, &iter,
128 DISK_DIR, &dir,
129 -1);
130
131 if (dir && !strcmp(dir, mountpoint)) {
132 *result = iter;
133 found = TRUE(!(0));
134 }
135
136 g_free(dir);
137
138 } while (!found && gtk_tree_model_iter_next(model, &iter));
139 }
140
141 return found;
142}
143
144
145
146static void
147remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
148{
149 GtkTreeIter iter;
150
151 if (!gtk_tree_model_get_iter_first(model, &iter))
152 return;
153
154 while (true) {
155 char *dir;
156 guint i;
157 gboolean found = FALSE(0);
158
159 gtk_tree_model_get(model, &iter,
160 DISK_DIR, &dir,
161 -1);
162
163 for (i = 0; i != n; ++i) {
164 if (!strcmp(dir, entries[i].mountdir)) {
165 found = TRUE(!(0));
166 break;
167 }
168 }
169
170 g_free(dir);
171
172 if (!found) {
173 if (!gtk_list_store_remove(GTK_LIST_STORE(model)((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_list_store_get_type ()))))))
, &iter))
174 break;
175 else
176 continue;
177 }
178
179 if (!gtk_tree_model_iter_next(model, &iter))
180 break;
181 }
182}
183
184#ifdef __linux__1
185static char *
186get_mount_opt(const glibtop_mountentry *entry, const char* opt)
187{
188 char *opt_value = NULL__null;
189 const struct mntent *mnt;
190 FILE *fp;
191
192 if (!(fp = setmntent(MOUNTED"/etc/mtab", "r"))) {
193 goto out;
194 }
195
196 while ((mnt = getmntent(fp))) {
197 if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
198 (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
199 char *res;
200
201 res = hasmntopt(mnt, "subvol");
Value stored to 'res' is never read
202 if ((res = hasmntopt(mnt, "subvol")) != NULL__null) {
203 char **strs = g_strsplit_set(res, "=", 2);
204
205 if (g_strv_length(strs) == 2) {
206 char *value = strs[1];
207 if (g_strcmp0 (value,"/root") == 0)
208 opt_value = g_strdup("/")g_strdup_inline ("/");
209 else
210 opt_value = g_strdup(strs[1])g_strdup_inline (strs[1]);
211 g_strfreev(strs);
212 }
213 }
214 break;
215 }
216 }
217
218 endmntent(fp);
219
220 out:
221 return opt_value;
222}
223#endif // __linux__
224
225
226static void
227add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
228{
229 Glib::RefPtr<Gdk::Pixbuf> pixbuf;
230 cairo_surface_t *surface;
231 GtkTreeIter iter;
232 glibtop_fsusage usage;
233 guint64 bused, bfree, bavail, btotal;
234 gint percentage;
235#ifdef __linux__1
236 char *subvol = NULL__null;
237#endif // __linux__
238
239 glibtop_get_fsusage(&usage, entry->mountdir);
240
241 if (not show_all_fs and usage.blocks == 0) {
242 if (find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
243 gtk_list_store_remove(list, &iter);
244 return;
245 }
246
247 fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
248#ifdef __linux__1
249 subvol = get_mount_opt(entry, "subvol");
250#endif // __linux__
251 pixbuf = get_icon_for_device(entry->mountdir);
252 surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL__null);
253
254 /* if we can find a row with the same mountpoint, we get it but we
255 still need to update all the fields.
256 This makes selection persistent.
257 */
258 if (!find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
259 gtk_list_store_append(list, &iter);
260
261 gtk_list_store_set(list, &iter,
262 DISK_ICON, surface,
263 DISK_DEVICE, entry->devname,
264 DISK_DIR, entry->mountdir,
265 DISK_TYPE, entry->type,
266#ifdef __linux__1
267
268 DISK_SUBVOLUME, subvol != NULL__null ? subvol : "",
269#else
270 DISK_SUBVOLUME, "",
271#endif // __linux__
272 DISK_USED_PERCENTAGE, percentage,
273 DISK_TOTAL, btotal,
274 DISK_FREE, bfree,
275 DISK_AVAIL, bavail,
276 DISK_USED, bused,
277 -1);
278#ifdef __linux__1
279 g_free (subvol);
280#endif // __linux__
281}
282
283
284
285int
286cb_update_disks(gpointer data)
287{
288 ProcData *const procdata = static_cast<ProcData*>(data);
289
290 GtkListStore *list;
291 glibtop_mountentry * entries;
292 glibtop_mountlist mountlist;
293 guint i;
294
295 list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)))((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_tree_view_get_model(((((GtkTreeView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((procdata->disk_list)), ((gtk_tree_view_get_type
()))))))))), ((gtk_list_store_get_type ()))))))
;
296
297 entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
298
299 remove_old_disks(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entries, mountlist.number);
300
301 for (i = 0; i < mountlist.number; i++)
302 add_disk(list, &entries[i], procdata->config.show_all_fs);
303
304 g_free(entries);
305
306 return TRUE(!(0));
307}
308
309
310static void
311cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
312{
313 ProcData * const procdata = static_cast<ProcData*>(user_data);
314
315 procman_save_tree_state(procdata->settings,
316 GTK_WIDGET(treeview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_widget_get_type ()))))))
,
317 "disktreenew");
318}
319
320
321static void
322open_dir(GtkTreeView *tree_view,
323 GtkTreePath *path,
324 GtkTreeViewColumn *column,
325 gpointer user_data)
326{
327 GtkTreeIter iter;
328 GtkTreeModel *model;
329 char *dir, *url;
330
331 model = gtk_tree_view_get_model(tree_view);
332
333 if (!gtk_tree_model_get_iter(model, &iter, path)) {
334 char *p;
335 p = gtk_tree_path_to_string(path);
336 g_warning("Cannot get iter for path '%s'\n", p);
337 g_free(p);
338 return;
339 }
340
341 gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
342
343 url = g_strdup_printf("file://%s", dir);
344
345 GError* error = 0;
346 if (!g_app_info_launch_default_for_uri(url, NULL__null, &error)) {
347 g_warning("Cannot open '%s' : %s\n", url, error->message);
348 g_error_free(error);
349 }
350
351 g_free(url);
352 g_free(dir);
353}
354
355static guint timeout_id = 0;
356static GtkTreeViewColumn *current_column;
357
358static gboolean
359save_column_width (gpointer data)
360{
361 gint width;
362 gchar *key;
363 int id;
364 GSettings *settings;
365
366 settings = g_settings_get_child (G_SETTINGS (data)((((GSettings*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((g_settings_get_type ()))))))
, "disktreenew");
367 id = gtk_tree_view_column_get_sort_column_id (current_column);
368 width = gtk_tree_view_column_get_width (current_column);
369
370 key = g_strdup_printf ("col-%d-width", id);
371 g_settings_set_int(settings, key, width);
372 g_free (key);
373
374 if (timeout_id) {
375 g_source_remove (timeout_id);
376 timeout_id = 0;
377 }
378
379 return FALSE(0);
380}
381
382static void
383cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
384{
385 current_column = GTK_TREE_VIEW_COLUMN(widget)((((GtkTreeViewColumn*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((widget)), ((gtk_tree_view_column_get_type (
)))))))
;
386
387 if (timeout_id)
388 g_source_remove (timeout_id);
389
390 timeout_id = g_timeout_add (250, save_column_width, data);
391}
392
393void
394create_disk_view(ProcData *procdata, GtkBuilder *builder)
395{
396 GtkWidget *scrolled;
397 GtkWidget *disk_tree;
398 GtkListStore *model;
399 GtkTreeViewColumn *col;
400 GtkCellRenderer *cell;
401 guint i;
402
403 const gchar * const titles[] = {
404 N_("Device")("Device"),
405 N_("Directory")("Directory"),
406 N_("Type")("Type"),
407 N_("SubVolume")("SubVolume"),
408 N_("Total")("Total"),
409 N_("Free")("Free"),
410 N_("Available")("Available"),
411 N_("Used")("Used")
412 };
413
414 scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "disks_scrolled"))), ((
gtk_widget_get_type ()))))))
;
415
416 model = gtk_list_store_new(DISK_N_COLUMNS, /* n columns */
417 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DEVICE */
418 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DIR */
419 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_TYPE */
420 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_SUBVOLUME */
421 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_TOTAL */
422 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_FREE */
423 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_AVAIL */
424 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_USED */
425 CAIRO_GOBJECT_TYPE_SURFACEcairo_gobject_surface_get_type (), /* DISK_ICON */
426 G_TYPE_INT((GType) ((6) << (2)))); /* DISK_USED_PERCENTAGE */
427
428 disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_model_get_type ()))))))
);
429 g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("row-activated"), (((GCallback) (open_dir))), (__null
), __null, (GConnectFlags) 0)
;
430 procdata->disk_list = disk_tree;
431 gtk_container_add(GTK_CONTAINER(scrolled)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((scrolled)), ((gtk_container_get_type ()))))))
, disk_tree);
432 g_object_unref(G_OBJECT(model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
);
433
434 /* icon + device */
435
436 col = gtk_tree_view_column_new();
437 cell = gtk_cell_renderer_pixbuf_new();
438 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
439 gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
440 NULL__null);
441
442 cell = gtk_cell_renderer_text_new();
443 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
444 gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
445 NULL__null);
446 gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE])gettext (titles[DISK_DEVICE]));
447 gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
448 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
449 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
450 gtk_tree_view_column_set_min_width (col, 30);
451 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
452 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
453 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
454
455 /* sizes - used */
456
457 for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
458 cell = gtk_cell_renderer_text_new();
459 col = gtk_tree_view_column_new();
460 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
461 gtk_tree_view_column_set_title(col, _(titles[i])gettext (titles[i]));
462 gtk_tree_view_column_set_sort_column_id(col, i);
463 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
464 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
465 gtk_tree_view_column_set_min_width (col, 30);
466 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
467 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
468 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
469
470 switch (i) {
471 case DISK_TOTAL:
472 case DISK_FREE:
473 case DISK_AVAIL:
474 g_object_set(cell, "xalign", 1.0f, NULL__null);
475 gtk_tree_view_column_set_cell_data_func(col, cell,
476 &procman::storage_size_cell_data_func,
477 GUINT_TO_POINTER(i)((gpointer) (gulong) (i)),
478 NULL__null);
479 break;
480
481 default:
482 gtk_tree_view_column_set_attributes(col, cell,
483 "text", i,
484 NULL__null);
485 break;
486 }
487 }
488
489 /* used + percentage */
490
491 col = gtk_tree_view_column_new();
492 cell = gtk_cell_renderer_text_new();
493 g_object_set(cell, "xalign", 1.0f, NULL__null);
494 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
495 gtk_tree_view_column_set_cell_data_func(col, cell,
496 &procman::storage_size_cell_data_func,
497 GUINT_TO_POINTER(DISK_USED)((gpointer) (gulong) (DISK_USED)),
498 NULL__null);
499
500 cell = gtk_cell_renderer_progress_new();
501 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
502 gtk_tree_view_column_set_attributes(col, cell, "value",
503 DISK_USED_PERCENTAGE, NULL__null);
504 gtk_tree_view_column_set_title(col, _(titles[DISK_USED])gettext (titles[DISK_USED]));
505 gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
506 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
507 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
508 gtk_tree_view_column_set_min_width (col, 150);
509 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
510 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
511 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
512
513 /* numeric sort */
514
515 procman_get_tree_state(procdata->settings, disk_tree,
516 "disktreenew");
517
518 g_signal_connect (G_OBJECT(disk_tree), "columns-changed",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
519 G_CALLBACK(cb_disk_columns_changed), procdata)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
;
520}
diff --git a/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-c673b5.html b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-c673b5.html new file mode 100644 index 00000000..e5aff0ba --- /dev/null +++ b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-c673b5.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 564, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-02-170148-6118-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-d507c5.html b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-d507c5.html new file mode 100644 index 00000000..8140067a --- /dev/null +++ b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-d507c5.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 151, column 9
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-02-170148-6118-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
This statement is never executed
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-e8ff80.html b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-e8ff80.html new file mode 100644 index 00000000..d8e71156 --- /dev/null +++ b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/report-e8ff80.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 350, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-02-170148-6118-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/scanview.css b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/scanview.css new file mode 100644 index 00000000..cf8a5a6a --- /dev/null +++ b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/sorttable.js b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/sorttable.js new file mode 100644 index 00000000..32faa078 --- /dev/null +++ b/2023-10-02-170148-6118-1@3d354f8f4fd2_test-CI/sorttable.js @@ -0,0 +1,492 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse',''); + cell.className = cell.className.replace('sorttable_sorted',''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j=0; j 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } + else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } + else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i=0; i=0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a,b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); + if (isNaN(bb)) bb = 0; + return aa-bb; + }, + sort_alpha: function(a,b) { + if (a[0]==b[0]) return 0; + if (a[0] 0 ) { + var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for(var i = t; i > b; --i) { + if ( comp_func(list[i], list[i-1]) < 0 ) { + var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write(" + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/optionentry.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+
+#include "argv.h"
+
+namespace procman
+{
+    OptionGroup::OptionGroup()
+        : Glib::OptionGroup("", ""),
+          show_system_tab(false),
+          show_processes_tab(false),
+          show_resources_tab(false),
+          show_file_systems_tab(false)
+    {
+        Glib::OptionEntry sys_tab;
+        sys_tab.set_long_name("show-system-tab");
+        sys_tab.set_short_name('s');
+        sys_tab.set_description(_("Show the System tab"));
+
+        Glib::OptionEntry proc_tab;
+        proc_tab.set_long_name("show-processes-tab");
+        proc_tab.set_short_name('p');
+        proc_tab.set_description(_("Show the Processes tab"));
+
+        Glib::OptionEntry res_tab;
+        res_tab.set_long_name("show-resources-tab");
+        res_tab.set_short_name('r');
+        res_tab.set_description(_("Show the Resources tab"));
+
+        Glib::OptionEntry fs_tab;
+        fs_tab.set_long_name("show-file-systems-tab");
+        fs_tab.set_short_name('f');
+        fs_tab.set_description(_("Show the File Systems tab"));
+
+        this->add_entry(sys_tab, this->show_system_tab);
+        this->add_entry(proc_tab, this->show_processes_tab);
+        this->add_entry(res_tab, this->show_resources_tab);
+        this->add_entry(fs_tab, this->show_file_systems_tab);
+    }
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/1.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/1.html new file mode 100644 index 00000000..9abf2d68 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/1.html @@ -0,0 +1,279 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
#ifndef H_PROCMAN_ARGV_1205873424
+#define H_PROCMAN_ARGV_1205873424
+
+#include <glibmm/optiongroup.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+namespace procman
+{
+    class OptionGroup
+        : public Glib::OptionGroup
+    {
+      public:
+        OptionGroup();
+
+        bool show_system_tab;
+        bool show_processes_tab;
+        bool show_resources_tab;
+        bool show_file_systems_tab;
+    };
+}
+
+#endif // H_PROCMAN_ARGV_1205873424
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/10.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/10.html new file mode 100644 index 00000000..4d43bbc7 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/10.html @@ -0,0 +1,391 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
/* Procman - tree view
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef _PROCMAN_PROCTABLE_H_
+#define _PROCMAN_PROCTABLE_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+enum
+{
+    COL_NAME = 0,
+    COL_USER,
+    COL_STATUS,
+    COL_VMSIZE,
+    COL_MEMRES,
+    COL_MEMWRITABLE,
+    COL_MEMSHARED,
+    COL_MEMXSERVER,
+    COL_CPU,
+    COL_CPU_TIME,
+    COL_START_TIME,
+    COL_NICE,
+    COL_PID,
+    COL_SECURITYCONTEXT,
+    COL_ARGS,
+    COL_MEM,
+    COL_WCHAN,
+    COL_CGROUP,
+    COL_UNIT,
+    COL_SESSION,
+    COL_SEAT,
+    COL_OWNER,
+    COL_DISK_WRITE_TOTAL,
+    COL_DISK_READ_TOTAL,
+    COL_DISK_WRITE_CURRENT,
+    COL_DISK_READ_CURRENT,
+    COL_PRIORITY,
+    COL_SURFACE,
+    COL_POINTER,
+    COL_TOOLTIP,
+    NUM_COLUMNS
+};
+
+GtkWidget*      proctable_new (ProcData *data);
+void            proctable_update_table (ProcData *data);
+void            proctable_update (ProcData *data);
+void            proctable_clear_tree (ProcData *data);
+void            proctable_free_table (ProcData *data);
+
+GSList*         proctable_get_columns_order(GtkTreeView *treeview);
+void            proctable_set_columns_order(GtkTreeView *treeview, GSList *order);
+
+char*           make_loadavg_string(void);
+
+void            get_last_selected (GtkTreeModel *model, GtkTreePath *path,
+                                   GtkTreeIter *iter, gpointer data);
+
+#endif /* _PROCMAN_PROCTABLE_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/11.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/11.html new file mode 100644 index 00000000..cd51236f --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/11.html @@ -0,0 +1,499 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
// -*- mode: c++ -*-
+
+#ifndef H_MATE_SYSTEM_MONITOR_UTIL_1123178725
+#define H_MATE_SYSTEM_MONITOR_UTIL_1123178725
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+using std::string;
+
+/* check if logind is running */
+#define LOGIND_RUNNING() (access("/run/systemd/seats/", F_OK) >= 0)
+
+GtkWidget*
+procman_make_label_for_mmaps_or_ofiles(const char *format,
+                                       const char *process_name,
+                                       unsigned pid);
+
+gboolean
+load_symbols(const char *module, ...) G_GNUC_NULL_TERMINATED;
+
+gchar *
+procman_format_date_for_display(time_t time_raw);
+
+const char*
+format_process_state(guint state);
+
+void
+procman_debug_real(const char *file, int line, const char *func,
+                   const char *format, ...) G_GNUC_PRINTF(4, 5);
+
+#define procman_debug(FMT, ...) procman_debug_real(__FILE__, __LINE__, __func__, FMT, ##__VA_ARGS__)
+
+inline string make_string(char *c_str)
+{
+    if (!c_str) {
+        procman_debug("NULL string");
+        return string();
+    }
+
+    string s(c_str);
+    g_free(c_str);
+    return s;
+}
+
+namespace procman
+{
+    gchar* format_duration_for_display(unsigned centiseconds);
+
+    void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                    GtkTreeModel *model, GtkTreeIter *iter,
+                                    gpointer user_data);
+
+    void io_rate_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                GtkTreeModel *model, GtkTreeIter *iter,
+                                gpointer user_data);
+
+    void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                       GtkTreeModel *model, GtkTreeIter *iter,
+                                       gpointer user_data);
+
+    void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                     GtkTreeModel *model, GtkTreeIter *iter,
+                                     gpointer user_data);
+
+    void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                        GtkTreeModel *model, GtkTreeIter *iter,
+                                        gpointer user_data);
+
+    void duration_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                   GtkTreeModel *model, GtkTreeIter *iter,
+                   gpointer user_data);
+
+    void time_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                             GtkTreeModel *model, GtkTreeIter *iter,
+                             gpointer user_data);
+
+    void status_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                               GtkTreeModel *model, GtkTreeIter *iter,
+                               gpointer user_data);
+    void priority_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                               GtkTreeModel *model, GtkTreeIter *iter,
+                               gpointer user_data);
+    gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
+                            GtkTreeIter* second, gpointer user_data);
+    gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
+                            GtkTreeIter* second, gpointer user_data);
+
+    template<typename T>
+    void poison(T &t, char c)
+    {
+        memset(&t, c, sizeof t);
+    }
+
+    //
+    // Stuff to update a tree_store in a smart way
+    //
+
+    template<typename T>
+    void tree_store_update(GtkTreeModel* model, GtkTreeIter* iter, int column, const T& new_value)
+    {
+        T current_value;
+
+        gtk_tree_model_get(model, iter, column, &current_value, -1);
+
+        if (current_value != new_value)
+            gtk_tree_store_set(GTK_TREE_STORE(model), iter, column, new_value, -1);
+    }
+
+    // undefined
+    // catch every thing about pointers
+    // just to make sure i'm not doing anything wrong
+    template<typename T>
+    void tree_store_update(GtkTreeModel* model, GtkTreeIter* iter, int column, T* new_value);
+
+    // specialized versions for strings
+    template<>
+    void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value);
+
+    template<>
+    inline void tree_store_update<char>(GtkTreeModel* model, GtkTreeIter* iter, int column, char* new_value)<--- Parameter 'new_value' can be declared as pointer to const
+    {
+         tree_store_update<const char>(model, iter, column, new_value);
+    }
+
+    gchar* get_nice_level (gint nice);
+}
+
+#endif /* H_MATE_SYSTEM_MONITOR_UTIL_1123178725 */
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/12.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/12.html new file mode 100644 index 00000000..5c3897fb --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/12.html @@ -0,0 +1,341 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
/* Procman - dialogs
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef _PROCDIALOGS_H_
+#define _PROCDIALOGS_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+/* These are the actual range of settable values. Values outside this range
+   are scaled back to these limits. So show these limits in the slider
+*/
+#ifdef __linux__
+#define RENICE_VAL_MIN -20
+#define RENICE_VAL_MAX 19
+#else /* ! linux */
+#define RENICE_VAL_MIN -20
+#define RENICE_VAL_MAX 20
+#endif
+
+typedef enum
+{
+    PROCMAN_ACTION_RENICE,
+    PROCMAN_ACTION_KILL
+} ProcmanActionType;
+
+void                    procdialog_create_kill_dialog (ProcData *data, int signal);
+void                    procdialog_create_renice_dialog (ProcData *data);
+gboolean                procdialog_create_root_password_dialog (ProcmanActionType type,
+                                                                ProcData *procdata,
+                                                                gint pid, gint extra_value);
+void                    procdialog_create_memmaps_dialog (ProcData *data);
+void                    procdialog_create_preferences_dialog (ProcData *data);
+
+#endif
+
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/13.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/13.html new file mode 100644 index 00000000..07b0403f --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/13.html @@ -0,0 +1,255 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
1
+2
+3
+4
+5
+6
+7
+8
+9
#ifndef _PROCMAN_MEMMAPS_H_
+#define _PROCMAN_MEMMAPS_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+void            create_memmaps_dialog (ProcData *procdata);
+
+#endif /* _PROCMAN_MEMMAPS_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/14.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/14.html new file mode 100644 index 00000000..b5c26f21 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/14.html @@ -0,0 +1,257 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
#ifndef _OPENFILES_H_
+#define _OPENFILES_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+void            create_openfiles_dialog (ProcData *procdata);
+
+#endif
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/15.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/15.html new file mode 100644 index 00000000..119b30ea --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/15.html @@ -0,0 +1,299 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
/* Process properties dialog
+ * Copyright (C) 2010 Krishnan Parthasarathi <krishnan.parthasarathi@gmail.com>
+ *                    Robert Ancell <robert.ancell@canonical.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef _PROCPROPERTIES_H_
+#define _PROCPROPERTIES_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+void create_procproperties_dialog (ProcData *procdata);
+
+#endif
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/16.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/16.html new file mode 100644 index 00000000..553dbda6 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/16.html @@ -0,0 +1,489 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
#ifndef _PROCMAN_LOAD_GRAPH_H_
+#define _PROCMAN_LOAD_GRAPH_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+enum
+{
+    LOAD_GRAPH_CPU,
+    LOAD_GRAPH_MEM,
+    LOAD_GRAPH_NET
+};
+
+enum {
+    CPU_TOTAL,
+    CPU_USED,
+    N_CPU_STATES
+};
+
+struct LoadGraphLabels
+{
+    GtkWidget *cpu[GLIBTOP_NCPU];
+    GtkWidget *memory;
+    GtkWidget *swap;
+    GtkWidget *net_in;
+    GtkWidget *net_in_total;
+    GtkWidget *net_out;
+    GtkWidget *net_out_total;
+};
+
+struct LoadGraph {
+
+    static const unsigned NUM_POINTS = 60 + 2;
+    static const unsigned GRAPH_MIN_HEIGHT = 40;
+
+    LoadGraph(guint type);
+    ~LoadGraph();
+
+    unsigned num_bars() const;
+    void clear_background();
+
+    double fontsize;
+    double rmargin;
+    double indent;
+
+    guint n;
+    gint type;
+    guint speed;
+    guint draw_width, draw_height;
+    guint render_counter;
+    guint frames_per_unit;
+    guint graph_dely;
+    guint real_draw_height;
+    double graph_delx;
+    guint graph_buffer_offset;
+
+    std::vector<GdkRGBA> colors;
+
+    std::vector<float> data_block;
+    gfloat* data[NUM_POINTS];
+
+    GtkWidget *main_widget;
+    GtkWidget *disp;
+
+    cairo_pattern_t *background;
+
+    guint timer_index;
+
+    gboolean draw;
+
+    LoadGraphLabels labels;
+    GtkWidget *mem_color_picker;
+    GtkWidget *swap_color_picker;
+
+    /* union { */
+        struct {
+            guint now; /* 0 -> current, 1 -> last
+                    now ^ 1 each time */
+            /* times[now], times[now ^ 1] is last */
+            guint64 times[2][GLIBTOP_NCPU][N_CPU_STATES];
+        } cpu;
+
+        struct {
+            guint64 last_in, last_out;
+#if GLIB_CHECK_VERSION(2,61,2)
+            gint64 time;
+#else
+            GTimeVal time;
+#endif
+            guint64 max;
+            unsigned values[NUM_POINTS];
+            size_t cur;
+        } net;
+    /* }; */
+};
+
+/* Force a drawing update */
+void
+load_graph_queue_draw (LoadGraph *g);
+
+/* Start load graph. */
+void
+load_graph_start (LoadGraph *g);
+
+/* Stop load graph. */
+void
+load_graph_stop (LoadGraph *g);
+
+/* Change load graph speed and restart it if it has been previously started */
+void
+load_graph_change_speed (LoadGraph *g,
+                         guint new_speed);
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+#endif /* _PROCMAN_LOAD_GRAPH_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/17.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/17.html new file mode 100644 index 00000000..40d7d2b5 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/17.html @@ -0,0 +1,255 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
1
+2
+3
+4
+5
+6
+7
+8
+9
#ifndef H_PROCMAN_LSOF_1161179202
+#define H_PROCMAN_LSOF_1161179202
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+void procman_lsof(ProcData *data);
+
+#endif /* H_PROCMAN_LSOF_1161179202 */
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/18.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/18.html new file mode 100644 index 00000000..6cfdc63e --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/18.html @@ -0,0 +1,645 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <cstring><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "cgroups.h"
+#include "util.h"
+
+gboolean
+cgroups_enabled(void)
+{
+    static gboolean initialized = FALSE;
+    static gboolean has_cgroups;
+
+    if (!initialized) {
+        initialized = TRUE;
+        has_cgroups = g_file_test("/proc/cgroups", G_FILE_TEST_EXISTS);
+    }
+
+    return has_cgroups;
+}
+
+static void
+append_cgroup_name(char *line, gchar **current_cgroup_name)
+{
+    gchar *controller, *path, *tmp, *path_plus_space;
+    int paren_offset, off, tmp_size;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return;
+
+    *(path - 1) = '\0';
+    g_strdelimit(controller, ",", '/');
+
+    if ((std::strcmp(path, "/") == 0) || (std::strncmp(controller, "name=", 5) == 0))
+        return;
+
+    if (*current_cgroup_name == NULL) {
+        *current_cgroup_name = g_strdup_printf("%s (%s)", path, controller);
+        return;
+    }
+
+    /* add a space to the end of the path string */
+    path_plus_space = g_strdup_printf("%s ", path);
+
+    if ((tmp = g_strstr_len(*current_cgroup_name, -1, path_plus_space))) {
+        tmp_size = strlen(*current_cgroup_name) + strlen(controller) + 1;
+        paren_offset = g_strstr_len(tmp + strlen(path), -1, ")") - *current_cgroup_name;
+        *(*current_cgroup_name + paren_offset) = '\0';
+        tmp = (gchar *)g_strnfill(tmp_size, '\0');
+        off = g_strlcat(tmp, *current_cgroup_name, tmp_size);
+        *(tmp + off) = '/';
+        off++;
+        off += g_strlcat(tmp + off, controller, tmp_size);
+        *(tmp + off) = ')';
+        off++;
+        g_strlcat(tmp + off, *current_cgroup_name + paren_offset + 1, tmp_size);
+    } else
+        tmp = g_strdup_printf("%s, %s(%s)", *current_cgroup_name, path_plus_space, controller);
+
+    g_free(path_plus_space);
+    g_free(*current_cgroup_name);
+    *current_cgroup_name = tmp;
+}
+
+static int
+check_cgroup_changed(gchar *line, gchar *current_cgroup_set)
+{
+    /* check if line is contained in current_cgroup_set */
+    gchar *controller, *path, *tmp, *found, *close_paren, *open_paren;
+    int ret = 0;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return 1;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return 1;
+
+    *(path - 1) = '\0';
+
+    if (std::strncmp(controller, "name=", 5) == 0)
+        goto out;
+
+    /* if there are multiple controllers just report string has changed */
+    if (g_strstr_len(controller, -1, ",")) {
+        ret = 1;
+        goto out;
+    }
+
+    if (!current_cgroup_set) {
+        if (std::strcmp(path, "/") != 0)
+            ret = 1;
+        goto out;
+    }
+
+    /* special case for root cgroup */
+    tmp = current_cgroup_set;
+    if (std::strcmp(path, "/") == 0) {
+        while ((found = g_strstr_len(tmp, -1, controller))) {
+            close_paren = g_strstr_len(found, -1, ")");
+            open_paren = g_strstr_len(found, -1, "(");
+            if (close_paren) {
+                if (!open_paren || (close_paren < open_paren)) {
+                    ret = 1;
+                    goto out;
+                }
+            }
+            tmp = found + strlen(controller);
+        }
+        goto out;
+    }
+
+    tmp = current_cgroup_set;
+    while ((found = g_strstr_len(tmp, -1, path))) {
+            found = found + strlen(path);
+            close_paren = g_strstr_len(found, -1, ")");
+            if (*found == ' ') {
+                if (g_strstr_len(found + 1, close_paren - found, controller))
+                    goto out;
+            }
+            tmp = close_paren + 1;
+    }
+    ret = 1;
+out:
+    *(path - 1) = ':';
+    return ret;
+}
+
+void
+get_process_cgroup_info(ProcInfo *info)
+{
+    gchar *path;
+    gchar *cgroup_name = NULL;
+    int cgroups_changed = 0;
+    gchar *text;
+    char **lines;
+    int i;
+
+    if (!cgroups_enabled())
+        return;
+
+    /* read out of /proc/pid/cgroup */
+    path = g_strdup_printf("/proc/%d/cgroup", info->pid);
+    if (!path)
+        return;
+    if(!g_file_get_contents(path, &text, NULL, NULL))
+        goto out;
+    lines = g_strsplit(text, "\n", -1);
+    g_free(text);
+    if (!lines)
+        goto out;
+
+    for (i = 0; lines[i] != NULL; i++) {
+        if (lines[i][0] == '\0')
+            continue;
+        if (check_cgroup_changed(lines[i], info->cgroup_name)) {
+            cgroups_changed = 1;
+            break;
+        }
+    }
+
+    if (cgroups_changed) {
+        for (i = 0; lines[i] != NULL; i++) {
+            if (lines[i][0] == '\0')
+                continue;
+            append_cgroup_name(lines[i], &cgroup_name);
+        }
+        if (info->cgroup_name)
+            g_free(info->cgroup_name);
+        if (!cgroup_name)
+            info->cgroup_name = g_strdup("");
+        else
+            info->cgroup_name = cgroup_name;
+    }
+
+    g_strfreev(lines);
+out:
+    g_free(path);
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/19.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/19.html new file mode 100644 index 00000000..f9dfbcbd --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/19.html @@ -0,0 +1,261 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
#ifndef PROCMAN_CGROUP_H_20111103
+#define PROCMAN_CGROUP_H_20111103
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+void get_process_cgroup_info (ProcInfo *info);
+
+gboolean cgroups_enabled (void);
+
+#endif /* PROCMAN_CGROUP_H_20111103 */
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/2.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/2.html new file mode 100644 index 00000000..ddc7b909 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/2.html @@ -0,0 +1,1289 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
/* Procman - callbacks
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <giomm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "callbacks.h"
+#include "interface.h"
+#include "proctable.h"
+#include "util.h"
+#include "procactions.h"
+#include "procman.h"
+#include "procdialogs.h"
+#include "memmaps.h"
+#include "openfiles.h"
+#include "procproperties.h"
+#include "load-graph.h"
+#include "disks.h"
+#include "lsof.h"
+#include "sysinfo.h"
+
+void
+cb_kill_sigstop(GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    /* no confirmation */
+    kill_process (procdata, SIGSTOP);
+}
+
+
+
+
+void
+cb_kill_sigcont(GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    /* no confirmation */
+    kill_process (procdata, SIGCONT);
+}
+
+
+
+
+static void
+kill_process_helper(ProcData *procdata, int sig)
+{
+    if (procdata->config.show_kill_warning)
+        procdialog_create_kill_dialog (procdata, sig);
+    else
+        kill_process (procdata, sig);
+}
+
+
+void
+cb_edit_preferences (GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdialog_create_preferences_dialog (procdata);
+}
+
+
+void
+cb_renice (GtkAction *action, GtkRadioAction *current, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    gint selected = gtk_radio_action_get_current_value(current);
+
+    if (selected == CUSTOM_PRIORITY)
+    {
+       procdialog_create_renice_dialog (procdata);
+    } else {
+       gint new_nice_value = 0;
+       switch (selected) {
+           case VERY_HIGH_PRIORITY: new_nice_value = -20; break;
+           case HIGH_PRIORITY: new_nice_value = -5; break;
+           case NORMAL_PRIORITY: new_nice_value = 0; break;
+           case LOW_PRIORITY: new_nice_value = 5; break;
+           case VERY_LOW_PRIORITY: new_nice_value = 19; break;
+       }
+       renice(procdata, new_nice_value);
+    }
+}
+
+
+void
+cb_end_process (GtkAction *action, gpointer data)
+{
+    kill_process_helper(static_cast<ProcData*>(data), SIGTERM);
+}
+
+
+void
+cb_kill_process (GtkAction *action, gpointer data)
+{
+    kill_process_helper(static_cast<ProcData*>(data), SIGKILL);
+}
+
+
+void
+cb_show_memory_maps (GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    create_memmaps_dialog (procdata);
+}
+
+void
+cb_show_open_files (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    create_openfiles_dialog (procdata);
+}
+
+void
+cb_show_process_properties (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    create_procproperties_dialog (procdata);
+}
+
+void
+cb_show_lsof(GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    procman_lsof(procdata);
+}
+
+
+void
+cb_about (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    const gchar * const authors[] = {
+        "Adam Erdman <hekel@archlinux.info>",
+        "Alexander Pyhalov <apyhalov@gmail.com>",
+        "Andreas Nilsson <nisses.mail@home.se>",
+        "Benoît Dejean <bdejean@gmail.com>",
+        "Chris Kühl <chrisk@openismus.com>",
+        "Clement Lefebvre <clement.lefebvre@linuxmint.com>",
+        "Elias Aebi <user142@hotmail.com>",
+        "Erik Johnsson",
+        "Jorgen Scheibengruber",
+        "Karl Lattimer",
+        "Kevin Vandersloot",
+        "Laurent Napias <tamplan@free.fr>",
+        "Marcel Dijkstra <marcel.dykstra@gmail.com>",
+        "Martin Wimpress <martin@mate-desktop.org>",
+        "Matias De lellis <mati86dl@gmail.com>",
+        "Mike Gabriel <mike.gabriel@das-netzwerkteam.de>",
+        "Nelson Marques <nmo.marques@gmail.com>",
+        "Obata Akio https://github.com/obache",
+        "Pablo Barciela <scow@riseup.net>",
+        "Paolo Borelli",
+        "Perberos <perberos@gmail.com>",
+        "Piotr DrÄ…g <piotrdrag@gmail.com>",
+        "Robert Buj <robert.buj@gmail.com>",
+        "Sander Sweers <infirit@gmail.com>",
+        "Scott Balneaves <sbalneav@alburg.net>",
+        "Soong Noonien https://github.com/SoongNoonien",
+        "Stefano Karapetsas <stefano@karapetsas.com>",
+        "Steve Zesch <stevezesch2@gmail.com>",
+        "Victor Kareh <vkareh@redhat.com>",
+        "Vlad Orlov <monsta@inbox.ru>",
+        "Wolfgang Ulbrich <mate@raveit.de>",
+        "Wu Xiaotian <yetist@gmail.com>",
+        "Yaakov Selkowitz <yselkowitz@users.sourceforge.net>",
+        "Youri Mouton <youri@NetBSD.org>",
+        NULL
+    };
+
+    const gchar * const documenters[] = {
+        "Bill Day",
+        "Sun Microsystems",
+        NULL
+    };
+
+    const gchar * const artists[] = {
+        "Baptiste Mille-Mathias",
+        NULL
+    };
+
+    const gchar * license[] = {
+        N_("System Monitor is free software; you can redistribute it and/or modify "
+        "it under the terms of the GNU General Public License as published by "
+        "the Free Software Foundation; either version 2 of the License, or "
+        "(at your option) any later version."),
+        N_("System Monitor is distributed in the hope that it will be useful, "
+        "but WITHOUT ANY WARRANTY; without even the implied warranty of "
+        "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the "
+        "GNU General Public License for more details."),
+        N_("You should have received a copy of the GNU General Public License "
+        "along with System Monitor; if not, write to the Free Software Foundation, Inc., "
+        "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA")
+    };
+
+    gchar *license_trans;
+    license_trans = g_strjoin ("\n\n", _(license[0]), _(license[1]), _(license[2]), NULL);
+
+    gtk_show_about_dialog (
+        GTK_WINDOW (procdata->app),
+        "program-name",       _("System Monitor"),
+        "version",            VERSION,
+        "title",              _("About System Monitor"),
+        "comments",           _("View current processes and monitor system state"),
+        "copyright",          _("Copyright \xc2\xa9 2001-2004 Kevin Vandersloot\n"
+                                "Copyright \xc2\xa9 2005-2007 Benoît Dejean\n"
+                                "Copyright \xc2\xa9 2011-2020 MATE developers"),
+        "logo-icon-name",     "utilities-system-monitor",
+        "authors",            authors,
+        "artists",            artists,
+        "documenters",        documenters,
+        "translator-credits", _("translator-credits"),
+        "license",            license_trans,
+        "wrap-license",       TRUE,
+        "website",            PACKAGE_URL,
+        NULL
+        );
+
+    g_free (license_trans);
+}
+
+
+void
+cb_help_contents (GtkAction *action, gpointer data)
+{
+    GError* error = 0;
+    if (!g_app_info_launch_default_for_uri("help:mate-system-monitor", NULL, &error)) {
+        g_warning("Could not display help : %s", error->message);
+        g_error_free(error);
+    }
+}
+
+
+void
+cb_app_exit (GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    cb_app_delete (NULL, NULL, procdata);
+    gtk_widget_destroy (procdata->app);
+}
+
+
+gboolean
+cb_app_delete (GtkWidget *window, GdkEventAny *event, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procman_save_config (procdata);
+    if (procdata->timeout)
+        g_source_remove (procdata->timeout);
+    if (procdata->disk_timeout)
+        g_source_remove (procdata->disk_timeout);
+
+    procdata->terminating = TRUE;
+
+    return FALSE;
+}
+
+
+
+void
+cb_end_process_button_pressed (GtkButton *button, gpointer data)
+{
+    kill_process_helper(static_cast<ProcData*>(data), SIGTERM);
+}
+
+
+static void change_settings_color(GSettings *settings, const char *key,
+                   GSMColorButton *cp)
+{
+    GdkRGBA c;
+    char *color;
+
+    gsm_color_button_get_color(cp, &c);
+    color = gdk_rgba_to_string (&c);
+    g_settings_set_string (settings, key, color);
+    g_free (color);
+}
+
+
+void
+cb_cpu_color_changed (GSMColorButton *cp, gpointer data)
+{
+    char key[80];
+    gint i = GPOINTER_TO_INT (data);
+    GSettings *settings = g_settings_new (GSM_GSETTINGS_SCHEMA);
+
+    g_snprintf(key, sizeof key, "cpu-color%d", i);
+
+    change_settings_color(settings, key, cp);
+}
+
+void
+cb_mem_color_changed (GSMColorButton *cp, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    change_settings_color(procdata->settings, "mem-color", cp);
+}
+
+
+void
+cb_swap_color_changed (GSMColorButton *cp, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    change_settings_color(procdata->settings, "swap-color", cp);
+}
+
+void
+cb_net_in_color_changed (GSMColorButton *cp, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    change_settings_color(procdata->settings, "net-in-color", cp);
+}
+
+void
+cb_net_out_color_changed (GSMColorButton *cp, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    change_settings_color(procdata->settings, "net-out-color", cp);
+}
+
+void
+cb_row_selected (GtkTreeSelection *selection, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->selection = selection;
+
+    procdata->selected_process = NULL;
+
+    /* get the most recent selected process and determine if there are
+    ** no selected processes
+    */
+    gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                         &procdata->selected_process);
+    if (procdata->selected_process) {
+        gint value;
+        gint nice = procdata->selected_process->nice;
+        if (nice < -7)
+            value = VERY_HIGH_PRIORITY;
+        else if (nice < -2)
+            value = HIGH_PRIORITY;
+        else if (nice < 3)
+            value = NORMAL_PRIORITY;
+        else if (nice < 7)
+            value = LOW_PRIORITY;
+        else
+            value = VERY_LOW_PRIORITY;
+
+        GtkRadioAction* normal = GTK_RADIO_ACTION(gtk_action_group_get_action(procdata->action_group, "Normal"));
+        block_priority_changed_handlers(procdata, TRUE);
+        gtk_radio_action_set_current_value(normal, value);
+        block_priority_changed_handlers(procdata, FALSE);
+
+    }
+    update_sensitivity(procdata);
+}
+
+
+gboolean
+cb_tree_button_pressed (GtkWidget *widget,
+            GdkEventButton *event,
+            gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
+        do_popup_menu (procdata, event);
+
+    return FALSE;
+}
+
+
+gboolean
+cb_tree_popup_menu (GtkWidget *widget, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    do_popup_menu (procdata, NULL);
+
+    return TRUE;
+}
+
+
+void
+cb_switch_page (GtkNotebook *nb, GtkWidget *page,
+        gint num, gpointer data)
+{
+    cb_change_current_page (nb, num, data);
+}
+
+void
+cb_change_current_page (GtkNotebook *nb, gint num, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->config.current_tab = num;
+
+
+    if (num == PROCMAN_TAB_PROCESSES) {
+
+        cb_timeout (procdata);
+
+        if (!procdata->timeout)
+            procdata->timeout = g_timeout_add (
+                procdata->config.update_interval,
+                cb_timeout, procdata);
+
+        update_sensitivity(procdata);
+    }
+    else {
+        if (procdata->timeout) {
+            g_source_remove (procdata->timeout);
+            procdata->timeout = 0;
+        }
+
+        update_sensitivity(procdata);
+    }
+
+
+    if (num == PROCMAN_TAB_RESOURCES) {
+        load_graph_start (procdata->cpu_graph);
+        load_graph_start (procdata->mem_graph);
+        load_graph_start (procdata->net_graph);
+    }
+    else {
+        load_graph_stop (procdata->cpu_graph);
+        load_graph_stop (procdata->mem_graph);
+        load_graph_stop (procdata->net_graph);
+    }
+
+
+    if (num == PROCMAN_TAB_DISKS) {
+
+        cb_update_disks (procdata);
+
+        if(!procdata->disk_timeout) {
+            procdata->disk_timeout =
+                g_timeout_add (procdata->config.disks_update_interval,
+                           cb_update_disks,
+                           procdata);
+        }
+    }
+    else {
+        if(procdata->disk_timeout) {
+            g_source_remove (procdata->disk_timeout);
+            procdata->disk_timeout = 0;
+        }
+    }
+
+    if (num == PROCMAN_TAB_SYSINFO) {
+        procman::build_sysinfo_ui();
+    }
+}
+
+
+
+gint
+cb_user_refresh (GtkAction*, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    proctable_update (procdata);
+    return FALSE;
+}
+
+
+gint
+cb_timeout (gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    guint new_interval;
+
+    if (!procdata->terminating) {
+        proctable_update (procdata);
+
+        if (procdata->smooth_refresh->get(new_interval))
+        {
+            procdata->timeout = g_timeout_add(new_interval,
+                                              cb_timeout,
+                                              procdata);
+            return FALSE;
+        }
+    }
+    return TRUE;
+}
+
+
+void
+cb_radio_processes(GtkAction *action, GtkRadioAction *current, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->config.whose_process = gtk_radio_action_get_current_value(current);
+
+    g_settings_set_int (procdata->settings, "view-as",
+                  procdata->config.whose_process);
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/20.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/20.html new file mode 100644 index 00000000..14abdda6 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/20.html @@ -0,0 +1,1277 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __linux__
+#include <mntent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif // __linux__
+
+#include <giomm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/themedicon.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mountlist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/fsusage.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "disks.h"
+#include "util.h"
+#include "interface.h"
+#include "iconthemewrapper.h"
+
+namespace
+{
+  const unsigned DISK_ICON_SIZE = 24;
+}
+
+enum DiskColumns
+{
+    /* string columns* */
+    DISK_DEVICE,
+    DISK_DIR,
+    DISK_TYPE,
+    DISK_SUBVOLUME,
+    DISK_TOTAL,
+    DISK_FREE,
+    DISK_AVAIL,
+    /* USED has to be the last column */
+    DISK_USED,
+    // then unvisible columns
+    /* Surface column */
+    DISK_ICON,
+    /* numeric columns */
+    DISK_USED_PERCENTAGE,
+    DISK_N_COLUMNS
+};
+
+
+
+static void
+fsusage_stats(const glibtop_fsusage *buf,
+              guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
+              gint *percentage)
+{
+    guint64 total = buf->blocks * buf->block_size;
+
+    if (!total) {
+        /* not a real device */
+        *btotal = *bfree = *bavail = *bused = 0ULL;
+        *percentage = 0;
+    } else {
+        int percent;
+        *btotal = total;
+        *bfree = buf->bfree * buf->block_size;
+        *bavail = buf->bavail * buf->block_size;
+        *bused = *btotal - *bfree;
+        /* percent = 100.0f * *bused / *btotal; */
+        percent = 100 * *bused / (*bused + *bavail);
+        *percentage = CLAMP(percent, 0, 100);
+    }
+}
+
+
+namespace
+{
+    string get_icon_for_path(const std::string& path)
+    {
+        using namespace Glib;
+        using namespace Gio;
+
+        // FIXME: I don't know whether i should use Volume or Mount or UnixMount
+        // all i need an icon name.
+        RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+        std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
+
+        for (size_t i = 0; i != mounts.size(); ++i) {
+            if (mounts[i]->get_name() != path)
+                continue;
+
+            RefPtr<Icon> icon = mounts[i]->get_icon();
+            RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
+
+            if (themed_icon) {
+                char* name = 0;
+                // FIXME: not wrapped yet
+                g_object_get(G_OBJECT(themed_icon->gobj()), "name", &name, NULL);
+                return make_string(name);
+            }
+        }
+
+        return "";
+    }
+}
+
+
+static Glib::RefPtr<Gdk::Pixbuf>
+get_icon_for_device(const char *mountpoint)
+{
+    procman::IconThemeWrapper icon_theme;
+    string icon_name = get_icon_for_path(mountpoint);
+    if (icon_name == "")
+        // FIXME: defaults to a safe value
+        icon_name = "drive-harddisk"; // get_icon_for_path("/");
+    return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
+}
+
+
+static gboolean
+find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
+                   GtkTreeIter *result)
+{
+    GtkTreeIter iter;
+    gboolean found = FALSE;
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        do {
+            char *dir;
+
+            gtk_tree_model_get(model, &iter,
+                               DISK_DIR, &dir,
+                               -1);
+
+            if (dir && !strcmp(dir, mountpoint)) {
+                *result = iter;
+                found = TRUE;
+            }
+
+            g_free(dir);
+
+        } while (!found && gtk_tree_model_iter_next(model, &iter));
+    }
+
+    return found;
+}
+
+
+
+static void
+remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
+{
+    GtkTreeIter iter;
+
+    if (!gtk_tree_model_get_iter_first(model, &iter))
+        return;
+
+    while (true) {
+        char *dir;
+        guint i;
+        gboolean found = FALSE;
+
+        gtk_tree_model_get(model, &iter,
+                           DISK_DIR, &dir,
+                           -1);
+
+        for (i = 0; i != n; ++i) {
+            if (!strcmp(dir, entries[i].mountdir)) {
+                found = TRUE;
+                break;
+            }
+        }
+
+        g_free(dir);
+
+        if (!found) {
+            if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                break;
+            else
+                continue;
+        }
+
+        if (!gtk_tree_model_iter_next(model, &iter))
+            break;
+    }
+}
+
+#ifdef __linux__
+static char *
+get_mount_opt(const glibtop_mountentry *entry, const char* opt)
+{
+    char *opt_value = NULL;
+    const struct mntent *mnt;
+    FILE *fp;
+
+    if (!(fp = setmntent(MOUNTED, "r"))) {
+        goto out;
+    }
+
+    while ((mnt = getmntent(fp))) {
+        if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
+            (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
+            char *res;
+
+            res = hasmntopt(mnt, "subvol");<--- res is assigned
+            if ((res = hasmntopt(mnt, "subvol")) != NULL) {<--- res is overwritten
+                char **strs = g_strsplit_set(res, "=", 2);
+
+                if (g_strv_length(strs) == 2) {
+                    char *value = strs[1];
+                    if (g_strcmp0 (value,"/root") == 0)
+                       opt_value = g_strdup("/");
+                    else
+                        opt_value = g_strdup(strs[1]);
+                    g_strfreev(strs);
+                }
+            }
+            break;
+        }
+    }
+
+    endmntent(fp);
+
+  out:
+     return opt_value;
+}
+#endif // __linux__
+
+
+static void
+add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
+{
+    Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+    cairo_surface_t *surface;
+    GtkTreeIter iter;
+    glibtop_fsusage usage;
+    guint64 bused, bfree, bavail, btotal;
+    gint percentage;
+#ifdef __linux__
+    char *subvol = NULL;
+#endif // __linux__
+
+    glibtop_get_fsusage(&usage, entry->mountdir);
+
+    if (not show_all_fs and usage.blocks == 0) {
+        if (find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+            gtk_list_store_remove(list, &iter);
+        return;
+    }
+
+    fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
+#ifdef __linux__
+    subvol = get_mount_opt(entry, "subvol");
+#endif // __linux__
+    pixbuf = get_icon_for_device(entry->mountdir);
+    surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL);
+
+    /* if we can find a row with the same mountpoint, we get it but we
+       still need to update all the fields.
+       This makes selection persistent.
+    */
+    if (!find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+        gtk_list_store_append(list, &iter);
+
+    gtk_list_store_set(list, &iter,
+                       DISK_ICON, surface,
+                       DISK_DEVICE, entry->devname,
+                       DISK_DIR, entry->mountdir,
+                       DISK_TYPE, entry->type,
+#ifdef __linux__
+
+                       DISK_SUBVOLUME, subvol != NULL ? subvol : "",
+#else
+                       DISK_SUBVOLUME, "",
+#endif // __linux__
+                       DISK_USED_PERCENTAGE, percentage,
+                       DISK_TOTAL, btotal,
+                       DISK_FREE, bfree,
+                       DISK_AVAIL, bavail,
+                       DISK_USED, bused,
+                       -1);
+#ifdef __linux__
+    g_free (subvol);
+#endif // __linux__
+}
+
+
+
+int
+cb_update_disks(gpointer data)
+{
+    ProcData *const procdata = static_cast<ProcData*>(data);
+
+    GtkListStore *list;
+    glibtop_mountentry * entries;
+    glibtop_mountlist mountlist;
+    guint i;
+
+    list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)));
+
+    entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
+
+    remove_old_disks(GTK_TREE_MODEL(list), entries, mountlist.number);
+
+    for (i = 0; i < mountlist.number; i++)
+        add_disk(list, &entries[i], procdata->config.show_all_fs);
+
+    g_free(entries);
+
+    return TRUE;
+}
+
+
+static void
+cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "disktreenew");
+}
+
+
+static void
+open_dir(GtkTreeView       *tree_view,
+         GtkTreePath       *path,
+         GtkTreeViewColumn *column,
+         gpointer           user_data)
+{
+    GtkTreeIter iter;
+    GtkTreeModel *model;
+    char *dir, *url;
+
+    model = gtk_tree_view_get_model(tree_view);
+
+    if (!gtk_tree_model_get_iter(model, &iter, path)) {
+        char *p;
+        p = gtk_tree_path_to_string(path);
+        g_warning("Cannot get iter for path '%s'\n", p);
+        g_free(p);
+        return;
+    }
+
+    gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
+
+    url = g_strdup_printf("file://%s", dir);
+
+    GError* error = 0;
+    if (!g_app_info_launch_default_for_uri(url, NULL, &error)) {
+        g_warning("Cannot open '%s' : %s\n", url, error->message);
+        g_error_free(error);
+    }
+
+    g_free(url);
+    g_free(dir);
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "disktreenew");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+void
+create_disk_view(ProcData *procdata, GtkBuilder *builder)
+{
+    GtkWidget *scrolled;
+    GtkWidget *disk_tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *col;
+    GtkCellRenderer *cell;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Device"),
+        N_("Directory"),
+        N_("Type"),
+        N_("SubVolume"),
+        N_("Total"),
+        N_("Free"),
+        N_("Available"),
+        N_("Used")
+    };
+
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"));
+
+    model = gtk_list_store_new(DISK_N_COLUMNS,             /* n columns */
+                               G_TYPE_STRING,              /* DISK_DEVICE */
+                               G_TYPE_STRING,              /* DISK_DIR */
+                               G_TYPE_STRING,              /* DISK_TYPE */
+                               G_TYPE_STRING,              /* DISK_SUBVOLUME */
+                               G_TYPE_UINT64,              /* DISK_TOTAL */
+                               G_TYPE_UINT64,              /* DISK_FREE */
+                               G_TYPE_UINT64,              /* DISK_AVAIL */
+                               G_TYPE_UINT64,              /* DISK_USED */
+                               CAIRO_GOBJECT_TYPE_SURFACE, /* DISK_ICON */
+                               G_TYPE_INT);                /* DISK_USED_PERCENTAGE */
+
+    disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL);
+    procdata->disk_list = disk_tree;
+    gtk_container_add(GTK_CONTAINER(scrolled), disk_tree);
+    g_object_unref(G_OBJECT(model));
+
+    /* icon + device */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
+                                        NULL);
+
+    cell = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
+                                        NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 30);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* sizes - used */
+
+    for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_min_width (col, 30);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+        switch (i) {
+            case DISK_TOTAL:
+            case DISK_FREE:
+            case DISK_AVAIL:
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+        default:
+            gtk_tree_view_column_set_attributes(col, cell,
+                                                "text", i,
+                                                NULL);
+            break;
+        }
+    }
+
+    /* used + percentage */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_text_new();
+    g_object_set(cell, "xalign", 1.0f, NULL);
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_cell_data_func(col, cell,
+                                            &procman::storage_size_cell_data_func,
+                                            GUINT_TO_POINTER(DISK_USED),
+                                            NULL);
+
+    cell = gtk_cell_renderer_progress_new();
+    gtk_tree_view_column_pack_start(col, cell, TRUE);
+    gtk_tree_view_column_set_attributes(col, cell, "value",
+                                        DISK_USED_PERCENTAGE, NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_USED]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 150);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* numeric sort */
+
+    procman_get_tree_state(procdata->settings, disk_tree,
+                   "disktreenew");
+
+    g_signal_connect (G_OBJECT(disk_tree), "columns-changed",
+                      G_CALLBACK(cb_disk_columns_changed), procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/21.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/21.html new file mode 100644 index 00000000..36328855 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/21.html @@ -0,0 +1,2141 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
+852
+853
+854
+855
+856
+857
+858
+859
+860
+861
+862
+863
+864
+865
+866
+867
+868
+869
+870
+871
+872
+873
+874
+875
+876
+877
+878
+879
+880
+881
+882
+883
+884
+885
+886
+887
+888
+889
+890
+891
+892
+893
+894
+895
+896
+897
+898
+899
+900
+901
+902
+903
+904
+905
+906
+907
+908
+909
+910
+911
+912
+913
+914
+915
+916
+917
+918
+919
+920
+921
+922
+923
+924
+925
+926
+927
+928
+929
+930
+931
+932
+933
+934
+935
+936
+937
+938
+939
+940
+941
+942
+943
+944
+945
+946
/*
+ * Mate system monitor color pickers
+ * Copyright (C) 2007 Karl Lattimer <karl@qdh.org.uk>
+ * Copyright (C) 2012-2021 MATE Developers
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with the software; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkkeysyms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <cairo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <librsvg/rsvg.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm_color_button.h"
+
+typedef struct {
+    GtkWidget *cc_dialog;		/* Color chooser dialog */
+
+    gchar *title;            /* Title for the color selection window */
+
+    GdkRGBA color;
+
+    gdouble fraction;        /* Only used by GSMCP_TYPE_PIE */
+    guint type;
+    cairo_surface_t *image_buffer;
+    gdouble highlight;
+    gboolean button_down;
+    gboolean in_button;
+} GSMColorButtonPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GSMColorButton, gsm_color_button, GTK_TYPE_DRAWING_AREA)
+
+/* Properties */
+enum
+{
+    PROP_0,
+    PROP_PERCENTAGE,
+    PROP_TITLE,
+    PROP_COLOR,
+    PROP_TYPE
+};
+
+/* Signals */
+enum
+{
+    COLOR_SET,
+    LAST_SIGNAL
+};
+
+#define GSMCP_MIN_WIDTH 15
+#define GSMCP_MIN_HEIGHT 15
+
+static void gsm_color_button_finalize (GObject * object);
+static void gsm_color_button_set_property (GObject * object, guint param_id,
+                                           const GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_get_property (GObject * object, guint param_id,
+                                           GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_realize (GtkWidget * widget);
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width);
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height);
+static void gsm_color_button_size_allocate (GtkWidget * widget,
+                                            GtkAllocation * allocation);
+static void gsm_color_button_unrealize (GtkWidget * widget);
+static void gsm_color_button_state_changed (GtkWidget * widget,
+                                            GtkStateType previous_state);
+static void gsm_color_button_style_set (GtkWidget * widget,
+                                        GtkStyle * previous_style);
+static gint gsm_color_button_pressed (GtkWidget * widget,
+                                      GdkEventButton * event);
+static gint gsm_color_button_released (GtkWidget * widget,
+                                       GdkEventButton * event);
+static gboolean gsm_color_button_enter_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+static gboolean gsm_color_button_leave_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+/* source side drag signals */
+static void gsm_color_button_drag_begin (GtkWidget * widget,
+                                         GdkDragContext * context,
+                                         gpointer data);
+static void gsm_color_button_drag_data_get (GtkWidget * widget,
+                                            GdkDragContext * context,
+                                            GtkSelectionData * selection_data,
+                                            guint info, guint time,
+                                            GSMColorButton * color_button);
+
+/* target side drag signals */
+static void gsm_color_button_drag_data_received (GtkWidget * widget,
+                                                 GdkDragContext * context,
+                                                 gint x,
+                                                 gint y,
+                                                 GtkSelectionData *
+                                                 selection_data, guint info,
+                                                 guint32 time,
+                                                 GSMColorButton *
+                                                 color_button);
+
+static guint color_button_signals[LAST_SIGNAL] = { 0 };
+
+static const GtkTargetEntry drop_types[] = { {"application/x-color", 0, 0} };
+
+static void
+gsm_color_button_class_init (GSMColorButtonClass * klass)
+{
+    GObjectClass *gobject_class;
+    GtkWidgetClass *widget_class;
+
+    gobject_class = G_OBJECT_CLASS (klass);
+    widget_class = GTK_WIDGET_CLASS (klass);
+
+    gobject_class->get_property = gsm_color_button_get_property;
+    gobject_class->set_property = gsm_color_button_set_property;
+    gobject_class->finalize = gsm_color_button_finalize;
+    widget_class->state_changed = gsm_color_button_state_changed;
+    widget_class->get_preferred_width = gsm_color_button_get_preferred_width;
+    widget_class->get_preferred_height = gsm_color_button_get_preferred_height;
+    widget_class->size_allocate = gsm_color_button_size_allocate;
+    widget_class->realize = gsm_color_button_realize;
+    widget_class->unrealize = gsm_color_button_unrealize;
+    widget_class->style_set = gsm_color_button_style_set;
+    widget_class->button_release_event = gsm_color_button_released;
+    widget_class->button_press_event = gsm_color_button_pressed;<--- You might need to cast the function pointer here
+    widget_class->enter_notify_event = gsm_color_button_enter_notify;
+    widget_class->leave_notify_event = gsm_color_button_leave_notify;
+
+    klass->color_set = NULL;
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_PERCENTAGE,
+                                     g_param_spec_double ("fraction",
+                                                          _("Fraction"),
+                                     // TRANSLATORS: description of the pie color picker's (mem, swap) filled percentage property
+                                                          _("Percentage full for pie color pickers"),
+                                                          0, 1, 0.5,
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TITLE,
+                                     g_param_spec_string ("title",
+                                                          _("Title"),
+                                                          _("The title of the color selection dialog"),
+                                                          _("Pick a Color"),
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_COLOR,
+                                     g_param_spec_boxed ("color",
+                                                         _("Current Color"),
+                                                         _("The selected color"),
+                                                         GDK_TYPE_RGBA,
+                                                         G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TYPE,
+                                     g_param_spec_uint ("type", _("Type"),
+                                                        _("Type of color picker"),
+                                                        0, 4, 0,
+                                                        G_PARAM_READWRITE));
+
+    color_button_signals[COLOR_SET] = g_signal_new ("color_set",
+                                                    G_TYPE_FROM_CLASS
+                                                    (gobject_class),
+                                                    G_SIGNAL_RUN_FIRST,
+                                                    G_STRUCT_OFFSET
+                                                    (GSMColorButtonClass,
+                                                    color_set), NULL, NULL,
+                                                    g_cclosure_marshal_VOID__VOID,
+                                                    G_TYPE_NONE, 0);
+
+}
+
+static cairo_surface_t *
+fill_image_buffer_from_file (cairo_t *cr, const char *filePath)
+{
+    GError *error = NULL;
+    RsvgHandle *handle;
+    cairo_surface_t *tmp_surface;
+    cairo_t *tmp_cr;
+
+    handle = rsvg_handle_new_from_file (filePath, &error);
+
+    if (handle == NULL) {
+        g_warning("rsvg_handle_new_from_file(\"%s\") failed: %s",
+              filePath, (error ? error->message : "unknown error"));
+    if (error)
+          g_error_free(error);
+    return NULL;
+    }
+
+    tmp_surface = cairo_surface_create_similar (cairo_get_target (cr),
+                                                CAIRO_CONTENT_COLOR_ALPHA,
+                                                32, 32);
+    tmp_cr = cairo_create (tmp_surface);
+    rsvg_handle_render_cairo (handle, tmp_cr);
+    cairo_destroy (tmp_cr);
+    g_object_unref (handle);
+    return tmp_surface;
+}
+
+static void
+render (GtkWidget * widget)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GdkRGBA *color;
+    GdkRGBA tmp_color = priv->color;
+    color = &tmp_color;
+    cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
+    cairo_path_t *path = NULL;
+    gint width, height;
+    gdouble radius, arc_start, arc_end;
+    gdouble highlight_factor;
+
+    if (priv->highlight > 0) {
+        highlight_factor = 0.125 * priv->highlight;
+
+    if (color->red + highlight_factor > 1.0)
+        color->red = 1.0;
+    else
+        color->red = color->red + highlight_factor;
+
+    if (color->blue + highlight_factor > 1.0)
+        color->blue = 1.0;
+    else
+      color->blue = color->blue + highlight_factor;
+
+    if (color->green + highlight_factor > 1.0)
+        color->green = 1.0;
+    else
+        color->green = color->green + highlight_factor;
+    }
+    gdk_cairo_set_source_rgba (cr, color);
+
+    width = gdk_window_get_width(gtk_widget_get_window(widget));
+    height = gdk_window_get_height(gtk_widget_get_window(widget));
+
+    switch (priv->type)
+        {
+        case GSMCP_TYPE_CPU:
+            //gtk_widget_set_size_request (widget, GSMCP_MIN_WIDTH, GSMCP_MIN_HEIGHT);
+            cairo_paint (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1);
+            cairo_stroke (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.4);
+            cairo_rectangle (cr, 1.5, 1.5, width - 3, height - 3);
+            cairo_stroke (cr);
+            break;
+        case GSMCP_TYPE_PIE:
+            if (width < 32)        // 32px minimum size
+                gtk_widget_set_size_request (widget, 32, 32);
+            if (width < height)
+                radius = width / 2;
+            else
+                radius = height / 2;
+
+            arc_start = -G_PI_2 + 2 * G_PI * priv->fraction;
+            arc_end = -G_PI_2;
+
+            cairo_set_line_width (cr, 1);
+
+            // Draw external stroke and fill
+            if (priv->fraction < 0.01) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_end);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    arc_end, arc_start);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_start);
+            }
+            cairo_fill_preserve (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.7);
+            cairo_stroke (cr);
+
+            // Draw internal highlight
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.45);
+            cairo_set_line_width (cr, 1);
+
+            if (priv->fraction < 0.03) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_end - (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    arc_end - (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+            }
+            cairo_stroke (cr);
+
+            // Draw external shape
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.2);
+            cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 1.25, 0,
+                G_PI * 2);
+            cairo_stroke (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_IN:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                    fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/download.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 8.5, 1.5);
+            cairo_line_to (cr, 23.5, 1.5);
+            cairo_line_to (cr, 23.5, 11.5);
+            cairo_line_to (cr, 29.5, 11.5);
+            cairo_line_to (cr, 16.5, 27.5);
+            cairo_line_to (cr, 15.5, 27.5);
+            cairo_line_to (cr, 2.5, 11.5);
+            cairo_line_to (cr, 8.5, 11.5);
+            cairo_line_to (cr, 8.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_OUT:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/upload.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 16.5, 1.5);
+            cairo_line_to (cr, 29.5, 17.5);
+            cairo_line_to (cr, 23.5, 17.5);
+            cairo_line_to (cr, 23.5, 27.5);
+            cairo_line_to (cr, 8.5, 27.5);
+            cairo_line_to (cr, 8.5, 17.5);
+            cairo_line_to (cr, 2.5, 17.5);
+            cairo_line_to (cr, 15.5, 1.5);
+            cairo_line_to (cr, 16.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        }
+    cairo_destroy (cr);
+}
+
+/* Handle exposure events for the color picker's drawing area */
+static gboolean draw (GtkWidget * widget, cairo_t * cr, gpointer data)
+{
+    render (GTK_WIDGET (data));
+
+    return FALSE;
+}
+
+static void
+gsm_color_button_realize (GtkWidget * widget)
+{
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->realize (widget);
+    render (widget);
+}
+
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width)
+{
+    g_return_if_fail (widget != NULL && minimum_width != NULL && natural_width != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_width = GSMCP_MIN_WIDTH;
+    *natural_width = GSMCP_MIN_WIDTH;
+}
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height)
+{
+    g_return_if_fail (widget != NULL && minimum_height != NULL && natural_height != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_height = GSMCP_MIN_HEIGHT;
+    *natural_height = GSMCP_MIN_HEIGHT;
+}
+
+static void
+gsm_color_button_size_allocate (GtkWidget * widget,
+                                GtkAllocation * allocation)
+{
+    g_return_if_fail (widget != NULL || allocation != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    gtk_widget_set_allocation (widget, allocation);
+
+    if (gtk_widget_get_realized (widget))
+    {
+        gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y,
+                                allocation->width, allocation->height);
+    }
+}
+
+static void
+gsm_color_button_unrealize (GtkWidget * widget)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->unrealize (widget);
+}
+
+static void
+gsm_color_button_style_set (GtkWidget * widget, GtkStyle * previous_style)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->style_set (widget,
+                                                                 previous_style);
+
+}
+
+static void
+gsm_color_button_state_changed (GtkWidget * widget,
+                                GtkStateType previous_state)
+{
+}
+
+static void
+gsm_color_button_drag_data_received (GtkWidget * widget,
+                                     GdkDragContext * context,
+                                     gint x,
+                                     gint y,
+                                     GtkSelectionData * selection_data,
+                                     guint info,
+                                     guint32 time,
+                                     GSMColorButton * color_button)
+{
+    gint length;
+    guint16 *dropped;
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    length = gtk_selection_data_get_length (selection_data);
+
+    if (length < 0)
+        return;
+
+    /* We accept drops with the wrong format, since the KDE color
+     * chooser incorrectly drops application/x-color with format 8.
+     */
+    if (length != 8)
+    {
+        g_warning (_("Received invalid color data\n"));
+        return;
+    }
+
+    dropped = (guint16 *) gtk_selection_data_get_data (selection_data);
+
+    priv->color.red =   ((double) dropped[0]) / 65535.0;
+    priv->color.green = ((double) dropped[1]) / 65535.0;
+    priv->color.blue =  ((double) dropped[2]) / 65535.0;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+    g_object_freeze_notify (G_OBJECT (color_button));
+    g_object_notify (G_OBJECT (color_button), "color");
+    g_object_thaw_notify (G_OBJECT (color_button));
+}
+
+static void
+set_color_icon (GdkDragContext * context, GdkRGBA * color)<--- Parameter 'color' can be declared as pointer to const
+{
+    GdkPixbuf *pixbuf;
+    guint32 pixel;
+
+    pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 48, 32);
+
+    pixel = ((guint32)(color->red * 0xff) << 24) |
+            ((guint32)(color->green * 0xff) << 16) |
+            ((guint32)(color->blue * 0xff) << 8);
+
+    gdk_pixbuf_fill (pixbuf, pixel);
+
+    gtk_drag_set_icon_pixbuf (context, pixbuf, -2, -2);
+    g_object_unref (pixbuf);
+}
+
+static void
+gsm_color_button_drag_begin (GtkWidget * widget,
+                             GdkDragContext * context, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = data;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    set_color_icon (context, &priv->color);
+}
+
+static void
+gsm_color_button_drag_data_get (GtkWidget * widget,
+                                GdkDragContext * context,
+                                GtkSelectionData * selection_data,
+                                guint info,
+                                guint time, GSMColorButton * color_button)
+{
+    guint16 dropped[4];
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    dropped[0] = (guint16) (65535.0 * priv->color.red);
+    dropped[1] = (guint16) (65535.0 * priv->color.green);
+    dropped[2] = (guint16) (65535.0 * priv->color.blue);
+    dropped[3] = 65535;        // This widget doesn't care about alpha
+
+    gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data),
+                            16, (guchar *) dropped, 8);
+}
+
+static void
+gsm_color_button_init (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = 0;
+    priv->color.green = 0;
+    priv->color.blue = 0;
+    priv->fraction = 0.5;
+    priv->type = GSMCP_TYPE_CPU;
+    priv->image_buffer = NULL;
+    priv->title = g_strdup (_("Pick a Color"));     /* default title */
+    priv->in_button = FALSE;
+    priv->button_down = FALSE;
+
+    gtk_drag_dest_set (GTK_WIDGET (color_button),
+                       GTK_DEST_DEFAULT_MOTION |
+                       GTK_DEST_DEFAULT_HIGHLIGHT |
+                       GTK_DEST_DEFAULT_DROP, drop_types, 1, GDK_ACTION_COPY);
+    gtk_drag_source_set (GTK_WIDGET (color_button),
+                         GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
+                         drop_types, 1, GDK_ACTION_COPY);
+    g_signal_connect (color_button, "drag_begin",
+                      G_CALLBACK (gsm_color_button_drag_begin), color_button);
+    g_signal_connect (color_button, "drag_data_received",
+                      G_CALLBACK (gsm_color_button_drag_data_received),
+                      color_button);
+    g_signal_connect (color_button, "drag_data_get",
+                      G_CALLBACK (gsm_color_button_drag_data_get),
+                      color_button);
+
+    gtk_widget_add_events (GTK_WIDGET(color_button), GDK_ENTER_NOTIFY_MASK
+                              | GDK_LEAVE_NOTIFY_MASK);
+
+    gtk_widget_set_tooltip_text (GTK_WIDGET(color_button), _("Click to set graph colors"));
+
+    g_signal_connect (color_button, "draw", G_CALLBACK (draw), color_button);
+}
+
+static void
+gsm_color_button_finalize (GObject * object)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    if (priv->cc_dialog != NULL)
+        gtk_widget_destroy (priv->cc_dialog);
+    priv->cc_dialog = NULL;
+
+    g_free (priv->title);
+    priv->title = NULL;
+
+    cairo_surface_destroy (priv->image_buffer);
+    priv->image_buffer = NULL;
+
+    G_OBJECT_CLASS (gsm_color_button_parent_class)->finalize (object);
+}
+
+GtkWidget *
+gsm_color_button_new (const GdkRGBA * color, guint type)
+{
+    return g_object_new (GSM_TYPE_COLOR_BUTTON, "color", color, "type", type,
+                         NULL);
+}
+
+static void
+dialog_response (GtkWidget * widget, GtkResponseType response, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GtkColorChooser *color_chooser;
+
+    if (response == GTK_RESPONSE_OK) {
+        color_chooser = GTK_COLOR_CHOOSER (priv->cc_dialog);
+
+        gtk_color_chooser_get_rgba (color_chooser, &priv->color);
+
+        gtk_widget_hide (priv->cc_dialog);
+
+        gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+        g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+        g_object_freeze_notify (G_OBJECT (color_button));
+        g_object_notify (G_OBJECT (color_button), "color");
+        g_object_thaw_notify (G_OBJECT (color_button));
+    }
+    else  /* (response == GTK_RESPONSE_CANCEL) */
+        gtk_widget_hide (priv->cc_dialog);
+}
+
+static gboolean
+dialog_destroy (GtkWidget * widget, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->cc_dialog = NULL;
+
+    return FALSE;
+}
+
+static gint
+gsm_color_button_clicked (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    /* if dialog already exists, make sure it's shown and raised */
+    if (!priv->cc_dialog)
+    {
+        /* Create the dialog and connects its buttons */
+        GtkWidget *cc_dialog;
+        GtkWidget *parent;
+
+        parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));
+        if (!gtk_widget_is_toplevel (parent))
+            parent = NULL;
+
+        cc_dialog = gtk_color_chooser_dialog_new (priv->title, GTK_WINDOW (parent));
+
+        gtk_window_set_modal (GTK_WINDOW (cc_dialog), TRUE);
+
+        g_signal_connect (cc_dialog, "response",
+                          G_CALLBACK (dialog_response), color_button);
+
+        g_signal_connect (cc_dialog, "destroy",
+                          G_CALLBACK (dialog_destroy), color_button);
+
+        priv->cc_dialog = cc_dialog;
+    }
+
+    gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (priv->cc_dialog),
+                                &priv->color);
+
+    gtk_window_present (GTK_WINDOW (priv->cc_dialog));
+
+    return 0;
+}
+
+static gint
+gsm_color_button_pressed (GtkWidget * widget, GdkEventButton * event)<--- Parameter 'event' can be declared as pointer to const
+{
+    if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) )
+    {
+	GSMColorButtonPrivate *priv;
+        GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+	priv = gsm_color_button_get_instance_private (color_button);
+	priv->button_down = TRUE;
+    }
+  return 0;
+}
+
+static gint
+gsm_color_button_released (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    if (priv->button_down && priv->in_button)
+        gsm_color_button_clicked (widget, event);
+    priv->button_down = FALSE;
+    return 0;
+}
+
+static gboolean
+gsm_color_button_enter_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 1.0;
+    priv->in_button = TRUE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+static gboolean
+gsm_color_button_leave_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 0;
+    priv->in_button = FALSE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+guint
+gsm_color_button_get_cbtype (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->type;
+}
+
+void
+gsm_color_button_set_cbtype (GSMColorButton * color_button, guint type)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->type = type;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "type");
+}
+
+gdouble
+gsm_color_button_get_fraction (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->fraction;
+}
+
+void
+gsm_color_button_set_fraction (GSMColorButton * color_button,
+                               gdouble fraction)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->fraction = fraction;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "fraction");
+}
+
+void
+gsm_color_button_get_color (GSMColorButton * color_button, GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    color->red = priv->color.red;
+    color->green = priv->color.green;
+    color->blue = priv->color.blue;
+    color->alpha = priv->color.alpha;
+}
+
+void
+gsm_color_button_set_color (GSMColorButton * color_button,
+                            const GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    g_return_if_fail (color != NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = color->red;
+    priv->color.green = color->green;
+    priv->color.blue = color->blue;
+    priv->color.alpha = color->alpha;
+
+    gtk_widget_queue_draw (GTK_WIDGET (color_button));
+
+    g_object_notify (G_OBJECT (color_button), "color");
+}
+
+void
+gsm_color_button_set_title (GSMColorButton * color_button,
+                            const gchar * title)
+{
+    gchar *old_title;
+    GSMColorButtonPrivate *priv;
+
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    old_title = priv->title;
+    priv->title = g_strdup (title);
+    g_free (old_title);
+
+    if (priv->cc_dialog)
+        gtk_window_set_title (GTK_WINDOW (priv->cc_dialog),
+                              priv->title);
+
+    g_object_notify (G_OBJECT (color_button), "title");
+}
+
+const gchar* gsm_color_button_get_title(GSMColorButton* color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail(GSM_IS_COLOR_BUTTON(color_button), NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->title;
+}
+
+static void
+gsm_color_button_set_property (GObject * object,
+                               guint param_id,
+                               const GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            gsm_color_button_set_fraction (color_button,
+                                           g_value_get_double (value));
+            break;
+        case PROP_TITLE:
+            gsm_color_button_set_title (color_button, g_value_get_string (value));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_set_color (color_button, g_value_get_boxed (value));
+            break;
+        case PROP_TYPE:
+            gsm_color_button_set_cbtype (color_button, g_value_get_uint (value));
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+static void
+gsm_color_button_get_property (GObject * object,
+                               guint param_id,
+                               GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+    GdkRGBA color;
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            g_value_set_double (value,
+                                gsm_color_button_get_fraction (color_button));
+            break;
+        case PROP_TITLE:
+            g_value_set_string (value, gsm_color_button_get_title (color_button));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_get_color (color_button, &color);
+                                        g_value_set_boxed (value, &color);
+            break;
+        case PROP_TYPE:
+            g_value_set_uint (value, gsm_color_button_get_cbtype (color_button));
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/22.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/22.html new file mode 100644 index 00000000..9c8cf9ea --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/22.html @@ -0,0 +1,351 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtkmm/icontheme.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/error.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "iconthemewrapper.h"
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
+{
+    gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
+    try
+    {
+      return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
+    }
+    catch (Gtk::IconThemeError &error)
+    {
+        if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
+            g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+    catch (Gio::Error &error)
+    {
+        g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+}
+
+Glib::RefPtr<Gdk::Pixbuf>
+procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
+                                      int size, Gtk::IconLookupFlags flags) const
+{
+    Gtk::IconInfo icon_info;
+    gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
+    icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
+
+    if (!icon_info) {
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+
+    try
+    {
+        return icon_info.load_icon();
+    }
+    catch (Gtk::IconThemeError &error)
+    {
+        if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
+            g_error("Cannot load gicon from theme: %s", error.what().c_str());
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+    catch (Gio::Error &error)
+    {
+        g_debug("Could not load gicon: %s", error.what().c_str());
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/23.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/23.html new file mode 100644 index 00000000..3f522db0 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/23.html @@ -0,0 +1,1599 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
/* Procman - main window
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkkeysyms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "callbacks.h"
+#include "interface.h"
+#include "proctable.h"
+#include "procactions.h"
+#include "load-graph.h"
+#include "util.h"
+#include "disks.h"
+#include "sysinfo.h"
+#include "gsm_color_button.h"
+
+static void    cb_toggle_tree (GtkAction *action, gpointer data);
+static void    cb_proc_goto_tab (gint tab);
+
+static const GtkActionEntry menu_entries[] =
+{
+    // xgettext: noun, top level menu.
+    // "File" did not make sense for system-monitor
+    { "Monitor", NULL, N_("_Monitor") },
+    { "Edit", NULL, N_("_Edit") },
+    { "View", NULL, N_("_View") },
+    { "Help", NULL, N_("_Help") },
+
+    { "Lsof", "edit-find", N_("Search for _Open Files"), "<control>O",
+      N_("Search for open files"), G_CALLBACK(cb_show_lsof) },
+    { "Quit", "application-exit", N_("_Quit"), "<control>Q",
+      N_("Quit the program"), G_CALLBACK (cb_app_exit) },
+
+
+    { "StopProcess", NULL, N_("_Stop Process"), "<control>S",
+      N_("Stop process"), G_CALLBACK(cb_kill_sigstop) },
+    { "ContProcess", NULL, N_("_Continue Process"), "<control>C",
+      N_("Continue process if stopped"), G_CALLBACK(cb_kill_sigcont) },
+
+    { "EndProcess", NULL, N_("_End Process"), "<control>E",
+      N_("Force process to finish normally"), G_CALLBACK (cb_end_process) },
+    { "KillProcess", NULL, N_("_Kill Process"), "<control>K",
+      N_("Force process to finish immediately"), G_CALLBACK (cb_kill_process) },
+    { "ChangePriority", NULL, N_("_Change Priority"), NULL,
+      N_("Change the order of priority of process"), NULL },
+    { "Preferences", "preferences-desktop", N_("_Preferences"), NULL,
+      N_("Configure the application"), G_CALLBACK (cb_edit_preferences) },
+
+    { "Refresh", "view-refresh", N_("_Refresh"), "<control>R",
+      N_("Refresh the process list"), G_CALLBACK(cb_user_refresh) },
+
+    { "MemoryMaps", NULL, N_("_Memory Maps"), "<control>M",
+      N_("Open the memory maps associated with a process"), G_CALLBACK (cb_show_memory_maps) },
+    // Translators: this means 'Files that are open' (open is no verb here
+    { "OpenFiles", NULL, N_("Open _Files"), "<control>F",
+      N_("View the files opened by a process"), G_CALLBACK (cb_show_open_files) },
+    { "ProcessProperties", NULL, N_("_Properties"), NULL,
+      N_("View additional information about a process"), G_CALLBACK (cb_show_process_properties) },
+
+
+    { "HelpContents", "help-browser", N_("_Contents"), "F1",
+      N_("Open the manual"), G_CALLBACK (cb_help_contents) },
+    { "About", "help-about", N_("_About"), NULL,
+      N_("About this application"), G_CALLBACK (cb_about) }
+};
+
+static const GtkToggleActionEntry toggle_menu_entries[] =
+{
+    { "ShowDependencies", NULL, N_("_Dependencies"), "<control>D",
+      N_("Show parent/child relationship between processes"),
+      G_CALLBACK (cb_toggle_tree), TRUE },
+};
+
+
+static const GtkRadioActionEntry radio_menu_entries[] =
+{
+  { "ShowActiveProcesses", NULL, N_("_Active Processes"), NULL,
+    N_("Show active processes"), ACTIVE_PROCESSES },
+  { "ShowAllProcesses", NULL, N_("A_ll Processes"), NULL,
+    N_("Show all processes"), ALL_PROCESSES },
+  { "ShowMyProcesses", NULL, N_("M_y Processes"), NULL,
+    N_("Show only user-owned processes"), MY_PROCESSES }
+};
+
+static const GtkRadioActionEntry priority_menu_entries[] =
+{
+    { "VeryHigh", NULL, N_("Very High"), NULL,
+      N_("Set process priority to very high"), VERY_HIGH_PRIORITY },
+    { "High", NULL, N_("High"), NULL,
+      N_("Set process priority to high"), HIGH_PRIORITY },
+    { "Normal", NULL, N_("Normal"), NULL,
+      N_("Set process priority to normal"), NORMAL_PRIORITY },
+    { "Low", NULL, N_("Low"), NULL,
+      N_("Set process priority to low"), LOW_PRIORITY },
+    { "VeryLow", NULL, N_("Very Low"), NULL,
+      N_("Set process priority to very low"), VERY_LOW_PRIORITY },
+    { "Custom", NULL, N_("Custom"), NULL,
+      N_("Set process priority manually"), CUSTOM_PRIORITY }
+};
+
+
+static const char ui_info[] =
+    "  <menubar name=\"MenuBar\">"
+    "    <menu name=\"MonitorMenu\" action=\"Monitor\">"
+    "      <menuitem name=\"MonitorLsofMenu\" action=\"Lsof\" />"
+    "      <menuitem name=\"MonitorQuitMenu\" action=\"Quit\" />"
+    "    </menu>"
+    "    <menu name=\"EditMenu\" action=\"Edit\">"
+    "      <menuitem name=\"EditStopProcessMenu\" action=\"StopProcess\" />"
+    "      <menuitem name=\"EditContProcessMenu\" action=\"ContProcess\" />"
+    "      <separator />"
+    "      <menuitem name=\"EditEndProcessMenu\" action=\"EndProcess\" />"
+    "      <menuitem name=\"EditKillProcessMenu\" action=\"KillProcess\" />"
+    "      <separator />"
+    "      <menu name=\"EditChangePriorityMenu\" action=\"ChangePriority\" >"
+    "        <menuitem action=\"VeryHigh\" />"
+    "        <menuitem action=\"High\" />"
+    "        <menuitem action=\"Normal\" />"
+    "        <menuitem action=\"Low\" />"
+    "        <menuitem action=\"VeryLow\" />"
+    "        <separator />"
+    "        <menuitem action=\"Custom\"/>"
+    "      </menu>"
+    "      <separator />"
+    "      <menuitem name=\"EditPreferencesMenu\" action=\"Preferences\" />"
+    "    </menu>"
+    "    <menu name=\"ViewMenu\" action=\"View\">"
+    "      <menuitem name=\"ViewActiveProcesses\" action=\"ShowActiveProcesses\" />"
+    "      <menuitem name=\"ViewAllProcesses\" action=\"ShowAllProcesses\" />"
+    "      <menuitem name=\"ViewMyProcesses\" action=\"ShowMyProcesses\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewDependenciesMenu\" action=\"ShowDependencies\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewMemoryMapsMenu\" action=\"MemoryMaps\" />"
+    "      <menuitem name=\"ViewOpenFilesMenu\" action=\"OpenFiles\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewProcessPropertiesMenu\" action=\"ProcessProperties\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewRefresh\" action=\"Refresh\" />"
+    "    </menu>"
+    "    <menu name=\"HelpMenu\" action=\"Help\">"
+    "      <menuitem name=\"HelpContentsMenu\" action=\"HelpContents\" />"
+    "      <menuitem name=\"HelpAboutMenu\" action=\"About\" />"
+    "    </menu>"
+    "  </menubar>"
+    "  <popup name=\"PopupMenu\" action=\"Popup\">"
+    "    <menuitem action=\"StopProcess\" />"
+    "    <menuitem action=\"ContProcess\" />"
+    "    <separator />"
+    "    <menuitem action=\"EndProcess\" />"
+    "    <menuitem action=\"KillProcess\" />"
+    "    <separator />"
+    "    <menu name=\"ChangePriorityMenu\" action=\"ChangePriority\" >"
+    "      <menuitem action=\"VeryHigh\" />"
+    "      <menuitem action=\"High\" />"
+    "      <menuitem action=\"Normal\" />"
+    "      <menuitem action=\"Low\" />"
+    "      <menuitem action=\"VeryLow\" />"
+    "      <separator />"
+    "      <menuitem action=\"Custom\"/>"
+    "    </menu>"
+    "    <separator />"
+    "    <menuitem action=\"MemoryMaps\" />"
+    "    <menuitem action=\"OpenFiles\" />"
+    "    <separator />"
+    "    <menuitem action=\"ProcessProperties\" />"
+
+    "  </popup>";
+
+
+static void
+create_proc_view(ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *proctree;
+    GtkWidget *scrolled;
+    char* string;
+
+    /* create the processes tab */
+    string = make_loadavg_string ();
+    procdata->loadavg = GTK_WIDGET (gtk_builder_get_object (builder, "load_avg_label"));
+    gtk_label_set_text (GTK_LABEL (procdata->loadavg), string);
+    g_free (string);
+
+    proctree = proctable_new (procdata);
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "processes_scrolled"));
+
+    gtk_container_add (GTK_CONTAINER (scrolled), proctree);
+
+    procdata->endprocessbutton = GTK_WIDGET (gtk_builder_get_object (builder, "endprocessbutton"));
+    g_signal_connect (G_OBJECT (procdata->endprocessbutton), "clicked",
+                      G_CALLBACK (cb_end_process_button_pressed), procdata);
+
+    /* create popup_menu for the processes tab */
+    procdata->popup_menu = gtk_ui_manager_get_widget (procdata->uimanager, "/PopupMenu");
+}
+
+
+GtkWidget *
+make_title_label (const char *text)
+{
+    GtkWidget *label;
+    char *full;
+
+    full = g_strdup_printf ("<span weight=\"bold\">%s</span>", text);
+    label = gtk_label_new (full);
+    g_free (full);
+
+    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+
+    return label;
+}
+
+
+static void
+create_sys_view (ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *cpu_graph_box, *mem_graph_box, *net_graph_box;
+    GtkWidget *label,*cpu_label;
+    GtkWidget *table;
+    GtkWidget *color_picker;
+    GtkWidget *picker_alignment;
+    LoadGraph *cpu_graph, *mem_graph, *net_graph;
+
+    gint i;
+    gchar *title_text;
+    gchar *label_text;
+    gchar *title_template;
+
+    // Translators: color picker title, %s is CPU, Memory, Swap, Receiving, Sending
+    title_template = g_strdup(_("Pick a Color for '%s'"));
+
+    /* The CPU BOX */
+
+    cpu_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_graph_box"));
+
+    cpu_graph = new LoadGraph(LOAD_GRAPH_CPU);
+    gtk_box_pack_start (GTK_BOX (cpu_graph_box),
+                        load_graph_get_widget(cpu_graph),
+                        TRUE,
+                        TRUE,
+                         0);
+
+    GtkWidget* flowbox = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_flow_box"));
+    gtk_box_reorder_child (GTK_BOX (cpu_graph_box), flowbox, 1);
+    for (i=0;i<procdata->config.num_cpus; i++) {
+        GtkWidget *temp_hbox;
+
+        temp_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
+        gtk_container_add (GTK_CONTAINER (flowbox), temp_hbox);
+
+        color_picker = gsm_color_button_new (&cpu_graph->colors.at(i), GSMCP_TYPE_CPU);
+        g_signal_connect (G_OBJECT (color_picker), "color_set",
+                          G_CALLBACK (cb_cpu_color_changed), GINT_TO_POINTER (i));
+        gtk_box_pack_start (GTK_BOX (temp_hbox), color_picker, FALSE, TRUE, 0);
+        gtk_widget_set_size_request(GTK_WIDGET(color_picker), 32, -1);
+        if(procdata->config.num_cpus == 1) {
+            label_text = g_strdup (_("CPU"));
+        } else {
+            label_text = g_strdup_printf (_("CPU%d"), i+1);
+        }
+        title_text = g_strdup_printf(title_template, label_text);
+        label = gtk_label_new (label_text);
+        gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+        g_free(title_text);
+        gtk_box_pack_start (GTK_BOX (temp_hbox), label, FALSE, FALSE, 6);
+        g_free (label_text);
+
+        cpu_label = gtk_label_new (NULL);
+        gtk_label_set_width_chars (GTK_LABEL (cpu_label), 7);
+        gtk_label_set_xalign (GTK_LABEL (cpu_label), 0.0);
+
+        gtk_box_pack_start (GTK_BOX (temp_hbox), cpu_label, TRUE, TRUE, 0);
+        load_graph_get_labels(cpu_graph)->cpu[i] = cpu_label;
+
+    }
+
+    procdata->cpu_graph = cpu_graph;
+
+    /** The memory box */
+    mem_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "mem_graph_box"));
+
+    mem_graph = new LoadGraph(LOAD_GRAPH_MEM);
+    gtk_box_pack_start (GTK_BOX (mem_graph_box),
+                        load_graph_get_widget(mem_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "mem_table"));
+
+    color_picker = load_graph_get_mem_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_mem_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Memory"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 0, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->memory;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 1, 1, 1, 1);
+
+    color_picker = load_graph_get_swap_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_swap_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Swap"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 2, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->swap;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 3, 1, 1, 1);
+
+    procdata->mem_graph = mem_graph;
+
+    /* The net box */
+    net_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "net_graph_box"));
+
+    net_graph = new LoadGraph(LOAD_GRAPH_NET);
+    gtk_box_pack_start (GTK_BOX (net_graph_box),
+                        load_graph_get_widget(net_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "net_table"));
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(0), GSMCP_TYPE_NETWORK_IN);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_in_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Receiving"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "receiving_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_in;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_in_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 1, 1, 1);
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(1), GSMCP_TYPE_NETWORK_OUT);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_out_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Sending"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "sending_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_out;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_out_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 1, 1, 1);
+
+    procdata->net_graph = net_graph;
+    g_free(title_template);
+}
+
+static void
+menu_item_select_cb (GtkMenuItem *proxy,
+                     ProcData *procdata)
+{
+    GtkAction *action;
+    char *message;
+
+    action = gtk_activatable_get_related_action (GTK_ACTIVATABLE(proxy));
+    g_assert(action);
+
+    g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
+    if (message)
+    {
+        gtk_statusbar_push (GTK_STATUSBAR (procdata->statusbar),
+                    procdata->tip_message_cid, message);
+        g_free (message);
+    }
+}
+
+static void
+menu_item_deselect_cb (GtkMenuItem *proxy,
+                       ProcData *procdata)
+{
+    gtk_statusbar_pop (GTK_STATUSBAR (procdata->statusbar),
+               procdata->tip_message_cid);
+}
+
+static void
+connect_proxy_cb (GtkUIManager *manager,
+                  GtkAction *action,
+                  GtkWidget *proxy,
+                  ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_connect (proxy, "select",
+                          G_CALLBACK (menu_item_select_cb), procdata);
+        g_signal_connect (proxy, "deselect",
+                          G_CALLBACK (menu_item_deselect_cb), procdata);
+    }
+}
+
+static void
+disconnect_proxy_cb (GtkUIManager *manager,
+                     GtkAction *action,
+                     GtkWidget *proxy,
+                     ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_select_cb)), procdata);
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_deselect_cb)), procdata);
+    }
+}
+
+void
+create_main_window (ProcData *procdata)
+{
+    gint i;
+    gint width, height, xpos, ypos;
+    GtkWidget *app;
+    GtkAction *action;
+    GtkWidget *menubar;
+    GtkWidget *main_box;
+    GtkWidget *notebook;
+    GtkBuilder *builder;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/interface.ui");
+
+    app = GTK_WIDGET (gtk_builder_get_object (builder, "main_window"));
+    main_box = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
+
+    GdkScreen* screen = gtk_widget_get_screen(app);
+    /* use visual, if available */
+    GdkVisual* visual = gdk_screen_get_rgba_visual(screen);
+    if (visual)
+        gtk_widget_set_visual(app, visual);
+
+    width = procdata->config.width;
+    height = procdata->config.height;
+    xpos = procdata->config.xpos;
+    ypos = procdata->config.ypos;
+    gtk_window_set_default_size (GTK_WINDOW (app), width, height);
+    gtk_window_move(GTK_WINDOW (app), xpos, ypos);
+
+    if (procdata->config.maximized) {
+        gtk_window_maximize(GTK_WINDOW(app));
+    }
+
+    /* create the menubar */
+    procdata->uimanager = gtk_ui_manager_new ();
+
+    /* show tooltips in the statusbar */
+    g_signal_connect (procdata->uimanager, "connect_proxy",
+                      G_CALLBACK (connect_proxy_cb), procdata);
+    g_signal_connect (procdata->uimanager, "disconnect_proxy",
+                      G_CALLBACK (disconnect_proxy_cb), procdata);
+
+    gtk_window_add_accel_group (GTK_WINDOW (app),
+                                gtk_ui_manager_get_accel_group (procdata->uimanager));
+
+    if (!gtk_ui_manager_add_ui_from_string (procdata->uimanager,
+                                            ui_info,
+                                            -1,
+                                            NULL)) {
+        g_error("building menus failed");
+    }
+
+    procdata->action_group = gtk_action_group_new ("ProcmanActions");
+    gtk_action_group_set_translation_domain (procdata->action_group, NULL);
+    gtk_action_group_add_actions (procdata->action_group,
+                                  menu_entries,
+                                  G_N_ELEMENTS (menu_entries),
+                                  procdata);
+    gtk_action_group_add_toggle_actions (procdata->action_group,
+                                         toggle_menu_entries,
+                                         G_N_ELEMENTS (toggle_menu_entries),
+                                         procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                        radio_menu_entries,
+                        G_N_ELEMENTS (radio_menu_entries),
+                        procdata->config.whose_process,
+                        G_CALLBACK(cb_radio_processes),
+                        procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                                        priority_menu_entries,
+                                        G_N_ELEMENTS (priority_menu_entries),
+                                        NORMAL_PRIORITY,
+                                        G_CALLBACK(cb_renice),
+                                        procdata);
+
+    gtk_ui_manager_insert_action_group (procdata->uimanager,
+                                        procdata->action_group,
+                                        0);
+
+    menubar = gtk_ui_manager_get_widget (procdata->uimanager, "/MenuBar");
+    gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0);
+    gtk_box_reorder_child (GTK_BOX (main_box), menubar, 0);
+
+    /* create the main notebook */
+    procdata->notebook = notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
+
+    create_proc_view(procdata, builder);
+    create_sys_view (procdata, builder);
+    create_disk_view (procdata, builder);
+
+    g_signal_connect (G_OBJECT (notebook), "switch-page",
+              G_CALLBACK (cb_switch_page), procdata);
+    g_signal_connect (G_OBJECT (notebook), "change-current-page",
+              G_CALLBACK (cb_change_current_page), procdata);
+
+    gtk_widget_show_all(notebook); // need to make page switch work
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab);
+    cb_change_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab, procdata);
+    g_signal_connect (G_OBJECT (app), "delete_event",
+                      G_CALLBACK (cb_app_delete),
+                      procdata);
+
+    GtkAccelGroup *accel_group;
+    GClosure *goto_tab_closure[4];
+    accel_group = gtk_accel_group_new ();
+    gtk_window_add_accel_group (GTK_WINDOW(app), accel_group);
+    for (i = 0; i < 4; ++i) {
+        goto_tab_closure[i] = g_cclosure_new_swap (G_CALLBACK (cb_proc_goto_tab),
+                                                   GINT_TO_POINTER (i), NULL);
+        gtk_accel_group_connect (accel_group, '0'+(i+1),
+                                 GDK_MOD1_MASK, GTK_ACCEL_VISIBLE,
+                                 goto_tab_closure[i]);
+    }
+
+    /* create the statusbar */
+    procdata->statusbar = GTK_WIDGET (gtk_builder_get_object (builder, "statusbar"));
+    procdata->tip_message_cid = gtk_statusbar_get_context_id
+        (GTK_STATUSBAR (procdata->statusbar), "tip_message");
+
+    action = gtk_action_group_get_action (procdata->action_group, "ShowDependencies");
+    gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+                      procdata->config.show_tree);
+
+    gtk_builder_connect_signals (builder, NULL);
+
+    gtk_widget_show_all(app);
+    procdata->app = app;
+
+    g_object_unref (G_OBJECT (builder));
+}
+
+void
+do_popup_menu (ProcData *procdata, GdkEventButton *event)
+{
+    gtk_menu_popup_at_pointer (GTK_MENU (procdata->popup_menu), NULL);
+}
+
+void
+update_sensitivity(ProcData *data)
+{
+    const char * const selected_actions[] = { "StopProcess",
+                                              "ContProcess",
+                                              "EndProcess",
+                                              "KillProcess",
+                                              "ChangePriority",
+                                              "MemoryMaps",
+                                              "OpenFiles",
+                                              "ProcessProperties" };
+
+    const char * const processes_actions[] = { "ShowActiveProcesses",
+                                               "ShowAllProcesses",
+                                               "ShowMyProcesses",
+                                               "ShowDependencies",
+                                               "Refresh"
+    };
+
+    size_t i;
+    gboolean processes_sensitivity, selected_sensitivity;
+    GtkAction *action;
+
+    processes_sensitivity = (data->config.current_tab == PROCMAN_TAB_PROCESSES);
+    selected_sensitivity = (processes_sensitivity && data->selection && gtk_tree_selection_count_selected_rows (data->selection) > 0);
+
+    if(data->endprocessbutton) {
+        /* avoid error on startup if endprocessbutton
+           has not been built yet */
+        gtk_widget_set_sensitive(data->endprocessbutton, selected_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(processes_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             processes_actions[i]);
+        gtk_action_set_sensitive(action, processes_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(selected_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             selected_actions[i]);
+        gtk_action_set_sensitive(action, selected_sensitivity);
+    }
+}
+
+void
+block_priority_changed_handlers(ProcData *data, bool block)
+{
+    gint i;
+    if (block) {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_block_by_func(action, (gpointer)cb_renice, data);
+        }
+    } else {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_unblock_by_func(action, (gpointer)cb_renice, data);
+        }
+    }
+}
+
+static void
+cb_toggle_tree (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GSettings *settings = procdata->settings;
+    gboolean show;
+
+    show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+    if (show == procdata->config.show_tree)
+        return;
+
+    g_settings_set_boolean (settings, "show-tree", show);
+}
+
+static void
+cb_proc_goto_tab (gint tab)
+{
+    ProcData *data = ProcData::get_instance ();
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (data->notebook), tab);
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/24.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/24.html new file mode 100644 index 00000000..382ee6f5 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/24.html @@ -0,0 +1,1939 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gdkmm/pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dirent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibtop.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/swap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/netload.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/netlist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <algorithm><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "load-graph.h"
+#include "util.h"
+#include "gsm_color_button.h"
+
+void LoadGraph::clear_background()
+{
+    if (background) {
+        cairo_pattern_destroy (background);
+        this->background = NULL;
+    }
+}
+
+
+unsigned LoadGraph::num_bars() const
+{
+    unsigned n;<--- Shadow variable
+
+    // keep 100 % num_bars == 0
+    switch (static_cast<int>(this->draw_height / (fontsize + 14)))
+    {
+    case 0:
+    case 1:
+        n = 1;
+        break;
+    case 2:
+    case 3:
+        n = 2;
+        break;
+    case 4:
+        n = 4;
+        break;
+    default:
+        n = 5;
+    }
+
+    return n;
+}
+
+
+
+#define FRAME_WIDTH 4
+static void draw_background(LoadGraph *graph) {
+    GtkAllocation allocation;
+    cairo_t *cr;
+    guint i;<--- Shadowed declaration
+    unsigned num_bars;
+    g_autofree gchar *caption;
+    PangoLayout* layout;
+    PangoFontDescription* font_desc;
+    PangoRectangle extents;
+    cairo_surface_t *surface;
+    GdkRGBA fg, bg;
+
+    num_bars = graph->num_bars();
+    graph->graph_dely = (graph->draw_height - 15) / num_bars; /* round to int to avoid AA blur */
+    graph->real_draw_height = graph->graph_dely * num_bars;
+    graph->graph_delx = (graph->draw_width - 2.0 - graph->rmargin - graph->indent) / (LoadGraph::NUM_POINTS - 3);
+    graph->graph_buffer_offset = (int) (1.5 * graph->graph_delx) + FRAME_WIDTH ;
+
+    gtk_widget_get_allocation (graph->disp, &allocation);
+    surface = gdk_window_create_similar_surface (gtk_widget_get_window (graph->disp), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height);
+    cr = cairo_create (surface);
+
+    GtkStyleContext *context = gtk_widget_get_style_context (ProcData::get_instance()->notebook);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get_background_color (context, gtk_style_context_get_state (context), &bg);
+    gtk_style_context_get_color (context, gtk_style_context_get_state (context), &fg);
+    gtk_style_context_restore (context);
+
+    // set the background color
+    gdk_cairo_set_source_rgba (cr, &bg);
+    cairo_paint (cr);
+
+    layout = pango_cairo_create_layout (cr);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get (context,
+                           gtk_style_context_get_state (context),
+                           GTK_STYLE_PROPERTY_FONT,
+                           &font_desc, NULL);
+    gtk_style_context_restore (context);
+    pango_font_description_set_size (font_desc, 0.8 * graph->fontsize * PANGO_SCALE);
+    pango_layout_set_font_description (layout, font_desc);
+    pango_font_description_free (font_desc);
+
+    /* draw frame */
+    cairo_translate (cr, FRAME_WIDTH, FRAME_WIDTH);
+
+    /* Draw background rectangle */
+    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+    cairo_rectangle (cr, graph->rmargin + graph->indent, 0,
+                     graph->draw_width - graph->rmargin - graph->indent, graph->real_draw_height);
+    cairo_fill(cr);
+
+    cairo_set_line_width (cr, 1.0);
+    cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    for (i = 0; i <= num_bars; ++i) {
+        double y;
+
+        if (i == 0)
+            y = 0.5 + graph->fontsize / 2.0;
+        else if (i == num_bars)
+            y = i * graph->graph_dely + 0.5;
+        else
+            y = i * graph->graph_dely + graph->fontsize / 2.0;
+
+        gdk_cairo_set_source_rgba (cr, &fg);
+        if (graph->type == LOAD_GRAPH_NET) {
+            // operation orders matters so it's 0 if i == num_bars
+            guint64 rate = graph->net.max - (i * graph->net.max / num_bars);
+            caption = g_format_size_full (network_in_bits ? rate*8 : rate, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        } else {
+            // operation orders matters so it's 0 if i == num_bars
+            caption = g_strdup_printf("%d%%", 100 - i * (100 / num_bars));
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        }
+
+        if (i==0 || i==num_bars)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, graph->rmargin + graph->indent - 3, i * graph->graph_dely + 0.5);
+        cairo_line_to (cr, graph->draw_width - 0.5, i * graph->graph_dely + 0.5);
+        cairo_stroke (cr);
+    }
+
+    const unsigned total_seconds = graph->speed * (LoadGraph::NUM_POINTS - 2) / 1000;
+
+    for (unsigned int i = 0; i < 7; i++) {<--- Shadow variable
+        double x = (i) * (graph->draw_width - graph->rmargin - graph->indent) / 6;
+        if (i==0 || i==6)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, 0.5);
+        cairo_line_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, graph->real_draw_height + 4.5);
+        cairo_stroke(cr);
+        unsigned seconds = total_seconds - i * total_seconds / 6;
+        const char* format;
+        if (i == 0)
+            format = dngettext(GETTEXT_PACKAGE, "%u second", "%u seconds", seconds);
+        else
+            format = "%u";
+        caption = g_strdup_printf(format, seconds);
+        pango_layout_set_text (layout, caption, -1);
+        pango_layout_get_extents (layout, NULL, &extents);
+        cairo_move_to (cr, ((ceil(x) + 0.5) + graph->rmargin + graph->indent) - (1.0 * extents.width / PANGO_SCALE/2), graph->draw_height - 1.0 * extents.height / PANGO_SCALE);
+        gdk_cairo_set_source_rgba (cr, &fg);
+        pango_cairo_show_layout (cr, layout);
+    }
+    g_object_unref(layout);
+    cairo_stroke (cr);
+    cairo_destroy (cr);
+    graph->background = cairo_pattern_create_for_surface (surface);
+    cairo_surface_destroy (surface);
+}
+
+/* Redraws the backing buffer for the load graph and updates the window */
+void
+load_graph_queue_draw (LoadGraph *graph)
+{
+    /* repaint */
+    gtk_widget_queue_draw (graph->disp);
+}
+
+static int load_graph_update (gpointer user_data); // predeclare load_graph_update so we can compile ;)
+
+static gboolean
+load_graph_configure (GtkWidget *widget,
+                      GdkEventConfigure *event,
+                      gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    gtk_widget_get_allocation (widget, &allocation);
+    graph->draw_width = allocation.width - 2 * FRAME_WIDTH;
+    graph->draw_height = allocation.height - 2 * FRAME_WIDTH;
+
+    graph->clear_background();
+
+    load_graph_queue_draw (graph);
+
+    return TRUE;
+}
+
+static gboolean load_graph_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+    GdkWindow *window;
+
+    guint i, j;
+    gdouble sample_width, x_offset;
+
+    window = gtk_widget_get_window (graph->disp);
+
+    /* Number of pixels wide for one graph point */
+    sample_width = (float)(graph->draw_width - graph->rmargin - graph->indent) / (float)LoadGraph::NUM_POINTS;
+    /* General offset */
+    x_offset = graph->draw_width - graph->rmargin + (sample_width*2);
+
+    /* Subframe offset */
+    x_offset += graph->rmargin - ((sample_width / graph->frames_per_unit) * graph->render_counter);
+
+    /* draw the graph */
+    cairo_t* cr;
+
+    cr = gdk_cairo_create (window);
+
+    if (graph->background == NULL) {
+        draw_background(graph);
+    }
+    cairo_set_source (cr, graph->background);
+    cairo_paint (cr);
+
+    cairo_set_line_width (cr, 1);
+    cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+    cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+    cairo_rectangle (cr, graph->rmargin + graph->indent + FRAME_WIDTH + 1, FRAME_WIDTH - 1,
+             graph->draw_width - graph->rmargin - graph->indent - 1, graph->real_draw_height + FRAME_WIDTH - 1);
+    cairo_clip(cr);
+
+    for (j = 0; j < graph->n; ++j) {
+        cairo_move_to (cr, x_offset, (1.0f - graph->data[0][j]) * graph->real_draw_height);
+        gdk_cairo_set_source_rgba (cr, &(graph->colors [j]));
+
+        for (i = 1; i < LoadGraph::NUM_POINTS; ++i) {
+            if (graph->data[i][j] == -1.0f)
+                continue;
+            cairo_curve_to (cr,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i-1][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - (i * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f);
+        }
+        cairo_stroke (cr);
+
+    }
+
+    cairo_destroy (cr);
+
+    return TRUE;
+}
+
+static void
+get_load (LoadGraph *graph)
+{
+    guint i;
+    glibtop_cpu cpu;
+
+    glibtop_get_cpu (&cpu);
+
+#undef NOW
+#undef LAST
+#define NOW  (graph->cpu.times[graph->cpu.now])
+#define LAST (graph->cpu.times[graph->cpu.now ^ 1])
+
+    if (graph->n == 1) {
+        NOW[0][CPU_TOTAL] = cpu.total;
+        NOW[0][CPU_USED] = cpu.user + cpu.nice + cpu.sys;
+    } else {
+        for (i = 0; i < graph->n; i++) {
+            NOW[i][CPU_TOTAL] = cpu.xcpu_total[i];
+            NOW[i][CPU_USED] = cpu.xcpu_user[i] + cpu.xcpu_nice[i]
+                + cpu.xcpu_sys[i];
+        }
+    }
+
+    // on the first call, LAST is 0
+    // which means data is set to the average load since boot
+    // that value has no meaning, we just want all the
+    // graphs to be aligned, so the CPU graph needs to start
+    // immediately
+
+    for (i = 0; i < graph->n; i++) {
+        float load;
+        float total, used;
+        gchar *text;
+
+        total = NOW[i][CPU_TOTAL] - LAST[i][CPU_TOTAL];
+        used  = NOW[i][CPU_USED]  - LAST[i][CPU_USED];
+
+        load = used / MAX(total, 1.0f);
+        graph->data[0][i] = load;
+
+        /* Update label */
+        text = g_strdup_printf("%.1f%%", load * 100.0f);
+        gtk_label_set_text(GTK_LABEL(graph->labels.cpu[i]), text);
+        g_free(text);
+    }
+
+    graph->cpu.now ^= 1;
+
+#undef NOW
+#undef LAST
+}
+
+
+namespace
+{
+
+    void set_memory_label_and_picker(GtkLabel* label, GSMColorButton* picker,
+                                   guint64 used, guint64 total, double percent)
+    {
+        char* used_text;
+        char* total_text;
+        char* text;
+
+        used_text = g_format_size_full(used, G_FORMAT_SIZE_IEC_UNITS);
+        total_text = g_format_size_full(total, G_FORMAT_SIZE_IEC_UNITS);
+        if (total == 0) {
+            text = g_strdup(_("not available"));
+        } else {
+            // xgettext: 540MiB (53 %) of 1.0 GiB
+            text = g_strdup_printf(_("%s (%.1f%%) of %s"), used_text, 100.0 * percent, total_text);
+        }
+        gtk_label_set_text(label, text);
+        g_free(used_text);
+        g_free(total_text);
+        g_free(text);
+
+        if (picker)
+            gsm_color_button_set_fraction(picker, percent);
+    }
+}
+
+static void
+get_memory (LoadGraph *graph)
+{
+    float mempercent, swappercent;
+
+    glibtop_mem mem;
+    glibtop_swap swap;
+
+    glibtop_get_mem (&mem);
+    glibtop_get_swap (&swap);
+
+    /* There's no swap on LiveCD : 0.0f is better than NaN :) */
+    swappercent = (swap.total ? (float)swap.used / (float)swap.total : 0.0f);
+    mempercent  = (float)mem.user  / (float)mem.total;
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.memory),
+                                GSM_COLOR_BUTTON(graph->mem_color_picker),
+                                mem.user, mem.total, mempercent);
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.swap),
+                                GSM_COLOR_BUTTON(graph->swap_color_picker),
+                                swap.used, swap.total, swappercent);
+
+    graph->data[0][0] = mempercent;
+    graph->data[0][1] = swappercent;
+}
+
+/* Nice Numbers for Graph Labels after Paul Heckbert
+   nicenum: find a "nice" number approximately equal to x.
+   Round the number if round=1, take ceiling if round=0    */
+
+static double
+nicenum (double x, int round)
+{
+    int expv;				/* exponent of x */
+    double f;				/* fractional part of x */
+    double nf;				/* nice, rounded fraction */
+
+    expv = floor( log10(x) );
+    f = x/pow( 10.0, expv );		/* between 1 and 10 */
+    if (round) {
+        if ( f < 1.5 ) nf = 1.0;
+        else if ( f < 3.0 ) nf = 2.0;
+        else if ( f < 7.0 ) nf = 5.0;
+        else nf = 10.0;
+    } else {
+        if ( f <= 1.0 ) nf = 1.0;
+        else if ( f <= 2.0 ) nf = 2.0;
+        else if ( f <= 5.0 ) nf = 5.0;
+        else nf = 10.0;
+    }
+    return nf * pow(10.0, expv);
+}
+
+static void
+net_scale (LoadGraph *graph, guint64 din, guint64 dout)
+{
+    graph->data[0][0] = 1.0f * din / graph->net.max;
+    graph->data[0][1] = 1.0f * dout / graph->net.max;
+
+    guint64 dmax = std::max(din, dout);
+    graph->net.values[graph->net.cur] = dmax;
+    graph->net.cur = (graph->net.cur + 1) % LoadGraph::NUM_POINTS;
+
+    guint64 new_max;
+    // both way, new_max is the greatest value
+    if (dmax >= graph->net.max)
+        new_max = dmax;
+    else
+        new_max = *std::max_element(&graph->net.values[0],
+                                    &graph->net.values[LoadGraph::NUM_POINTS]);
+
+    //
+    // Round network maximum
+    //
+
+    const guint64 bak_max(new_max);
+
+    if (ProcData::get_instance()->config.network_in_bits) {
+        // nice number is for the ticks
+        unsigned ticks = graph->num_bars();
+
+        // gets messy at low values due to division by 8
+        guint64 bit_max = std::max( new_max*8, G_GUINT64_CONSTANT(10000) );
+
+        // our tick size leads to max
+        double d = nicenum(bit_max/ticks, 0);
+        bit_max = ticks * d;
+        new_max = bit_max / 8;
+
+        procman_debug("bak*8 %" G_GUINT64_FORMAT ", ticks %d, d %f"
+                      ", bit_max %" G_GUINT64_FORMAT ", new_max %" G_GUINT64_FORMAT,
+                      bak_max*8, ticks, d, bit_max, new_max );
+    } else {
+        // round up to get some extra space
+        // yes, it can overflow
+        new_max = 1.1 * new_max;
+        // make sure max is not 0 to avoid / 0
+        // default to 1 KiB
+        new_max = std::max(new_max, G_GUINT64_CONSTANT(1024));
+
+        // decompose new_max = coef10 * 2**(base10 * 10)
+        // where coef10 and base10 are integers and coef10 < 2**10
+        //
+        // e.g: ceil(100.5 KiB) = 101 KiB = 101 * 2**(1 * 10)
+        //      where base10 = 1, coef10 = 101, pow2 = 16
+
+        guint64 pow2 = std::floor(log2(new_max));
+        guint64 base10 = pow2 / 10.0;
+        guint64 coef10 = std::ceil(new_max / double(G_GUINT64_CONSTANT(1) << (base10 * 10)));
+        g_assert(new_max <= (coef10 * (G_GUINT64_CONSTANT(1) << (base10 * 10))));
+
+        // then decompose coef10 = x * 10**factor10
+        // where factor10 is integer and x < 10
+        // so we new_max has only 1 significant digit
+
+        guint64 factor10 = std::pow(10.0, std::floor(std::log10(coef10)));
+        coef10 = std::ceil(coef10 / double(factor10)) * factor10;
+
+        // then make coef10 divisible by num_bars
+        if (coef10 % graph->num_bars() != 0)
+            coef10 = coef10 + (graph->num_bars() - coef10 % graph->num_bars());
+        g_assert(coef10 % graph->num_bars() == 0);
+        new_max = coef10 * (G_GUINT64_CONSTANT(1) << guint64(base10 * 10));
+        procman_debug("bak %" G_GUINT64_FORMAT " new_max %" G_GUINT64_FORMAT
+                      "pow2 %" G_GUINT64_FORMAT " coef10 %" G_GUINT64_FORMAT,
+                      bak_max, new_max, pow2, coef10);
+    }
+
+    if (bak_max > new_max) {
+        procman_debug("overflow detected: bak=%" G_GUINT64_FORMAT
+                      " new=%" G_GUINT64_FORMAT,
+                      bak_max, new_max);
+        new_max = bak_max;
+    }
+
+    // if max is the same or has decreased but not so much, don't
+    // do anything to avoid rescaling
+    if ((0.8 * graph->net.max) < new_max && new_max <= graph->net.max)
+        return;
+
+    const double scale = 1.0f * graph->net.max / new_max;
+
+    for (size_t i = 0; i < LoadGraph::NUM_POINTS; i++) {
+        if (graph->data[i][0] >= 0.0f) {
+            graph->data[i][0] *= scale;
+            graph->data[i][1] *= scale;
+        }
+    }
+
+    procman_debug("rescale dmax = %" G_GUINT64_FORMAT
+                  " max = %" G_GUINT64_FORMAT
+                  " new_max = %" G_GUINT64_FORMAT,
+                  dmax, graph->net.max, new_max);
+
+    graph->net.max = new_max;
+
+    // force the graph background to be redrawn now that scale has changed
+    graph->clear_background();
+}
+
+static void
+get_net (LoadGraph *graph)
+{
+    glibtop_netlist netlist;
+    char **ifnames;
+    guint32 i;
+    guint64 in = 0, out = 0;
+#if GLIB_CHECK_VERSION(2,61,2)
+    gint64 time;
+#else
+    GTimeVal time;
+#endif
+    guint64 din, dout;
+
+    ifnames = glibtop_get_netlist(&netlist);
+
+    for (i = 0; i < netlist.number; ++i)
+    {
+        glibtop_netload netload;
+        glibtop_get_netload (&netload, ifnames[i]);
+
+        if (netload.if_flags & (1 << GLIBTOP_IF_FLAGS_LOOPBACK))
+            continue;
+
+        /* Skip interfaces without any IPv4/IPv6 address (or
+         those with only a LINK ipv6 addr) However we need to
+         be able to exclude these while still keeping the
+         value so when they get online (with NetworkManager
+         for example) we don't get a suddent peak.  Once we're
+         able to get this, ignoring down interfaces will be
+         possible too.  */
+        if (not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS6)
+             and netload.scope6 != GLIBTOP_IF_IN6_SCOPE_LINK)
+            and not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS)))
+            continue;
+
+        /* Don't skip interfaces that are down (GLIBTOP_IF_FLAGS_UP)
+           to avoid spikes when they are brought up */
+
+        in  += netload.bytes_in;
+        out += netload.bytes_out;
+    }
+
+    g_strfreev(ifnames);
+
+#if GLIB_CHECK_VERSION(2,61,2)
+    time = g_get_real_time ();
+
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time != 0) {
+        float dtime = (double) (time - graph->net.time) / G_USEC_PER_SEC;
+#else
+    g_get_current_time (&time);
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time.tv_sec != 0) {
+        float dtime;
+        dtime = time.tv_sec - graph->net.time.tv_sec +
+            (double) (time.tv_usec - graph->net.time.tv_usec) / G_USEC_PER_SEC;
+#endif
+        din   = static_cast<guint64>((in  - graph->net.last_in)  / dtime);
+        dout  = static_cast<guint64>((out - graph->net.last_out) / dtime);
+    } else {
+        /* Don't calc anything if new data is less than old (interface
+           removed, counters reset, ...) or if it is the first time */
+        din  = 0;
+        dout = 0;
+    }
+
+    graph->net.last_in  = in;
+    graph->net.last_out = out;
+    graph->net.time     = time;
+
+    net_scale(graph, din, dout);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    g_autofree gchar *str=NULL, *formatted_str=NULL;
+
+    str = g_format_size_full (network_in_bits ? din*8 : din, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? in*8 : in, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in_total), str);
+
+    str = g_format_size_full (network_in_bits ? dout*8 : dout, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? out*8 : out, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out_total), str);
+}
+
+
+/* Updates the load graph when the timeout expires */
+static gboolean
+load_graph_update (gpointer user_data)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(user_data);
+
+    if (graph->render_counter == graph->frames_per_unit - 1) {
+        std::rotate(&graph->data[0], &graph->data[LoadGraph::NUM_POINTS - 1], &graph->data[LoadGraph::NUM_POINTS]);
+
+        switch (graph->type) {
+        case LOAD_GRAPH_CPU:
+            get_load(graph);
+            break;
+        case LOAD_GRAPH_MEM:
+            get_memory(graph);
+            break;
+        case LOAD_GRAPH_NET:
+            get_net(graph);
+            break;
+        default:
+            g_assert_not_reached();
+        }
+    }
+
+    if (graph->draw)
+        load_graph_queue_draw (graph);
+
+    graph->render_counter++;
+
+    if (graph->render_counter >= graph->frames_per_unit)
+        graph->render_counter = 0;
+
+    return TRUE;
+}
+
+
+
+LoadGraph::~LoadGraph()
+{
+  load_graph_stop(this);
+
+  if (timer_index)
+    g_source_remove(timer_index);
+
+  clear_background();
+}
+
+
+
+static gboolean
+load_graph_destroy (GtkWidget *widget, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    delete graph;
+
+    return FALSE;
+}
+
+
+LoadGraph::LoadGraph(guint type)
+  : fontsize(8.0),
+    rmargin(3.5 * fontsize),
+    indent(24.0),
+    n(0),
+    type(type),
+    speed(0),
+    draw_width(0),
+    draw_height(0),
+    render_counter(0),
+    frames_per_unit(10), // this will be changed but needs initialising
+    graph_dely(0),
+    real_draw_height(0),
+    graph_delx(0.0),
+    graph_buffer_offset(0),
+    main_widget(NULL),
+    disp(NULL),
+    background(NULL),
+    timer_index(0),
+    draw(FALSE),
+    mem_color_picker(NULL),
+    swap_color_picker(NULL)
+{
+    LoadGraph * const graph = this;
+
+    // FIXME:
+    // on configure, graph->frames_per_unit = graph->draw_width/(LoadGraph::NUM_POINTS);
+    // knock FRAMES down to 5 until cairo gets faster
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memset(&cpu, 0, sizeof cpu);
+        n = ProcData::get_instance()->config.num_cpus;
+
+        for(guint i = 0; i < G_N_ELEMENTS(labels.cpu); ++i)
+            labels.cpu[i] = gtk_label_new(NULL);
+
+        break;
+
+    case LOAD_GRAPH_MEM:
+        n = 2;
+        labels.memory = gtk_label_new(NULL);
+        labels.swap = gtk_label_new(NULL);
+        break;
+
+    case LOAD_GRAPH_NET:
+        memset(&net, 0, sizeof net);
+        n = 2;
+        net.max = 1;
+        labels.net_in = gtk_label_new(NULL);
+        labels.net_in_total = gtk_label_new(NULL);
+        labels.net_out = gtk_label_new(NULL);
+        labels.net_out_total = gtk_label_new(NULL);
+        break;
+    }
+
+    speed  = ProcData::get_instance()->config.graph_update_interval;
+
+    colors.resize(n);
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memcpy(&colors[0], ProcData::get_instance()->config.cpu_color,
+               n * sizeof colors[0]);
+        break;
+    case LOAD_GRAPH_MEM:
+        colors[0] = ProcData::get_instance()->config.mem_color;
+        colors[1] = ProcData::get_instance()->config.swap_color;
+        mem_color_picker = gsm_color_button_new (&colors[0],
+                                                 GSMCP_TYPE_PIE);
+        swap_color_picker = gsm_color_button_new (&colors[1],
+                                                  GSMCP_TYPE_PIE);
+        break;
+    case LOAD_GRAPH_NET:
+        colors[0] = ProcData::get_instance()->config.net_in_color;
+        colors[1] = ProcData::get_instance()->config.net_out_color;
+        break;
+    }
+
+    timer_index = 0;
+    render_counter = (frames_per_unit - 1);
+    draw = FALSE;
+
+    main_widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+    gtk_widget_set_size_request(main_widget, -1, LoadGraph::GRAPH_MIN_HEIGHT);
+    gtk_widget_show (main_widget);
+
+    disp = gtk_drawing_area_new ();
+    gtk_widget_show (disp);
+    g_signal_connect (G_OBJECT (disp), "draw", G_CALLBACK (load_graph_draw), graph);
+    g_signal_connect (G_OBJECT(disp), "configure_event",
+                      G_CALLBACK (load_graph_configure), graph);
+    g_signal_connect (G_OBJECT(disp), "destroy",
+                      G_CALLBACK (load_graph_destroy), graph);
+
+    gtk_widget_set_events (disp, GDK_EXPOSURE_MASK);
+
+    gtk_box_pack_start (GTK_BOX (main_widget), disp, TRUE, TRUE, 0);
+
+
+    /* Allocate data in a contiguous block */
+    data_block = std::vector<float>(n * LoadGraph::NUM_POINTS, -1.0f);
+
+    for (guint i = 0; i < LoadGraph::NUM_POINTS; ++i)
+        data[i] = &data_block[0] + i * n;
+
+    gtk_widget_show_all (main_widget);
+}
+
+void
+load_graph_start (LoadGraph *graph)
+{
+    if(!graph->timer_index) {
+
+        load_graph_update(graph);
+
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->draw = TRUE;
+}
+
+void
+load_graph_stop (LoadGraph *graph)
+{
+    /* don't draw anymore, but continue to poll */
+    graph->draw = FALSE;
+}
+
+void
+load_graph_change_speed (LoadGraph *graph,
+             guint new_speed)
+{
+    if (graph->speed == new_speed)
+        return;
+
+    graph->speed = new_speed;
+
+    if(graph->timer_index) {
+        g_source_remove (graph->timer_index);
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->clear_background();
+}
+
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *graph)
+{
+    return &graph->labels;
+}
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *graph)<--- Parameter 'graph' can be declared as pointer to const
+{
+    return graph->main_widget;
+}
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *graph)<--- Parameter 'graph' can be declared as pointer to const
+{
+    return graph->mem_color_picker;
+}
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *graph)<--- Parameter 'graph' can be declared as pointer to const
+{
+    return graph->swap_color_picker;
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/25.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/25.html new file mode 100644 index 00000000..cbf052f0 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/25.html @@ -0,0 +1,1075 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtkmm/messagedialog.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/regex.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procopenfiles.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <sys/wait.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <set><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sstream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <iterator><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibmm/regex.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "lsof.h"
+#include "util.h"
+
+
+using std::string;
+
+
+namespace
+{
+
+    class Lsof
+    {
+        Glib::RefPtr<Glib::Regex> re;
+
+        bool matches(const string &filename) const
+        {
+            return this->re->match(filename);
+        }
+
+    public:
+
+        Lsof(const string &pattern, bool caseless)
+        {
+            Glib::RegexCompileFlags flags = static_cast<Glib::RegexCompileFlags>(0);
+
+            if (caseless)
+                flags |= Glib::REGEX_CASELESS;
+
+            this->re = Glib::Regex::create(pattern, flags);
+        }
+
+
+        template<typename OutputIterator>
+        void search(const ProcInfo &info, OutputIterator out) const
+        {
+            glibtop_open_files_entry *entries;
+            glibtop_proc_open_files buf;
+
+            entries = glibtop_get_proc_open_files(&buf, info.pid);
+
+            for (unsigned i = 0; i != buf.number; ++i) {
+                if (entries[i].type & GLIBTOP_FILE_TYPE_FILE) {
+                    const string filename(entries[i].info.file.name);
+                    if (this->matches(filename))
+                        *out++ = filename;
+                }
+            }
+
+            g_free(entries);
+        }
+    };
+
+
+
+    // GUI Stuff
+
+
+    enum ProcmanLsof {
+        PROCMAN_LSOF_COL_SURFACE,
+        PROCMAN_LSOF_COL_PROCESS,
+        PROCMAN_LSOF_COL_PID,
+        PROCMAN_LSOF_COL_FILENAME,
+        PROCMAN_LSOF_NCOLS
+    };
+
+
+    struct GUI {
+
+        GtkListStore *model;
+        GtkEntry *entry;
+        GtkWindow *window;
+        GtkLabel *count;<--- Shadowed declaration
+        ProcData *procdata;
+        bool case_insensitive;
+
+
+        GUI()
+        {
+            procman_debug("New Lsof GUI %p", this);
+        }
+
+
+        ~GUI()
+        {
+            procman_debug("Destroying Lsof GUI %p", this);
+        }
+
+
+        void clear_results()
+        {
+            gtk_list_store_clear(this->model);
+            gtk_label_set_text(this->count, "");
+        }
+
+
+        void clear()
+        {
+            this->clear_results();
+            gtk_entry_set_text(this->entry, "");
+        }
+
+
+        void display_regex_error(const Glib::RegexError& error)
+        {
+            char * msg = g_strdup_printf ("<b>%s</b>\n%s\n%s",
+                                          _("Error"),
+                                          _("'%s' is not a valid Perl regular expression."),
+                                          "%s");
+            std::string message = make_string(g_strdup_printf(msg, this->pattern().c_str(), error.what().c_str()));
+            g_free(msg);
+
+            Gtk::MessageDialog dialog(message,
+                                      true, // use markup
+                                      Gtk::MESSAGE_ERROR,
+                                      Gtk::BUTTONS_OK,
+                                      true); // modal
+            dialog.run();
+        }
+
+
+        void update_count(unsigned count)
+        {
+            std::ostringstream ss;
+            ss << count;
+            string s = ss.str();
+            gtk_label_set_text(this->count, s.c_str());
+        }
+
+
+        string pattern() const
+        {
+            return gtk_entry_get_text(this->entry);
+        }
+
+
+        void search()
+        {
+            typedef std::set<string> MatchSet;
+            typedef MatchSet::const_iterator iterator;
+
+            this->clear_results();
+
+
+            try {
+                Lsof lsof(this->pattern(), this->case_insensitive);
+
+                unsigned count = 0;<--- Shadow variable
+
+                for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it) {
+                    const ProcInfo &info(*it->second);
+
+                    MatchSet matches;
+                    lsof.search(info, std::inserter(matches, matches.begin()));
+                    count += matches.size();
+
+                    for (iterator it(matches.begin()), end(matches.end()); it != end; ++it) {
+                        GtkTreeIter file;
+                        gtk_list_store_append(this->model, &file);
+                        gtk_list_store_set(this->model, &file,
+                                           PROCMAN_LSOF_COL_SURFACE, info.surface,
+                                           PROCMAN_LSOF_COL_PROCESS, info.name,
+                                           PROCMAN_LSOF_COL_PID, info.pid,
+                                           PROCMAN_LSOF_COL_FILENAME, it->c_str(),
+                                           -1);
+                    }
+                }
+
+                this->update_count(count);
+            }
+            catch (Glib::RegexError& error) {
+                this->display_regex_error(error);
+            }
+        }
+
+
+        static void search_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void search_entry_activate(GtkEntry *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void clear_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->clear();
+        }
+
+
+        static void close_button_clicked(GtkButton *, gpointer data)
+        {
+            GUI *gui = static_cast<GUI*>(data);
+            gtk_widget_destroy(GTK_WIDGET(gui->window));
+            delete gui;
+        }
+
+
+        static void case_button_toggled(GtkToggleButton *button, gpointer data)
+        {
+            bool state = gtk_toggle_button_get_active(button);
+            static_cast<GUI*>(data)->case_insensitive = state;
+        }
+
+
+        static gboolean window_delete_event(GtkWidget *, GdkEvent *, gpointer data)
+        {
+            delete static_cast<GUI*>(data);
+            return FALSE;
+        }
+
+    };
+}
+
+
+
+
+void procman_lsof(ProcData *procdata)
+{
+    GtkListStore *model = \
+        gtk_list_store_new(PROCMAN_LSOF_NCOLS,
+                           CAIRO_GOBJECT_TYPE_SURFACE, // PROCMAN_LSOF_COL_SURFACE
+                           G_TYPE_STRING,              // PROCMAN_LSOF_COL_PROCESS
+                           G_TYPE_UINT,                // PROCMAN_LSOF_COL_PID
+                           G_TYPE_STRING               // PROCMAN_LSOF_COL_FILENAME
+        );
+
+    GtkWidget *tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_object_unref(model);
+
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *renderer;
+
+    // SURFACE / PROCESS
+
+    column = gtk_tree_view_column_new();
+
+    renderer = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "surface", PROCMAN_LSOF_COL_SURFACE,
+                                        NULL);
+
+    renderer = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "text", PROCMAN_LSOF_COL_PROCESS,
+                                        NULL);
+
+    gtk_tree_view_column_set_title(column, _("Process"));
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PROCESS);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_column_set_min_width(column, 10);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), PROCMAN_LSOF_COL_PROCESS,
+                                         GTK_SORT_ASCENDING);
+
+
+    // PID
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("PID"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_PID,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PID);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    // FILENAME
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("Filename"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_FILENAME,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_FILENAME);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    GtkWidget *dialog; /* = gtk_dialog_new_with_buttons(_("Search for Open Files"), NULL,
+                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+                                                        NULL); */
+    dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(procdata->app));
+    gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
+    // gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_title(GTK_WINDOW(dialog), _("Search for Open Files"));
+
+    // g_signal_connect(G_OBJECT(dialog), "response",
+    //                           G_CALLBACK(close_dialog), NULL);
+    gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(dialog), 575, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(dialog), 12);
+    GtkWidget *mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_add(GTK_CONTAINER(dialog), mainbox);
+    gtk_box_set_spacing(GTK_BOX(mainbox), 6);
+
+
+    // Label, entry and search button
+
+    GtkWidget *hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), hbox1, FALSE, FALSE, 0);
+
+    GtkWidget *image = gtk_image_new_from_icon_name("edit-find", GTK_ICON_SIZE_DIALOG);
+    gtk_box_pack_start(GTK_BOX(hbox1), image, FALSE, FALSE, 0);
+
+
+    GtkWidget *vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox1), vbox2, TRUE, TRUE, 0);
+
+
+    GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox, TRUE, TRUE, 0);
+    GtkWidget *label = gtk_label_new_with_mnemonic(_("_Name contains:"));
+    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+    GtkWidget *entry = gtk_entry_new();
+
+    gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
+
+    GtkWidget *search_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                         "label", "gtk-find",
+                                                         "use-stock", TRUE,
+                                                         "use-underline", TRUE,
+                                                         NULL));
+
+    gtk_box_pack_start(GTK_BOX(hbox), search_button, FALSE, FALSE, 0);
+
+    GtkWidget *clear_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-clear",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    /* The default accelerator collides with the default close accelerator. */
+    gtk_button_set_label(GTK_BUTTON(clear_button), _("C_lear"));
+    gtk_box_pack_start(GTK_BOX(hbox), clear_button, FALSE, FALSE, 0);
+
+
+    GtkWidget *case_button = gtk_check_button_new_with_mnemonic(_("Case insensitive matching"));
+    GtkWidget *hbox3 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox3), case_button, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox3, FALSE, FALSE, 0);
+
+
+    GtkWidget *results_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), results_box, FALSE, FALSE, 0);
+    GtkWidget *results_label = gtk_label_new_with_mnemonic(_("S_earch results:"));
+    gtk_box_pack_start(GTK_BOX(results_box), results_label, FALSE, FALSE, 0);
+    GtkWidget *count_label = gtk_label_new(NULL);
+    gtk_box_pack_end(GTK_BOX(results_box), count_label, FALSE, FALSE, 0);
+
+    // Scrolled TreeView
+    GtkWidget *scrolled = gtk_scrolled_window_new(NULL, NULL);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
+                                   GTK_POLICY_AUTOMATIC,
+                                   GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled),
+                                        GTK_SHADOW_IN);
+    gtk_container_add(GTK_CONTAINER(scrolled), tree);
+    gtk_box_pack_start(GTK_BOX(mainbox), scrolled, TRUE, TRUE, 0);
+
+    GtkWidget *bottom_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+
+    GtkWidget *close_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-close",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    gtk_box_pack_start(GTK_BOX(mainbox), bottom_box, FALSE, FALSE, 0);
+    gtk_box_pack_end(GTK_BOX(bottom_box), close_button, FALSE, FALSE, 0);
+
+
+    GUI *gui = new GUI; // wil be deleted by the close button or delete-event
+    gui->procdata = procdata;
+    gui->model = model;
+    gui->window = GTK_WINDOW(dialog);
+    gui->entry = GTK_ENTRY(entry);
+    gui->count = GTK_LABEL(count_label);
+
+    g_signal_connect(G_OBJECT(entry), "activate",
+                     G_CALLBACK(GUI::search_entry_activate), gui);
+    g_signal_connect(G_OBJECT(clear_button), "clicked",
+                     G_CALLBACK(GUI::clear_button_clicked), gui);
+    g_signal_connect(G_OBJECT(search_button), "clicked",
+                     G_CALLBACK(GUI::search_button_clicked), gui);
+    g_signal_connect(G_OBJECT(close_button), "clicked",
+                     G_CALLBACK(GUI::close_button_clicked), gui);
+    g_signal_connect(G_OBJECT(case_button), "toggled",
+                     G_CALLBACK(GUI::case_button_toggled), gui);
+    g_signal_connect(G_OBJECT(dialog), "delete-event",
+                     G_CALLBACK(GUI::window_delete_event), gui);
+
+
+    gtk_widget_show_all(dialog);
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/26.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/26.html new file mode 100644 index 00000000..7bce5b12 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/26.html @@ -0,0 +1,1197 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibtop/procmap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mountlist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <map><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sstream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <iomanip><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdexcept><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+using std::string;
+
+
+#include "procman.h"
+#include "memmaps.h"
+#include "proctable.h"
+#include "util.h"
+
+
+/* be careful with this enum, you could break the column names */
+enum
+{
+    MMAP_COL_FILENAME,
+    MMAP_COL_VMSTART,
+    MMAP_COL_VMEND,
+    MMAP_COL_VMSZ,
+    MMAP_COL_FLAGS,
+    MMAP_COL_VMOFFSET,
+    MMAP_COL_PRIVATE_CLEAN,
+    MMAP_COL_PRIVATE_DIRTY,
+    MMAP_COL_SHARED_CLEAN,
+    MMAP_COL_SHARED_DIRTY,
+    MMAP_COL_DEVICE,
+    MMAP_COL_INODE,
+    MMAP_COL_MAX
+};
+
+
+namespace
+{
+    class OffsetFormater
+    {
+        string format;
+
+    public:
+
+        void set(const glibtop_map_entry &last_map)
+        {
+            this->format = (last_map.end <= G_MAXUINT32) ? "%08" G_GINT64_MODIFIER "x" : "%016" G_GINT64_MODIFIER "x";
+        }
+
+        string operator()(guint64 v) const
+        {
+            char buffer[17];
+            g_snprintf(buffer, sizeof buffer, this->format.c_str(), v);
+            return buffer;
+        }
+    };
+
+
+    class InodeDevices
+    {
+        typedef std::map<guint16, string> Map;
+        Map devices;
+
+    public:
+
+        void update()
+        {
+            this->devices.clear();
+
+            glibtop_mountlist list;
+            glibtop_mountentry *entries = glibtop_get_mountlist(&list, 1);
+
+            for (unsigned i = 0; i != list.number; ++i) {
+                struct stat buf;
+
+                if (stat(entries[i].devname, &buf) != -1)
+                    this->devices[buf.st_rdev] = entries[i].devname;
+            }
+
+            g_free(entries);
+        }
+
+        string get(guint64 dev64)
+        {
+            if (dev64 == 0)
+                return "";
+
+            guint16 dev = dev64 & 0xffff;
+
+            if (dev != dev64)
+                g_warning("weird device %" G_GINT64_MODIFIER "x", dev64);
+
+            Map::iterator it(this->devices.find(dev));
+
+            if (it != this->devices.end())
+                return it->second;
+
+            guint8 major, minor;
+            major = dev >> 8;
+            minor = dev;
+
+            std::ostringstream out;
+            out << std::hex
+                << std::setfill('0')
+                << std::setw(2) << unsigned(major)
+                << ':'
+                << std::setw(2) << unsigned(minor);
+
+            this->devices[dev] = out.str();
+            return out.str();
+        }
+    };
+
+
+    class MemMapsData
+    {
+    public:
+        guint timer;
+        GtkWidget *tree;
+        GSettings *settings;
+        ProcInfo *info;
+        OffsetFormater format;
+        mutable InodeDevices devices;
+        const char * const schema;
+
+        MemMapsData(GtkWidget *a_tree, GSettings *a_settings)
+            : tree(a_tree),
+            settings(a_settings),
+            schema("memmapstree")
+        {
+            procman_get_tree_state(this->settings, this->tree, this->schema);
+        }
+
+        ~MemMapsData()
+        {
+            procman_save_tree_state(this->settings, this->tree, this->schema);
+        }
+    };
+}
+
+
+struct glibtop_map_entry_cmp
+{
+    bool operator()(const glibtop_map_entry &a, const guint64 start) const
+    {
+        return a.start < start;
+    }
+
+    bool operator()(const guint64 &start, const glibtop_map_entry &a) const
+    {
+        return start < a.start;
+    }
+
+};
+
+
+static void
+update_row(GtkTreeModel *model, GtkTreeIter &row, const MemMapsData &mm, const glibtop_map_entry *memmaps)
+{
+    guint64 size;
+    string filename, device;
+    string vmstart, vmend, vmoffset;
+    char flags[5] = "----";
+
+    size = memmaps->end - memmaps->start;
+
+    if(memmaps->perm & GLIBTOP_MAP_PERM_READ)    flags [0] = 'r';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_WRITE)   flags [1] = 'w';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_EXECUTE) flags [2] = 'x';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_SHARED)  flags [3] = 's';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_PRIVATE) flags [3] = 'p';
+
+    if (memmaps->flags & (1 << GLIBTOP_MAP_ENTRY_FILENAME))
+      filename = memmaps->filename;
+
+    vmstart  = mm.format(memmaps->start);
+    vmend    = mm.format(memmaps->end);
+    vmoffset = mm.format(memmaps->offset);
+    device   = mm.devices.get(memmaps->device);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        MMAP_COL_FILENAME, filename.c_str(),
+                        MMAP_COL_VMSTART, vmstart.c_str(),
+                        MMAP_COL_VMEND, vmend.c_str(),
+                        MMAP_COL_VMSZ, size,
+                        MMAP_COL_FLAGS, flags,
+                        MMAP_COL_VMOFFSET, vmoffset.c_str(),
+                        MMAP_COL_PRIVATE_CLEAN, memmaps->private_clean,
+                        MMAP_COL_PRIVATE_DIRTY, memmaps->private_dirty,
+                        MMAP_COL_SHARED_CLEAN, memmaps->shared_clean,
+                        MMAP_COL_SHARED_DIRTY, memmaps->shared_dirty,
+                        MMAP_COL_DEVICE, device.c_str(),
+                        MMAP_COL_INODE, memmaps->inode,
+                        -1);
+}
+
+
+
+
+static void
+update_memmaps_dialog (MemMapsData *mmdata)
+{
+    GtkTreeModel *model;
+    glibtop_map_entry *memmaps;
+    glibtop_proc_map procmap;
+
+    memmaps = glibtop_get_proc_map (&procmap, mmdata->info->pid);
+    /* process has disappeared */
+    if(!memmaps or procmap.number == 0) return;
+
+    mmdata->format.set(memmaps[procmap.number - 1]);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+
+    GtkTreeIter iter;<--- Shadowed declaration
+
+    typedef std::map<guint64, GtkTreeIter> IterCache;
+    IterCache iter_cache;
+
+    /*
+      removes the old maps and
+      also fills a cache of start -> iter in order to speed
+      up add
+    */
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        while (true) {
+            char *vmstart = 0;
+            guint64 start;
+            gtk_tree_model_get(model, &iter,
+                               MMAP_COL_VMSTART, &vmstart,
+                               -1);
+
+            try {
+                std::istringstream(vmstart) >> std::hex >> start;
+            } catch (std::logic_error &e) {
+                g_warning("Could not parse %s", vmstart);
+                start = 0;
+            }
+
+            g_free(vmstart);
+
+            bool found = std::binary_search(memmaps, memmaps + procmap.number,
+                                            start, glibtop_map_entry_cmp());
+
+            if (found) {
+                iter_cache[start] = iter;
+                if (!gtk_tree_model_iter_next(model, &iter))
+                    break;
+            } else {
+                if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                    break;
+            }
+        }
+    }
+
+    mmdata->devices.update();
+
+    /*
+      add the new maps
+    */
+
+    for (guint i = 0; i != procmap.number; i++) {
+        GtkTreeIter iter;<--- Shadow variable
+        IterCache::iterator it(iter_cache.find(memmaps[i].start));
+
+        if (it != iter_cache.end())
+            iter = it->second;
+        else
+            gtk_list_store_prepend(GTK_LIST_STORE(model), &iter);
+
+        update_row(model, iter, *mmdata, &memmaps[i]);
+    }
+
+    g_free (memmaps);
+}
+
+
+
+static void
+dialog_response (GtkDialog * dialog, gint response_id, gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+
+    g_source_remove (mmdata->timer);
+
+    delete mmdata;
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+
+static MemMapsData*
+create_memmapsdata (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Filename"),
+        // xgettext: virtual memory start
+        N_("VM Start"),
+        // xgettext: virtual memory end
+        N_("VM End"),
+        // xgettext: virtual memory syze
+        N_("VM Size"),
+        N_("Flags"),
+        // xgettext: virtual memory offset
+        N_("VM Offset"),
+        // xgettext: memory that has not been modified since
+        // it has been allocated
+        N_("Private clean"),
+        // xgettext: memory that has been modified since it
+        // has been allocated
+        N_("Private dirty"),
+        // xgettext: shared memory that has not been modified
+        // since it has been allocated
+        N_("Shared clean"),
+        // xgettext: shared memory that has been modified
+        // since it has been allocated
+        N_("Shared dirty"),
+        N_("Device"),
+        N_("Inode")
+    };
+
+    model = gtk_list_store_new (MMAP_COL_MAX,
+                                G_TYPE_STRING, /* MMAP_COL_FILENAME  */
+                                G_TYPE_STRING, /* MMAP_COL_VMSTART     */
+                                G_TYPE_STRING, /* MMAP_COL_VMEND     */
+                                G_TYPE_UINT64, /* MMAP_COL_VMSZ     */
+                                G_TYPE_STRING, /* MMAP_COL_FLAGS     */
+                                G_TYPE_STRING, /* MMAP_COL_VMOFFSET  */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_DIRTY */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_DIRTY */
+                                G_TYPE_STRING, /* MMAP_COL_DEVICE     */
+                                G_TYPE_UINT64 /* MMAP_COL_INODE     */
+                                );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < MMAP_COL_MAX; i++) {
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(tree), col);
+
+        switch (i) {
+            case MMAP_COL_PRIVATE_CLEAN:
+            case MMAP_COL_PRIVATE_DIRTY:
+            case MMAP_COL_SHARED_CLEAN:
+            case MMAP_COL_SHARED_DIRTY:
+            case MMAP_COL_VMSZ:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                         &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+                break;
+        }
+
+
+        switch (i) {
+            case MMAP_COL_VMSTART:
+            case MMAP_COL_VMEND:
+            case MMAP_COL_FLAGS:
+            case MMAP_COL_VMOFFSET:
+            case MMAP_COL_DEVICE:
+                g_object_set(cell, "family", "monospace", NULL);
+                break;
+        }
+    }
+
+    return new MemMapsData(tree, procdata->settings);
+}
+
+
+static gboolean
+memmaps_timer (gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+    g_assert(model);
+
+    update_memmaps_dialog (mmdata);
+
+    return TRUE;
+}
+
+
+static void
+create_single_memmaps_dialog (GtkTreeModel *model, GtkTreePath *path,
+                              GtkTreeIter *iter, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    MemMapsData *mmdata;
+    GtkWidget *memmapsdialog;
+    GtkWidget *dialog_vbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    ProcInfo *info;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    mmdata = create_memmapsdata (procdata);
+    mmdata->info = info;
+
+    memmapsdialog = gtk_dialog_new_with_buttons (_("Memory Maps"), GTK_WINDOW (procdata->app),
+                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                 "gtk-close", GTK_RESPONSE_CLOSE,
+                                                 NULL);
+    gtk_window_set_resizable(GTK_WINDOW(memmapsdialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(memmapsdialog), 620, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(memmapsdialog), 5);
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG(memmapsdialog));
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Memory maps for process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), label, FALSE, TRUE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    gtk_container_add (GTK_CONTAINER (scrolled), mmdata->tree);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), mmdata->tree);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+
+    g_signal_connect(G_OBJECT(memmapsdialog), "response",
+                              G_CALLBACK(dialog_response), mmdata);
+
+    gtk_widget_show_all (memmapsdialog);
+
+    mmdata->timer = g_timeout_add_seconds (5, memmaps_timer, mmdata);
+
+    update_memmaps_dialog (mmdata);
+}
+
+
+void
+create_memmaps_dialog (ProcData *procdata)
+{
+    /* TODO: do we really want to open multiple dialogs ? */
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_memmaps_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/27.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/27.html new file mode 100644 index 00000000..fec20c10 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/27.html @@ -0,0 +1,1067 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#if defined (__ELF__) && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
+# define SECTION __attribute__ ((section (".gresource.msm"), aligned (8)))
+#else
+# define SECTION
+#endif
+
+static const SECTION union { const guint8 data[3353]; const double alignment; void * const ptr;}  msm_resource_data = { {<--- union member 'Anonymous0::alignment' is never used.<--- union member 'Anonymous0::ptr' is never used.
+  0107, 0126, 0141, 0162, 0151, 0141, 0156, 0164, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0030, 0000, 0000, 0000, 0310, 0000, 0000, 0000, 0000, 0000, 0000, 0050, 0006, 0000, 0000, 0000, 
+  0000, 0000, 0000, 0000, 0001, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0005, 0000, 0000, 0000, 0376, 0236, 0033, 0101, 0005, 0000, 0000, 0000, 
+  0310, 0000, 0000, 0000, 0024, 0000, 0114, 0000, 0334, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 
+  0113, 0120, 0220, 0013, 0002, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 0004, 0000, 0114, 0000, 
+  0350, 0000, 0000, 0000, 0354, 0000, 0000, 0000, 0324, 0265, 0002, 0000, 0377, 0377, 0377, 0377, 
+  0354, 0000, 0000, 0000, 0001, 0000, 0114, 0000, 0360, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 
+  0173, 0250, 0316, 0037, 0000, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 0014, 0000, 0166, 0000, 
+  0000, 0001, 0000, 0000, 0034, 0006, 0000, 0000, 0234, 0164, 0275, 0021, 0000, 0000, 0000, 0000, 
+  0034, 0006, 0000, 0000, 0016, 0000, 0166, 0000, 0060, 0006, 0000, 0000, 0017, 0015, 0000, 0000, 
+  0201, 0321, 0040, 0031, 0001, 0000, 0000, 0000, 0017, 0015, 0000, 0000, 0005, 0000, 0114, 0000, 
+  0024, 0015, 0000, 0000, 0030, 0015, 0000, 0000, 0155, 0141, 0164, 0145, 0055, 0163, 0171, 0163, 
+  0164, 0145, 0155, 0055, 0155, 0157, 0156, 0151, 0164, 0157, 0162, 0057, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0157, 0162, 0147, 0057, 0005, 0000, 0000, 0000, 0057, 0000, 0000, 0000, 
+  0001, 0000, 0000, 0000, 0151, 0156, 0164, 0145, 0162, 0146, 0141, 0143, 0145, 0056, 0165, 0151, 
+  0242, 0073, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0133, 0133, 0163, 0352, 0066, 
+  0020, 0176, 0317, 0257, 0160, 0375, 0332, 0161, 0010, 0227, 0320, 0164, 0006, 0070, 0323, 0166, 
+  0232, 0364, 0241, 0347, 0114, 0046, 0344, 0114, 0037, 0031, 0331, 0136, 0260, 0212, 0054, 0271, 
+  0222, 0314, 0345, 0337, 0237, 0065, 0066, 0004, 0002, 0370, 0102, 0210, 0061, 0224, 0067, 0154, 
+  0257, 0054, 0355, 0267, 0253, 0335, 0317, 0253, 0245, 0363, 0145, 0346, 0063, 0143, 0002, 0122, 
+  0121, 0301, 0273, 0146, 0375, 0366, 0316, 0064, 0200, 0073, 0302, 0245, 0174, 0324, 0065, 0277, 
+  0277, 0076, 0132, 0017, 0346, 0227, 0336, 0115, 0347, 0047, 0313, 0062, 0236, 0200, 0203, 0044, 
+  0032, 0134, 0143, 0112, 0265, 0147, 0214, 0030, 0161, 0301, 0150, 0336, 0066, 0037, 0156, 0033, 
+  0206, 0145, 0241, 0020, 0345, 0032, 0344, 0220, 0070, 0320, 0353, 0110, 0370, 0057, 0244, 0022, 
+  0224, 0301, 0250, 0335, 0065, 0107, 0172, 0374, 0263, 0371, 0066, 0113, 0363, 0266, 0321, 0062, 
+  0153, 0275, 0216, 0260, 0377, 0005, 0107, 0033, 0016, 0043, 0112, 0165, 0315, 0047, 0075, 0376, 
+  0207, 0162, 0127, 0114, 0115, 0203, 0272, 0135, 0323, 0047, 0224, 0017, 0246, 0361, 0215, 0136, 
+  0047, 0220, 0042, 0000, 0251, 0347, 0006, 0047, 0076, 0164, 0115, 0207, 0160, 0153, 0050, 0234, 
+  0120, 0231, 0275, 0107, 0302, 0024, 0164, 0152, 0113, 0201, 0055, 0121, 0115, 0065, 0003, 0323, 
+  0320, 0222, 0160, 0305, 0210, 0046, 0066, 0303, 0233, 0163, 0300, 0221, 0375, 0271, 0322, 0340, 
+  0033, 0137, 0005, 0247, 0132, 0310, 0224, 0127, 0270, 0060, 0044, 0041, 0323, 0326, 0224, 0272, 
+  0332, 0063, 0173, 0255, 0326, 0135, 0016, 0141, 0017, 0350, 0310, 0323, 0050, 0375, 0353, 0375, 
+  0272, 0264, 0343, 0121, 0346, 0356, 0120, 0375, 0167, 0061, 0133, 0323, 0333, 0306, 0253, 0255, 
+  0067, 0117, 0250, 0242, 0270, 0172, 0263, 0367, 0052, 0303, 0064, 0215, 0013, 0200, 0043, 0044, 
+  0005, 0256, 0211, 0106, 0263, 0230, 0075, 0264, 0217, 0246, 0016, 0141, 0073, 0226, 0033, 0060, 
+  0264, 0252, 0047, 0230, 0013, 0022, 0355, 0126, 0113, 0356, 0356, 0323, 0345, 0233, 0320, 0140, 
+  0013, 0061, 0216, 0025, 0342, 0313, 0253, 0143, 0050, 0224, 0041, 0351, 0023, 0071, 0242, 0334, 
+  0122, 0232, 0110, 0204, 0276, 0336, 0310, 0026, 0005, 0356, 0346, 0023, 0324, 0042, 0170, 0057, 
+  0230, 0151, 0113, 0065, 0127, 0224, 0017, 0105, 0151, 0346, 0364, 0140, 0026, 0220, 0110, 0241, 
+  0214, 0127, 0116, 0162, 0312, 0331, 0102, 0242, 0305, 0227, 0176, 0237, 0212, 0222, 0012, 0210, 
+  0203, 0061, 0143, 0017, 0104, 0251, 0376, 0263, 0373, 0141, 0055, 0206, 0365, 0235, 0264, 0241, 
+  0347, 0101, 0264, 0251, 0211, 0155, 0356, 0000, 0376, 0157, 0142, 0003, 0333, 0204, 0236, 0055, 
+  0156, 0225, 0001, 0176, 0074, 0323, 0376, 0100, 0263, 0076, 0164, 0245, 0034, 0242, 0066, 0106, 
+  0330, 0266, 0243, 0026, 0261, 0255, 0041, 0145, 0154, 0307, 0264, 0265, 0325, 0230, 0254, 0175, 
+  0270, 0362, 0103, 0034, 0354, 0374, 0037, 0234, 0060, 0063, 0234, 0355, 0165, 0332, 0207, 0074, 
+  0373, 0172, 0315, 0275, 0230, 0040, 0356, 0200, 0114, 0106, 0045, 0372, 0227, 0107, 0030, 0035, 
+  0241, 0136, 0213, 0340, 0126, 0310, 0231, 0226, 0100, 0147, 0315, 0020, 0073, 0134, 0306, 0212, 
+  0003, 0241, 0150, 0014, 0360, 0335, 0141, 0136, 0331, 0167, 0244, 0140, 0014, 0334, 0365, 0144, 
+  0037, 0071, 0050, 0050, 0005, 0152, 0240, 0222, 0247, 0145, 0144, 0213, 0143, 0173, 0252, 0362, 
+  0010, 0152, 0144, 0105, 0041, 0312, 0354, 0121, 0236, 0073, 0016, 0236, 0312, 0200, 0365, 0003, 
+  0303, 0112, 0250, 0065, 0016, 0137, 0030, 0016, 0323, 0147, 0142, 0073, 0073, 0276, 0133, 0040, 
+  0054, 0376, 0311, 0135, 0143, 0360, 0034, 0217, 0116, 0131, 0157, 0250, 0300, 0042, 0116, 0264, 
+  0142, 0213, 0004, 0001, 0020, 0174, 0221, 0003, 0331, 0130, 0034, 0337, 0135, 0044, 0070, 0100, 
+  0047, 0240, 0254, 0204, 0342, 0145, 0373, 0127, 0262, 0143, 0021, 0244, 0014, 0375, 0102, 0216, 
+  0036, 0301, 0050, 0337, 0261, 0334, 0123, 0071, 0107, 0043, 0335, 0071, 0062, 0227, 0125, 0314, 
+  0315, 0162, 0347, 0365, 0105, 0052, 0253, 0102, 0122, 0177, 0136, 0206, 0254, 0102, 0306, 0332, 
+  0203, 0312, 0247, 0146, 0177, 0374, 0014, 0273, 0046, 0377, 0242, 0214, 0165, 0077, 0234, 0116, 
+  0020, 0126, 0347, 0373, 0154, 0257, 0116, 0167, 0005, 0011, 0115, 0244, 0125, 0025, 0266, 0325, 
+  0037, 0317, 0337, 0215, 0277, 0250, 0302, 0017, 0362, 0171, 0312, 0370, 0131, 0022, 0131, 0067, 
+  0264, 0044, 0132, 0113, 0212, 0151, 0010, 0324, 0332, 0357, 0144, 0300, 0064, 0376, 0032, 0067, 
+  0046, 0204, 0205, 0013, 0267, 0142, 0156, 0124, 0201, 0250, 0255, 0217, 0071, 0063, 0036, 0265, 
+  0341, 0220, 0043, 0111, 0002, 0357, 0154, 0167, 0371, 0301, 0156, 0336, 0376, 0160, 0255, 0342, 
+  0221, 0211, 0351, 0006, 0222, 0103, 0274, 0121, 0032, 0220, 0223, 0175, 0234, 0076, 0265, 0256, 
+  0161, 0377, 0113, 0332, 0354, 0202, 0205, 0076, 0212, 0056, 0041, 0112, 0013, 0231, 0022, 0331, 
+  0152, 0056, 0101, 0037, 0047, 0137, 0040, 0050, 0201, 0133, 0370, 0300, 0212, 0271, 0112, 0063, 
+  0165, 0311, 0263, 0135, 0103, 0322, 0213, 0010, 0300, 0040, 0146, 0172, 0276, 0160, 0121, 0230, 
+  0013, 0176, 0112, 0056, 0204, 0223, 0044, 0144, 0076, 0235, 0301, 0345, 0246, 0072, 0025, 0045, 
+  0372, 0347, 0032, 0370, 0174, 0360, 0057, 0060, 0023, 0107, 0132, 0125, 0041, 0023, 0177, 0005, 
+  0037, 0223, 0260, 0201, 0206, 0067, 0372, 0123, 0022, 0134, 0263, 0162, 0161, 0347, 0274, 0146, 
+  0345, 0174, 0131, 0071, 0072, 0135, 0302, 0004, 0263, 0310, 0134, 0252, 0333, 0302, 0337, 0230, 
+  0231, 0124, 0167, 0161, 0254, 0264, 0015, 0361, 0223, 0244, 0356, 0033, 0306, 0013, 0227, 0055, 
+  0005, 0337, 0002, 0111, 0070, 0257, 0051, 0066, 0022, 0160, 0273, 0100, 0126, 0157, 0147, 0274, 
+  0324, 0023, 0276, 0030, 0001, 0007, 0261, 0253, 0256, 0221, 0043, 0010, 0051, 0334, 0361, 0145, 
+  0326, 0066, 0163, 0342, 0225, 0122, 0143, 0307, 0005, 0027, 0015, 0115, 0231, 0241, 0205, 0301, 
+  0120, 0133, 0030, 0214, 0210, 0343, 0245, 0223, 0035, 0055, 0202, 0225, 0334, 0201, 0201, 0143, 
+  0063, 0003, 0140, 0240, 0075, 0053, 0370, 0343, 0144, 0361, 0271, 0006, 0250, 0037, 0325, 0000, 
+  0007, 0034, 0111, 0235, 0342, 0341, 0225, 0362, 0136, 0024, 0345, 0255, 0177, 0220, 0125, 0160, 
+  0320, 0027, 0110, 0171, 0043, 0255, 0252, 0100, 0171, 0277, 0201, 0236, 0012, 0071, 0276, 0122, 
+  0335, 0342, 0116, 0171, 0245, 0272, 0173, 0330, 0154, 0073, 0067, 0233, 0215, 0140, 0074, 0031, 
+  0233, 0155, 0345, 0154, 0225, 0151, 0076, 0134, 0062, 0355, 0215, 0217, 0370, 0160, 0252, 0263, 
+  0042, 0137, 0057, 0313, 0125, 0237, 0023, 0377, 0112, 0063, 0203, 0026, 0232, 0260, 0101, 0162, 
+  0336, 0352, 0236, 0225, 0055, 0136, 0243, 0245, 0033, 0057, 0311, 0322, 0253, 0141, 0220, 0372, 
+  0207, 0015, 0242, 0160, 0357, 0237, 0333, 0256, 0350, 0143, 0104, 0377, 0134, 0374, 0357, 0113, 
+  0336, 0020, 0150, 0005, 0175, 0206, 0233, 0241, 0072, 0206, 0070, 0302, 0106, 0300, 0101, 0040, 
+  0267, 0341, 0137, 0034, 0120, 0133, 0121, 0327, 0063, 0050, 0235, 0221, 0045, 0077, 0215, 0322, 
+  0366, 0156, 0112, 0256, 0156, 0154, 0071, 0114, 0334, 0362, 0334, 0070, 0014, 0346, 0337, 0042, 
+  0077, 0360, 0321, 0131, 0336, 0347, 0342, 0200, 0072, 0143, 0220, 0003, 0262, 0172, 0136, 0006, 
+  0244, 0233, 0235, 0007, 0355, 0343, 0065, 0163, 0155, 0300, 0176, 0127, 0071, 0330, 0227, 0241, 
+  0376, 0202, 0101, 0157, 0225, 0016, 0372, 0045, 0026, 0176, 0076, 0122, 0146, 0313, 0255, 0134, 
+  0306, 0262, 0057, 0243, 0050, 0164, 0274, 0126, 0273, 0306, 0061, 0133, 0355, 0242, 0276, 0261, 
+  0052, 0124, 0145, 0136, 0100, 0211, 0120, 0072, 0007, 0167, 0332, 0065, 0112, 0353, 0264, 0033, 
+  0226, 0327, 0150, 0127, 0106, 0143, 0134, 0073, 0317, 0327, 0363, 0256, 0166, 0156, 0227, 0252, 
+  0361, 0265, 0225, 0273, 0102, 0045, 0274, 0002, 0273, 0245, 0171, 0314, 0020, 0062, 0254, 0106, 
+  0004, 0171, 0244, 0014, 0214, 0370, 0137, 0070, 0207, 0006, 0221, 0346, 0261, 0202, 0310, 0231, 
+  0235, 0074, 0364, 0061, 0160, 0204, 0312, 0046, 0062, 0141, 0207, 0253, 0313, 0112, 0237, 0100, 
+  0064, 0076, 0261, 0153, 0054, 0113, 0252, 0170, 0136, 0337, 0276, 0361, 0366, 0117, 0332, 0233, 
+  0037, 0325, 0360, 0311, 0023, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0160, 0162, 0145, 0146, 
+  0145, 0162, 0145, 0156, 0143, 0145, 0163, 0056, 0165, 0151, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0065, 0123, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0134, 0335, 0162, 0342, 0066, 
+  0024, 0276, 0357, 0123, 0250, 0276, 0355, 0050, 0004, 0262, 0155, 0167, 0072, 0301, 0073, 0335, 
+  0335, 0046, 0335, 0231, 0266, 0263, 0323, 0354, 0266, 0227, 0036, 0331, 0076, 0140, 0155, 0204, 
+  0344, 0112, 0002, 0102, 0257, 0372, 0054, 0175, 0264, 0076, 0111, 0217, 0177, 0010, 0140, 0300, 
+  0066, 0004, 0210, 0041, 0334, 0331, 0346, 0110, 0072, 0072, 0377, 0237, 0216, 0206, 0353, 0067, 
+  0017, 0003, 0101, 0106, 0240, 0015, 0127, 0262, 0353, 0264, 0057, 0056, 0035, 0002, 0062, 0120, 
+  0041, 0227, 0375, 0256, 0363, 0371, 0323, 0015, 0175, 0355, 0274, 0161, 0277, 0272, 0376, 0232, 
+  0122, 0162, 0013, 0022, 0064, 0263, 0020, 0222, 0061, 0267, 0021, 0351, 0013, 0026, 0002, 0271, 
+  0272, 0270, 0172, 0175, 0321, 0041, 0224, 0042, 0021, 0227, 0026, 0164, 0217, 0005, 0340, 0136, 
+  0153, 0370, 0153, 0310, 0065, 0030, 0042, 0270, 0337, 0165, 0372, 0366, 0376, 0033, 0147, 0266, 
+  0312, 0325, 0105, 0347, 0225, 0323, 0162, 0257, 0225, 0377, 0005, 0002, 0113, 0002, 0301, 0214, 
+  0351, 0072, 0267, 0366, 0376, 0303, 0200, 0365, 0301, 0041, 0074, 0354, 0072, 0074, 0171, 0154, 
+  0073, 0356, 0165, 0254, 0125, 0014, 0332, 0116, 0210, 0144, 0003, 0350, 0072, 0043, 0156, 0270, 
+  0057, 0300, 0161, 0077, 0351, 0041, 0134, 0267, 0246, 0277, 0056, 0321, 0005, 0114, 0322, 0236, 
+  0012, 0206, 0306, 0161, 0157, 0230, 0060, 0145, 0244, 0074, 0120, 0222, 0046, 0217, 0216, 0073, 
+  0346, 0062, 0124, 0143, 0032, 0010, 0265, 0070, 0242, 0225, 0261, 0132, 0203, 0345, 0316, 0241, 
+  0131, 0216, 0100, 0304, 0324, 0327, 0152, 0154, 0100, 0327, 0143, 0371, 0075, 0147, 0102, 0365, 
+  0063, 0236, 0143, 0015, 0075, 0320, 0250, 0161, 0060, 0136, 0230, 0175, 0177, 0012, 0137, 0276, 
+  0322, 0041, 0150, 0072, 0346, 0241, 0215, 0034, 0367, 0333, 0022, 0112, 0313, 0055, 0212, 0204, 
+  0130, 0315, 0244, 0021, 0314, 0062, 0024, 0120, 0327, 0231, 0000, 0256, 0161, 0067, 0061, 0026, 
+  0006, 0344, 0127, 0045, 0271, 0125, 0232, 0174, 0234, 0161, 0130, 0062, 0135, 0010, 0075, 0066, 
+  0024, 0166, 0272, 0362, 0253, 0313, 0313, 0032, 0304, 0021, 0360, 0176, 0144, 0221, 0272, 0123, 
+  0116, 0155, 0254, 0126, 0023, 0232, 0030, 0075, 0215, 0031, 0262, 0142, 0053, 0125, 0151, 0047, 
+  0061, 0320, 0210, 0047, 0224, 0231, 0124, 0347, 0151, 0203, 0210, 0213, 0220, 0244, 0316, 0042, 
+  0231, 0240, 0351, 0053, 0132, 0211, 0257, 0036, 0234, 0025, 0332, 0172, 0213, 0237, 0123, 0125, 
+  0145, 0023, 0171, 0202, 0115, 0324, 0320, 0076, 0111, 0113, 0003, 0246, 0373, 0134, 0122, 0253, 
+  0342, 0162, 0035, 0345, 0164, 0276, 0262, 0126, 0015, 0312, 0111, 0225, 0346, 0050, 0027, 0146, 
+  0321, 0277, 0035, 0027, 0035, 0335, 0362, 0200, 0211, 0022, 0172, 0023, 0263, 0000, 0103, 0214, 
+  0343, 0166, 0252, 0045, 0303, 0202, 0144, 0132, 0017, 0045, 0317, 0126, 0012, 0150, 0210, 0354, 
+  0311, 0242, 0230, 0026, 0007, 0155, 0040, 0253, 0164, 0321, 0265, 0313, 0144, 0153, 0044, 0076, 
+  0347, 0371, 0331, 0207, 0245, 0311, 0005, 0363, 0101, 0070, 0356, 0317, 0110, 0123, 0042, 0200, 
+  0241, 0001, 0232, 0361, 0110, 0131, 0034, 0003, 0103, 0077, 0010, 0240, 0132, 0165, 0133, 0304, 
+  0222, 0012, 0112, 0015, 0001, 0360, 0021, 0030, 0232, 0173, 0105, 0345, 0200, 0064, 0314, 0071, 
+  0156, 0026, 0355, 0126, 0106, 0034, 0324, 0355, 0075, 0052, 0167, 0151, 0044, 0074, 0304, 0114, 
+  0206, 0325, 0233, 0354, 0161, 0041, 0052, 0331, 0210, 0225, 0341, 0231, 0271, 0055, 0070, 0157, 
+  0353, 0161, 0361, 0126, 0256, 0311, 0072, 0012, 0115, 0003, 0176, 0225, 0106, 0337, 0025, 0263, 
+  0302, 0111, 0252, 0264, 0335, 0004, 0225, 0266, 0313, 0125, 0172, 0140, 0266, 0160, 0021, 0232, 
+  0104, 0164, 0307, 0005, 0031, 0356, 0320, 0044, 0223, 0242, 0112, 0322, 0100, 0211, 0341, 0100, 
+  0232, 0156, 0033, 0237, 0223, 0064, 0216, 0017, 0130, 0115, 0055, 0333, 0353, 0255, 0346, 0141, 
+  0156, 0255, 0012, 0043, 0244, 0264, 0136, 0077, 0371, 0162, 0210, 0162, 0143, 0323, 0350, 0236, 
+  0155, 0211, 0226, 0004, 0371, 0025, 0373, 0373, 0115, 0131, 0360, 0225, 0272, 0317, 0366, 0050, 
+  0247, 0157, 0007, 0360, 0227, 0150, 0152, 0056, 0025, 0164, 0243, 0232, 0164, 0045, 0125, 0120, 
+  0271, 0346, 0073, 0125, 0232, 0307, 0211, 0260, 0016, 0062, 0130, 0254, 0141, 0305, 0344, 0345, 
+  0166, 0160, 0020, 0023, 0330, 0257, 0214, 0332, 0235, 0035, 0132, 0037, 0212, 0162, 0146, 0172, 
+  0355, 0327, 0173, 0021, 0277, 0017, 0021, 0033, 0161, 0245, 0017, 0042, 0373, 0205, 0015, 0175, 
+  0127, 0307, 0227, 0176, 0111, 0063, 0326, 0032, 0236, 0275, 0074, 0237, 0035, 0302, 0152, 0230, 
+  0340, 0175, 0324, 0232, 0261, 0114, 0333, 0022, 0272, 0214, 0243, 0125, 0150, 0340, 0155, 0316, 
+  0164, 0131, 0055, 0211, 0162, 0021, 0100, 0005, 0227, 0100, 0007, 0052, 0134, 0261, 0001, 0146, 
+  0255, 0346, 0230, 0335, 0301, 0314, 0075, 0347, 0243, 0307, 0031, 0010, 0040, 0043, 0046, 0206, 
+  0251, 0135, 0212, 0060, 0301, 0246, 0255, 0371, 0061, 0225, 0371, 0106, 0100, 0317, 0122, 0034, 
+  0301, 0202, 0250, 0020, 0374, 0213, 0300, 0100, 0305, 0253, 0351, 0066, 0115, 0022, 0257, 0066, 
+  0267, 0125, 0317, 0100, 0220, 0071, 0321, 0001, 0064, 0237, 0143, 0207, 0124, 0361, 0025, 0376, 
+  0135, 0151, 0336, 0213, 0042, 0350, 0324, 0316, 0223, 0303, 0070, 0144, 0026, 0274, 0024, 0117, 
+  0240, 0172, 0017, 0227, 0057, 0353, 0006, 0313, 0142, 0236, 0154, 0167, 0266, 0166, 0356, 0307, 
+  0115, 0036, 0316, 0271, 0327, 0073, 0255, 0367, 0071, 0225, 0074, 0231, 0062, 0205, 0017, 0004, 
+  0215, 0117, 0311, 0320, 0374, 0120, 0121, 0100, 0017, 0045, 0246, 0205, 0304, 0225, 0053, 0071, 
+  0035, 0110, 0030, 0050, 0311, 0203, 0044, 0207, 0364, 0001, 0215, 0154, 0205, 0060, 0114, 0314, 
+  0245, 0134, 0163, 0056, 0362, 0014, 0276, 0274, 0244, 0312, 0073, 0344, 0157, 0036, 0207, 0254, 
+  0337, 0302, 0041, 0352, 0040, 0056, 0363, 0071, 0021, 0171, 0063, 0134, 0361, 0277, 0177, 0376, 
+  0055, 0233, 0127, 0360, 0201, 0117, 0223, 0003, 0301, 0102, 0275, 0136, 0074, 0077, 0341, 0175, 
+  0156, 0115, 0241, 0010, 0334, 0114, 0013, 0355, 0335, 0150, 0241, 0121, 0252, 0177, 0027, 0101, 
+  0260, 0200, 0101, 0315, 0100, 0051, 0033, 0125, 0200, 0320, 0125, 0336, 0366, 0223, 0114, 0136, 
+  0210, 0227, 0115, 0100, 0064, 0364, 0064, 0230, 0350, 0070, 0201, 0152, 0025, 0017, 0233, 0205, 
+  0210, 0120, 0263, 0061, 0345, 0062, 0304, 0202, 0321, 0046, 0265, 0132, 0221, 0174, 0077, 0006, 
+  0321, 0336, 0221, 0101, 0004, 0311, 0207, 0055, 0354, 0341, 0107, 0201, 0144, 0304, 0207, 0236, 
+  0322, 0100, 0020, 0261, 0342, 0352, 0104, 0151, 0342, 0335, 0043, 0330, 0115, 0236, 0037, 0203, 
+  0314, 0331, 0104, 0236, 0313, 0104, 0072, 0273, 0212, 0031, 0112, 0060, 0315, 0315, 0026, 0106, 
+  0342, 0275, 0347, 0043, 0036, 0002, 0171, 0367, 0361, 0063, 0031, 0032, 0326, 0007, 0342, 0117, 
+  0322, 0227, 0100, 0015, 0245, 0075, 0133, 0306, 0163, 0131, 0306, 0325, 0163, 0244, 0260, 0166, 
+  0163, 0363, 0346, 0323, 0241, 0172, 0217, 0203, 0010, 0315, 0121, 0036, 0222, 0354, 0010, 0370, 
+  0147, 0022, 0150, 0004, 0062, 0370, 0040, 0061, 0053, 0015, 0322, 0263, 0034, 0162, 0223, 0262, 
+  0125, 0062, 0315, 0227, 0241, 0261, 0274, 0067, 0161, 0334, 0344, 0230, 0266, 0204, 0016, 0060, 
+  0257, 0305, 0206, 0377, 0135, 0171, 0100, 0133, 0175, 0122, 0120, 0030, 0360, 0220, 0237, 0137, 
+  0134, 0236, 0370, 0151, 0302, 0306, 0356, 0324, 0074, 0054, 0135, 0327, 0247, 0052, 0117, 0023, 
+  0267, 0161, 0255, 0324, 0304, 0033, 0341, 0140, 0037, 0063, 0326, 0010, 0367, 0346, 0074, 0315, 
+  0104, 0152, 0054, 0023, 0020, 0056, 0270, 0261, 0173, 0106, 0340, 0126, 0003, 0170, 0271, 0201, 
+  0155, 0352, 0131, 0315, 0302, 0346, 0201, 0126, 0102, 0100, 0370, 0147, 0172, 0047, 0244, 0250, 
+  0170, 0223, 0377, 0172, 0214, 0375, 0011, 0023, 0261, 0344, 0226, 0113, 0326, 0322, 0342, 0262, 
+  0216, 0361, 0177, 0102, 0255, 0376, 0301, 0141, 0116, 0014, 0363, 0172, 0076, 0214, 0020, 0030, 
+  0332, 0245, 0241, 0217, 0063, 0127, 0371, 0010, 0244, 0260, 0230, 0032, 0054, 0121, 0023, 0053, 
+  0130, 0335, 0350, 0137, 0272, 0154, 0140, 0100, 0074, 0236, 0222, 0256, 0224, 0302, 0335, 0043, 
+  0301, 0242, 0105, 0114, 0203, 0052, 0235, 0315, 0320, 0132, 0121, 0102, 0235, 0140, 0041, 0327, 
+  0350, 0105, 0027, 0274, 0234, 0044, 0046, 0217, 0363, 0060, 0337, 0251, 0033, 0340, 0223, 0076, 
+  0133, 0203, 0342, 0372, 0042, 0150, 0257, 0024, 0055, 0316, 0100, 0263, 0036, 0367, 0322, 0312, 
+  0073, 0357, 0112, 0153, 0060, 0152, 0250, 0203, 0163, 0157, 0362, 0171, 0172, 0223, 0063, 0361, 
+  0367, 0065, 0213, 0243, 0146, 0001, 0236, 0047, 0001, 0231, 0342, 0316, 0016, 0331, 0277, 0254, 
+  0271, 0277, 0365, 0176, 0173, 0233, 0262, 0174, 0006, 0071, 0307, 0000, 0162, 0226, 0014, 0255, 
+  0241, 0015, 0323, 0203, 0037, 0063, 0154, 0333, 0200, 0235, 0011, 0264, 0320, 0212, 0075, 0255, 
+  0056, 0354, 0154, 0233, 0347, 0056, 0254, 0273, 0102, 0030, 0307, 0326, 0205, 0135, 0277, 0205, 
+  0163, 0027, 0366, 0324, 0273, 0260, 0076, 0112, 0151, 0233, 0166, 0312, 0135, 0244, 0306, 0104, 
+  0202, 0035, 0053, 0175, 0117, 0114, 0014, 0220, 0100, 0113, 0222, 0314, 0166, 0232, 0275, 0224, 
+  0272, 0301, 0365, 0004, 0032, 0266, 0057, 0247, 0347, 0122, 0271, 0150, 0355, 0033, 0332, 0233, 
+  0301, 0355, 0105, 0350, 0330, 0204, 0334, 0371, 0373, 0224, 0243, 0215, 0254, 0157, 0215, 0170, 
+  0366, 0007, 0312, 0053, 0113, 0332, 0020, 0106, 0374, 0014, 0311, 0237, 0011, 0222, 0117, 0205, 
+  0177, 0074, 0227, 0205, 0213, 0034, 0037, 0025, 0324, 0256, 0161, 0125, 0370, 0014, 0266, 0033, 
+  0003, 0266, 0227, 0114, 0355, 0310, 0301, 0366, 0336, 0100, 0364, 0124, 0120, 0047, 0174, 0215, 
+  0171, 0151, 0213, 0057, 0027, 0076, 0057, 0211, 0342, 0330, 0300, 0363, 0272, 0015, 0234, 0241, 
+  0363, 0251, 0103, 0147, 0046, 0204, 0067, 0325, 0176, 0172, 0167, 0165, 0023, 0000, 0235, 0342, 
+  0147, 0017, 0247, 0040, 0230, 0232, 0201, 0230, 0364, 0117, 0000, 0316, 0330, 0371, 0214, 0235, 
+  0137, 0310, 0175, 0305, 0251, 0343, 0274, 0324, 0333, 0212, 0213, 0373, 0077, 0052, 0334, 0161, 
+  0276, 0323, 0170, 0012, 0056, 0167, 0302, 0067, 0032, 0367, 0350, 0247, 0315, 0271, 0370, 0170, 
+  0063, 0053, 0033, 0236, 0347, 0362, 0143, 0310, 0315, 0175, 0162, 0051, 0116, 0302, 0370, 0144, 
+  0357, 0077, 0116, 0265, 0377, 0242, 0157, 0077, 0256, 0120, 0364, 0013, 0276, 0000, 0231, 0233, 
+  0004, 0115, 0044, 0062, 0102, 0031, 0235, 0357, 0077, 0036, 0305, 0242, 0263, 0126, 0105, 0147, 
+  0227, 0235, 0234, 0004, 0274, 0171, 0071, 0170, 0153, 0114, 0063, 0047, 0115, 0015, 0167, 0313, 
+  0210, 0162, 0133, 0041, 0075, 0245, 0237, 0323, 0314, 0276, 0136, 0315, 0320, 0271, 0247, 0177, 
+  0161, 0232, 0176, 0310, 0341, 0174, 0226, 0120, 0115, 0341, 0235, 0150, 0060, 0261, 0222, 0006, 
+  0127, 0240, 0355, 0166, 0366, 0277, 0207, 0171, 0243, 0036, 0113, 0321, 0171, 0312, 0222, 0201, 
+  0337, 0073, 0356, 0374, 0137, 0175, 0055, 0015, 0154, 0025, 0131, 0230, 0361, 0070, 0373, 0163, 
+  0313, 0257, 0376, 0007, 0112, 0344, 0157, 0105, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0155, 
+  0141, 0164, 0145, 0057, 0000, 0000, 0000, 0000
+} };
+
+static GStaticResource static_resource = { msm_resource_data.data, sizeof (msm_resource_data.data) - 1 /* nul terminator */, NULL, NULL, NULL };
+
+G_MODULE_EXPORT
+GResource *msm_get_resource (void);
+GResource *msm_get_resource (void)
+{
+  return g_static_resource_get_resource (&static_resource);
+}
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GLib Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __G_CONSTRUCTOR_H__
+#define __G_CONSTRUCTOR_H__
+
+/*
+  If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and
+  destructors, in a usable way, including e.g. on library unload. If not you're on
+  your own.
+
+  Some compilers need #pragma to handle this, which does not work with macros,
+  so the way you need to use this is (for constructors):
+
+  #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+  #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(my_constructor)
+  #endif
+  G_DEFINE_CONSTRUCTOR(my_constructor)
+  static void my_constructor(void) {
+   ...
+  }
+
+*/
+
+#ifndef __GTK_DOC_IGNORE__
+
+#if  __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func (void);
+#define G_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func (void);
+
+#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
+/* Visual studio 2008 and later has _Pragma */
+
+/*
+ * Only try to include gslist.h if not already included via glib.h,
+ * so that items using gconstructor.h outside of GLib (such as
+ * GResources) continue to build properly.
+ */
+#ifndef __G_LIB_H__
+#include "gslist.h"
+#endif
+
+#include <stdlib.h>
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* We do some weird things to avoid the constructors being optimized
+ * away on VS2015 if WholeProgramOptimization is enabled. First we
+ * make a reference to the array from the wrapper to make sure its
+ * references. Then we use a pragma to make sure the wrapper function
+ * symbol is always included at the link stage. Also, the symbols
+ * need to be extern (but not dllexport), even though they are not
+ * really used from another object file.
+ */
+
+/* We need to account for differences between the mangling of symbols
+ * for x86 and x64/ARM/ARM64 programs, as symbols on x86 are prefixed
+ * with an underscore but symbols on x64/ARM/ARM64 are not.
+ */
+#ifdef _M_IX86
+#define G_MSVC_SYMBOL_PREFIX "_"
+#else
+#define G_MSVC_SYMBOL_PREFIX ""
+#endif
+
+#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
+#define G_DEFINE_DESTRUCTOR(_func) G_MSVC_DTOR (_func, G_MSVC_SYMBOL_PREFIX)
+
+#define G_MSVC_CTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _wrapper(void) { _func(); g_slist_find (NULL,  _array ## _func); return 0; } \
+  __pragma(comment(linker,"/include:" _sym_prefix # _func "_wrapper")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _wrapper;
+
+#define G_MSVC_DTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _constructor(void) { atexit (_func); g_slist_find (NULL,  _array ## _func); return 0; } \
+   __pragma(comment(linker,"/include:" _sym_prefix # _func "_constructor")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined (_MSC_VER)
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* Pre Visual studio 2008 must use #pragma section */
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _wrapper(void) { _func(); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func ## _wrapper;
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _constructor(void) { atexit (_func); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined(__SUNPRO_C)
+
+/* This is not tested, but i believe it should work, based on:
+ * http://opensource.apple.com/source/OpenSSL098/OpenSSL098-35/src/fips/fips_premain.c
+ */
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  init(_func)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void);
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  fini(_func)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void);
+
+#else
+
+/* constructors not supported for this compiler */
+
+#endif
+
+#endif /* __GTK_DOC_IGNORE__ */
+#endif /* __G_CONSTRUCTOR_H__ */
+
+#ifdef G_HAS_CONSTRUCTORS
+
+#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(msmresource_constructor)
+#endif
+G_DEFINE_CONSTRUCTOR(msmresource_constructor)
+#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(msmresource_destructor)
+#endif
+G_DEFINE_DESTRUCTOR(msmresource_destructor)
+
+#else
+#warning "Constructor not supported on this compiler, linking in resources will not work"
+#endif
+
+static void msmresource_constructor (void)
+{
+  g_static_resource_init (&static_resource);
+}
+
+static void msmresource_destructor (void)
+{
+  g_static_resource_fini (&static_resource);
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/28.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/28.html new file mode 100644 index 00000000..88cc9fc6 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/28.html @@ -0,0 +1,1039 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procopenfiles.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <netdb.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/socket.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <netinet/in.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <arpa/inet.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "openfiles.h"
+#include "proctable.h"
+#include "util.h"
+#include "settings-keys.h"
+
+#ifndef NI_IDN
+#define NI_IDN 0
+#endif
+
+enum
+{
+    COL_FD,
+    COL_TYPE,
+    COL_OBJECT,
+    COL_OPENFILE_STRUCT,
+    NUM_OPENFILES_COL
+};
+
+
+static const char*
+get_type_name(enum glibtop_file_type t)
+{
+    switch(t)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        return _("file");
+    case GLIBTOP_FILE_TYPE_PIPE:
+        return _("pipe");
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+        return _("IPv6 network connection");
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        return _("IPv4 network connection");
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        return _("local socket");
+    default:
+        return _("unknown type");
+    }
+}
+
+
+
+static char *
+friendlier_hostname(const char *addr_str, int port)
+{
+    struct addrinfo hints = { };
+    struct addrinfo *res = NULL;
+    char hostname[NI_MAXHOST];
+    char service[NI_MAXSERV];
+    char port_str[6];
+
+    if (!addr_str[0]) return g_strdup("");
+
+    snprintf(port_str, sizeof port_str, "%d", port);
+
+    hints.ai_family = AF_UNSPEC;
+    hints.ai_socktype = SOCK_STREAM;
+
+    if (getaddrinfo(addr_str, port_str, &hints, &res))
+        goto failsafe;
+
+    if (getnameinfo(res->ai_addr, res->ai_addrlen, hostname,<--- Null pointer dereference
+            sizeof hostname, service, sizeof service, NI_IDN))
+        goto failsafe;
+
+    if (res) freeaddrinfo(res);<--- Assuming that condition 'res' is not redundant
+        return g_strdup_printf("%s, TCP port %d (%s)", hostname, port, service);
+
+  failsafe:
+    if (res) freeaddrinfo(res);
+    return g_strdup_printf("%s, TCP port %d", addr_str, port);
+}
+
+
+
+static void
+add_new_files (gpointer key, gpointer value, gpointer data)
+{
+    glibtop_open_files_entry *openfiles = static_cast<glibtop_open_files_entry*>(value);
+
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreeIter row;
+
+    char *object;
+
+    switch(openfiles->type)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        object = g_strdup(openfiles->info.file.name);
+        break;
+
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        object = friendlier_hostname(openfiles->info.sock.dest_host,
+                         openfiles->info.sock.dest_port);
+        break;
+
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        object = g_strdup(openfiles->info.localsock.name);
+        break;
+
+    default:
+        object = g_strdup("");
+    }
+
+    gtk_list_store_insert (GTK_LIST_STORE (model), &row, 0);
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        COL_FD, openfiles->fd,
+                        COL_TYPE, get_type_name(static_cast<glibtop_file_type>(openfiles->type)),
+                        COL_OBJECT, object,
+#if GLIB_CHECK_VERSION (2, 68, 0)
+                        COL_OPENFILE_STRUCT, g_memdup2(openfiles, sizeof(*openfiles)),
+#else
+                        COL_OPENFILE_STRUCT, g_memdup(openfiles, sizeof(*openfiles)),
+#endif
+                        -1);
+
+    g_free(object);
+}
+
+static GList *old_maps = NULL;
+
+static gboolean
+classify_openfiles (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+    GHashTable *new_maps = static_cast<GHashTable*>(data);
+    GtkTreeIter *old_iter;
+    glibtop_open_files_entry *openfiles;
+    gchar *old_name;
+
+    gtk_tree_model_get (model, iter, 1, &old_name, -1);
+
+    openfiles = static_cast<glibtop_open_files_entry*>(g_hash_table_lookup (new_maps, old_name));
+    if (openfiles) {
+        g_hash_table_remove (new_maps, old_name);
+        g_free (old_name);
+        return FALSE;
+
+    }
+
+    old_iter = gtk_tree_iter_copy (iter);
+    old_maps = g_list_append (old_maps, old_iter);
+    g_free (old_name);
+    return FALSE;
+
+}
+
+
+static gboolean
+compare_open_files(gconstpointer a, gconstpointer b)
+{
+    const glibtop_open_files_entry *o1 = static_cast<const glibtop_open_files_entry *>(a);
+    const glibtop_open_files_entry *o2 = static_cast<const glibtop_open_files_entry *>(b);
+
+    /* Falta manejar los diferentes tipos! */
+    return (o1->fd == o2->fd) && (o1->type == o2->type); /* XXX! */
+}
+
+
+static void
+update_openfiles_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+    GtkTreeModel *model;
+    glibtop_open_files_entry *openfiles;<--- Shadowed declaration
+    glibtop_proc_open_files procmap;
+    GHashTable *new_maps;
+    guint i;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    if (!info)
+        return;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    openfiles = glibtop_get_proc_open_files (&procmap, info->pid);
+
+    if (!openfiles)
+        return;
+
+    new_maps = static_cast<GHashTable *>(g_hash_table_new_full (g_str_hash, compare_open_files,
+                                                                NULL, NULL));
+    for (i=0; i < procmap.number; i++)
+        g_hash_table_insert (new_maps, openfiles + i, openfiles + i);
+
+    gtk_tree_model_foreach (model, classify_openfiles, new_maps);
+
+    g_hash_table_foreach (new_maps, add_new_files, model);
+
+    while (old_maps) {
+        GtkTreeIter *iter = static_cast<GtkTreeIter*>(old_maps->data);
+        glibtop_open_files_entry *openfiles = NULL;<--- Shadow variable
+
+        gtk_tree_model_get (model, iter,
+                            COL_OPENFILE_STRUCT, &openfiles,
+                            -1);
+
+        gtk_list_store_remove (GTK_LIST_STORE (model), iter);
+        gtk_tree_iter_free (iter);
+        g_free (openfiles);
+
+        old_maps = g_list_next (old_maps);
+
+    }
+
+    g_hash_table_destroy (new_maps);
+    g_free (openfiles);
+}
+
+static void
+close_openfiles_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GSettings *settings;
+    guint timer;
+
+    settings = static_cast<GSettings*>(g_object_get_data (G_OBJECT (tree), "settings"));
+    procman_save_tree_state (settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    return ;
+}
+
+
+static GtkWidget *
+create_openfiles_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    const gchar * const titles[] = {
+        /* Translators: "FD" here means "File Descriptor". Please use
+           a very short translation if possible, and at most
+           2-3 characters for it to be able to fit in the UI. */
+        N_("FD"),
+        N_("Type"),
+        N_("Object")
+    };
+
+    model = gtk_list_store_new (NUM_OPENFILES_COL,
+                                G_TYPE_INT,        /* FD */
+                                G_TYPE_STRING,    /* Type */
+                                G_TYPE_STRING,    /* Object */
+                                G_TYPE_POINTER    /* open_files_entry */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_OPENFILES_COL-1; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        switch (i) {
+        case COL_FD:
+            g_object_set(cell, "xalign", 1.0f, NULL);
+            break;
+        }
+
+        column = gtk_tree_view_column_new_with_attributes (_(titles[i]),
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_sort_column_id (column, i);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    procman_get_tree_state (procdata->settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    return tree;
+}
+
+
+static gboolean
+openfiles_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_openfiles_dialog (tree);
+
+    return TRUE;
+}
+
+
+static void
+create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *openfilesdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    openfilesdialog = gtk_dialog_new_with_buttons (_("Open Files"), NULL,
+                                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                   "gtk-close", GTK_RESPONSE_CLOSE,
+                                                   NULL);
+    gtk_window_set_resizable (GTK_WINDOW (openfilesdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (openfilesdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (openfilesdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (openfilesdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Files opened by process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                    GTK_POLICY_AUTOMATIC,
+                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_openfiles_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+    g_object_set_data (G_OBJECT (tree), "settings", procdata->settings);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (openfilesdialog), "response",
+                      G_CALLBACK (close_openfiles_dialog), tree);
+
+    gtk_widget_show_all (openfilesdialog);
+
+    timer = g_timeout_add_seconds (5, openfiles_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_openfiles_dialog (tree);
+
+}
+
+
+void
+create_openfiles_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_openfiles_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/29.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/29.html new file mode 100644 index 00000000..a5901ac6 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/29.html @@ -0,0 +1,271 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
#ifndef H_PROCMAN_SETTINGS_KEYS_1177430397
+#define H_PROCMAN_SETTINGS_KEYS_1177430397
+
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+namespace procman
+{
+    namespace settings
+    {
+        extern const std::string root;
+        extern const std::string solaris_mode;
+        extern const std::string open_files_tree_prefix;
+        extern const std::string network_in_bits;
+    }
+}
+
+#endif //  H_PROCMAN_SETTINGS_KEYS_1177430397
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/3.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/3.html new file mode 100644 index 00000000..1d042194 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/3.html @@ -0,0 +1,395 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
/* Procman - callbacks
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef _PROCMAN_CALLBACKS_H_
+#define _PROCMAN_CALLBACKS_H_
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+#include "gsm_color_button.h"
+
+void            cb_show_memory_maps (GtkAction *action, gpointer data);
+void            cb_show_open_files (GtkAction *action, gpointer data);
+void            cb_show_process_properties (GtkAction *action, gpointer data);
+void            cb_show_lsof(GtkAction *action, gpointer data);
+void            cb_renice (GtkAction *action, GtkRadioAction *current, gpointer data);
+void            cb_end_process (GtkAction *action, gpointer data);
+void            cb_kill_process (GtkAction *action, gpointer data);
+void            cb_edit_preferences (GtkAction *action, gpointer data);
+
+void            cb_help_contents (GtkAction *action, gpointer data);
+void            cb_about (GtkAction *action, gpointer data);
+
+void            cb_app_exit (GtkAction *action, gpointer data);
+gboolean        cb_app_delete (GtkWidget *window, GdkEventAny *event, gpointer data);
+
+void            cb_end_process_button_pressed (GtkButton *button, gpointer data);
+void            cb_logout (GtkButton *button, gpointer data);
+
+void            cb_info_button_pressed (GtkButton *button, gpointer user_data);
+
+void            cb_cpu_color_changed (GSMColorButton *widget, gpointer user_data);
+void            cb_mem_color_changed (GSMColorButton *widget, gpointer user_data);
+void            cb_swap_color_changed (GSMColorButton *widget, gpointer user_data);
+void            cb_net_in_color_changed (GSMColorButton *widget, gpointer user_data);
+void            cb_net_out_color_changed (GSMColorButton *widget, gpointer user_data);
+
+void            cb_row_selected (GtkTreeSelection *selection, gpointer data);
+
+gboolean        cb_tree_popup_menu (GtkWidget *widget, gpointer data);
+gboolean        cb_tree_button_pressed (GtkWidget *widget, GdkEventButton *event,
+                                        gpointer data);
+
+void            cb_change_current_page (GtkNotebook *nb,
+                                        gint num, gpointer data);
+void            cb_switch_page (GtkNotebook *nb, GtkWidget *page,
+                                gint num, gpointer data);
+
+gint            cb_update_disks (gpointer data);
+gint            cb_user_refresh (GtkAction* action, gpointer data);
+gint            cb_timeout (gpointer data);
+
+void            cb_radio_processes(GtkAction *action,
+                                   GtkRadioAction *current,
+                                   gpointer data);
+
+void            cb_kill_sigstop(GtkAction *action,
+                                gpointer data);
+
+void            cb_kill_sigcont(GtkAction *action,
+                                gpointer data);
+
+#endif /* _PROCMAN_CALLBACKS_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/30.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/30.html new file mode 100644 index 00000000..7bdd1228 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/30.html @@ -0,0 +1,899 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef HAVE_WNCK
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <dirent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk-pixbuf/gdk-pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procstate.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/error.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/file.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/miscutils.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <iostream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <vector><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "prettytable.h"
+#include "defaulttable.h"
+#include "proctable.h"
+#include "util.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+namespace
+{
+  const unsigned APP_ICON_SIZE = 16;
+}
+
+
+PrettyTable::PrettyTable()
+{
+#ifdef HAVE_WNCK
+#ifdef GDK_WINDOWING_X11
+  if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+      WnckScreen* screen = wnck_screen_get_default();
+      g_signal_connect(G_OBJECT(screen), "application_opened",
+		       G_CALLBACK(PrettyTable::on_application_opened), this);
+      g_signal_connect(G_OBJECT(screen), "application_closed",
+	               G_CALLBACK(PrettyTable::on_application_closed), this);
+  }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    // init GIO apps cache
+    std::vector<std::string> dirs = Glib::get_system_data_dirs();
+    for (std::vector<std::string>::iterator it = dirs.begin(); it != dirs.end(); ++it) {
+        std::string path = (*it).append("/applications");
+        Glib::RefPtr<Gio::File> file = Gio::File::create_for_path(path);
+        Glib::RefPtr<Gio::FileMonitor> monitor = file->monitor_directory();
+        monitor->set_rate_limit(1000); // 1 second
+
+        monitor->signal_changed().connect(sigc::mem_fun(this, &PrettyTable::file_monitor_event));
+        monitors[path] = monitor;
+    }
+
+    this->init_gio_app_cache();
+}
+
+
+PrettyTable::~PrettyTable()
+{
+}
+
+#ifdef HAVE_WNCK
+void
+PrettyTable::on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data)
+{
+    PrettyTable * const that = static_cast<PrettyTable*>(data);
+    FILE *f;
+
+    pid_t pid = wnck_application_get_pid(app);
+
+    if (pid == 0)
+        return;
+
+    const char* icon_name = wnck_application_get_icon_name(app);
+
+
+    Glib::RefPtr<Gdk::Pixbuf> icon;
+
+    // Make sure that icon_name is a valid symlink before loading.
+    f = fopen (icon_name, "r");
+    if (f != NULL) {
+        fclose (f);
+        icon = that->theme->load_icon(icon_name, APP_ICON_SIZE);
+    }
+
+    if (not icon) {
+        icon = Glib::wrap(wnck_application_get_icon(app), /* take_copy */ true);
+        icon = icon->scale_simple(APP_ICON_SIZE, APP_ICON_SIZE, Gdk::INTERP_HYPER);
+    }
+
+    if (not icon)
+        return;
+
+    that->register_application(pid, icon);
+}
+
+void
+PrettyTable::register_application(pid_t pid, Glib::RefPtr<Gdk::Pixbuf> icon)
+{
+  /* If process already exists then set the icon. Otherwise put into hash
+  ** table to be added later */
+  if (ProcInfo* info = ProcInfo::find(pid))
+    {
+      info->set_icon(icon);
+      // move the ref to the map
+      this->apps[pid] = icon;
+      procman_debug("MATEWNCK OK for %u", unsigned(pid));
+    }
+}
+
+void
+PrettyTable::on_application_closed(WnckScreen* screen, WnckApplication* app, gpointer data)
+{
+    pid_t pid = wnck_application_get_pid(app);
+
+    if (pid == 0)
+        return;
+
+    static_cast<PrettyTable*>(data)->unregister_application(pid);
+}
+
+void
+PrettyTable::unregister_application(pid_t pid)
+{
+    IconsForPID::iterator it(this->apps.find(pid));
+
+    if (it != this->apps.end())
+        this->apps.erase(it);
+}
+#endif // HAVE_WNCK
+
+void PrettyTable::init_gio_app_cache ()
+{
+    this->gio_apps.clear();
+
+    Glib::ListHandle<Glib::RefPtr<Gio::AppInfo>> registered_apps = Gio::AppInfo::get_all();
+    for (Glib::ListHandle<Glib::RefPtr<Gio::AppInfo>>::const_iterator it = registered_apps.begin(); it != registered_apps.end(); ++it) {
+        Glib::RefPtr<Gio::AppInfo> app = *it;
+        std::string executable = app->get_executable();
+        if (executable != "sh" && executable != "env")
+            this->gio_apps[executable] = app;
+    }
+}
+
+void PrettyTable::file_monitor_event(Glib::RefPtr<Gio::File>,
+                                     Glib::RefPtr<Gio::File>,
+                                     Gio::FileMonitorEvent)
+{
+  this->init_gio_app_cache();
+}
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_theme(const ProcInfo &info)
+{
+    return this->theme->load_icon(info.name, APP_ICON_SIZE);
+}
+
+
+bool PrettyTable::get_default_icon_name(const string &cmd, string &name)
+{
+    for (size_t i = 0; i != G_N_ELEMENTS(default_table); ++i) {
+        if (default_table[i].command->match(cmd)) {
+            name = default_table[i].icon;
+            return true;
+        }
+    }
+
+    return false;
+}
+
+/*
+  Try to get an icon from the default_table
+  If it's not in defaults, try to load it.
+  If there is no default for a command, store NULL in defaults
+  so we don't have to lookup again.
+*/
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_default(const ProcInfo &info)
+{
+    Glib::RefPtr<Gdk::Pixbuf> pix;
+    string name;
+
+    if (this->get_default_icon_name(info.name, name)) {
+        IconCache::iterator it(this->defaults.find(name));
+
+        if (it == this->defaults.end()) {
+            pix = this->theme->load_icon(name, APP_ICON_SIZE);
+            if (pix)
+                this->defaults[name] = pix;
+            } else
+                pix = it->second;
+    }
+
+    return pix;
+}
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_gio(const ProcInfo &info)
+{
+    gchar **cmdline = g_strsplit(info.name, " ", 2);
+    const gchar *executable = cmdline[0];
+    Glib::RefPtr<Gdk::Pixbuf> icon;
+
+    if (executable) {
+        Glib::RefPtr<Gio::AppInfo> app = this->gio_apps[executable];
+        Glib::RefPtr<Gio::Icon> gicon;
+
+        if (app)
+          gicon = app->get_icon();
+
+        if (gicon)
+          icon = this->theme->load_gicon(gicon, APP_ICON_SIZE, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
+    }
+
+    g_strfreev(cmdline);
+    return icon;
+}
+
+#ifdef HAVE_WNCK
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_wnck(const ProcInfo &info)
+{
+    Glib::RefPtr<Gdk::Pixbuf> icon;
+
+    IconsForPID::iterator it(this->apps.find(info.pid));
+
+    if (it != this->apps.end())
+        icon = it->second;
+
+    return icon;
+}
+#endif
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_name(const ProcInfo &info)
+{
+    return this->theme->load_icon(info.name, APP_ICON_SIZE);
+}
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_dummy(const ProcInfo &)
+{
+    return this->theme->load_icon("application-x-executable", APP_ICON_SIZE);
+}
+
+
+namespace
+{
+    bool has_kthreadd()
+    {
+        glibtop_proc_state buf;
+        glibtop_get_proc_state(&buf, 2);
+
+        return buf.cmd == string("kthreadd");
+    }
+
+    // @pre: has_kthreadd
+    bool is_kthread(const ProcInfo &info)
+    {
+        return info.pid == 2 or info.ppid == 2;
+    }
+}
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_for_kernel(const ProcInfo &info)
+{
+    if (is_kthread(info))
+        return this->theme->load_icon("applications-system", APP_ICON_SIZE);
+
+    return Glib::RefPtr<Gdk::Pixbuf>();
+}
+
+
+
+void
+PrettyTable::set_icon(ProcInfo &info)
+{
+    typedef Glib::RefPtr<Gdk::Pixbuf>
+        (PrettyTable::*Getter)(const ProcInfo &);
+
+    static std::vector<Getter> getters;
+
+    if (getters.empty())
+    {
+        getters.push_back(&PrettyTable::get_icon_from_gio);
+#ifdef HAVE_WNCK
+        getters.push_back(&PrettyTable::get_icon_from_wnck);
+#endif
+        getters.push_back(&PrettyTable::get_icon_from_theme);
+        getters.push_back(&PrettyTable::get_icon_from_default);
+        getters.push_back(&PrettyTable::get_icon_from_name);
+        if (has_kthreadd())
+        {
+            procman_debug("kthreadd is running with PID 2");
+            getters.push_back(&PrettyTable::get_icon_for_kernel);
+        }
+        getters.push_back(&PrettyTable::get_icon_dummy);
+    }
+
+    Glib::RefPtr<Gdk::Pixbuf> icon;
+
+    for (size_t i = 0; not icon and i < getters.size(); ++i) {
+        try {
+            icon = (this->*getters[i])(info);
+        }
+        catch (std::exception& e) {
+            g_warning("Failed to load icon for %s(%u) : %s", info.name, info.pid, e.what());
+            continue;
+        }
+        catch (Glib::Exception& e) {
+            g_warning("Failed to load icon for %s(%u) : %s", info.name, info.pid, e.what().c_str());
+            continue;
+        }
+    }
+
+    info.set_icon(icon);
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/31.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/31.html new file mode 100644 index 00000000..d8618dcb --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/31.html @@ -0,0 +1,331 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
#ifndef _PROCMAN_DEFAULTTABLE_H_
+#define _PROCMAN_DEFAULTTABLE_H_
+
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/refptr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/regex.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+/* This file contains prettynames and icons for well-known applications, that by default has no .desktop entry */
+
+struct PrettyTableItem
+{
+    Glib::RefPtr<Glib::Regex> command;
+    std::string icon;
+
+PrettyTableItem(const std::string& a_command, const std::string& a_icon)
+: command(Glib::Regex::create("^(" + a_command + ")$")),
+        icon(a_icon)
+    { }
+};
+
+#define ITEM PrettyTableItem
+
+static const PrettyTableItem default_table[] = {
+    ITEM("(ba|z|tc|c|k)?sh", "utilities-terminal"),
+    ITEM("(k|sys|u)logd|logger", "internet-news-reader"),
+    ITEM("X(org)?", "display"),
+    ITEM("apache2?|httpd|lighttpd", "internet-web-browser"),
+    ITEM("atd|cron|CRON|ntpd", "date"),
+    ITEM("cupsd|lpd?", "printer"),
+    ITEM("cvsd|mtn|git|svn", "file-manager"),
+    ITEM("evolution.*", "internet-mail"),
+    ITEM("famd|gam_server", "file-manager"),
+    ITEM("getty", "input-keyboard"),
+    ITEM("gdb|((gcc|g\\+\\+)(-.*)?)|ar|ld|make", "applications-development"),
+    ITEM("marco|metacity", "gnome-window-manager"),
+    ITEM("sendmail|exim\\d?", "internet-mail"),
+    ITEM("squid", "proxy"),
+    ITEM("ssh(d|-agent)", "ssh-askpass-gnome"),
+    ITEM("top|vmstat", "system-monitor"),
+    ITEM("vim?", "vim"),
+    ITEM("x?inetd", "internet-web-browser"),
+    ITEM("vino.*", "gnome-remote-desktop")
+};
+
+#undef ITEM
+
+#endif /* _PROCMAN_DEFAULTTABLE_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/32.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/32.html new file mode 100644 index 00000000..d34b6a5f --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/32.html @@ -0,0 +1,621 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
/* Procman process actions
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/resource.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procactions.h"
+#include "procman.h"
+#include "proctable.h"
+#include "procdialogs.h"
+#include "callbacks.h"
+
+
+static void
+renice_single_process (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+    const struct ReniceArgs * const args = static_cast<ReniceArgs*>(data);
+
+    ProcInfo *info = NULL;
+    gint error;
+    int saved_errno;
+    gchar *error_msg;
+    GtkWidget *dialog;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+    if (info->nice == args->nice_value)
+        return;
+    error = setpriority (PRIO_PROCESS, info->pid, args->nice_value);
+
+    /* success */
+    if(error != -1) return;
+
+    saved_errno = errno;
+
+    /* need to be root */
+    if(errno == EPERM || errno == EACCES) {
+        gboolean success;
+
+        success = procdialog_create_root_password_dialog (
+            PROCMAN_ACTION_RENICE, args->procdata, info->pid,
+            args->nice_value);
+
+        if(success) return;
+
+        if(errno) {
+            saved_errno = errno;
+        }
+    }
+
+    /* failed */
+    error_msg = g_strdup_printf (
+        _("Cannot change the priority of process with PID %d to %d.\n"
+          "%s"),
+        info->pid, args->nice_value, g_strerror(saved_errno));
+
+    dialog = gtk_message_dialog_new (
+        NULL,
+        GTK_DIALOG_DESTROY_WITH_PARENT,
+        GTK_MESSAGE_ERROR,
+        GTK_BUTTONS_OK,
+        "%s", error_msg);
+
+    gtk_dialog_run (GTK_DIALOG (dialog));
+    gtk_widget_destroy (dialog);
+    g_free (error_msg);
+}
+
+
+void
+renice (ProcData *procdata, int nice)
+{
+    struct ReniceArgs args = { procdata, nice };
+
+    /* EEEK - ugly hack - make sure the table is not updated as a crash
+    ** occurs if you first kill a process and the tree node is removed while
+    ** still in the foreach function
+    */
+    g_source_remove(procdata->timeout);
+
+    gtk_tree_selection_selected_foreach(procdata->selection, renice_single_process,
+                                        &args);
+
+    procdata->timeout = g_timeout_add(procdata->config.update_interval,
+                                      cb_timeout,
+                                      procdata);
+
+    proctable_update (procdata);
+}
+
+
+
+
+static void
+kill_single_process (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+    const struct KillArgs * const args = static_cast<KillArgs*>(data);
+    char *error_msg;
+    ProcInfo *info;
+    int error;
+    int saved_errno;
+    GtkWidget *dialog;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    error = kill (info->pid, args->signal);
+
+    /* success */
+    if(error != -1) return;
+
+    saved_errno = errno;
+
+    /* need to be root */
+    if(errno == EPERM) {
+        gboolean success;
+
+        success = procdialog_create_root_password_dialog (
+            PROCMAN_ACTION_KILL, args->procdata, info->pid,
+            args->signal);
+
+        if(success) return;
+
+        if(errno) {
+            saved_errno = errno;
+        }
+    }
+
+    /* failed */
+    error_msg = g_strdup_printf (
+        _("Cannot kill process with PID %d with signal %d.\n"
+          "%s"),
+        info->pid, args->signal, g_strerror(saved_errno));
+
+    dialog = gtk_message_dialog_new (
+        NULL,
+        GTK_DIALOG_DESTROY_WITH_PARENT,
+        GTK_MESSAGE_ERROR,
+        GTK_BUTTONS_OK,
+        "%s", error_msg);
+
+    gtk_dialog_run (GTK_DIALOG (dialog));
+    gtk_widget_destroy (dialog);
+    g_free (error_msg);
+}
+
+
+void
+kill_process (ProcData *procdata, int sig)
+{
+    struct KillArgs args = { procdata, sig };
+
+    /* EEEK - ugly hack - make sure the table is not updated as a crash
+    ** occurs if you first kill a process and the tree node is removed while
+    ** still in the foreach function
+    */
+    g_source_remove (procdata->timeout);
+
+    gtk_tree_selection_selected_foreach (procdata->selection, kill_single_process,
+                                         &args);
+
+    procdata->timeout = g_timeout_add (procdata->config.update_interval,
+                                       cb_timeout,
+                                       procdata);
+    proctable_update (procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/33.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/33.html new file mode 100644 index 00000000..41c754fc --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/33.html @@ -0,0 +1,1417 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
/* Procman - dialogs
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procdialogs.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "procactions.h"
+#include "util.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "procman_gksu.h"
+#include "procman_pkexec.h"
+#include "cgroups.h"
+
+#define GET_WIDGET(x) GTK_WIDGET(gtk_builder_get_object(builder, x))
+
+static GtkWidget *renice_dialog = NULL;
+static GtkWidget *prefs_dialog = NULL;
+static gint new_nice_value = 0;
+
+
+static void
+kill_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    struct KillArgs *kargs = static_cast<KillArgs*>(data);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    if (id == GTK_RESPONSE_OK)
+        kill_process (kargs->procdata, kargs->signal);
+
+    g_free (kargs);
+}
+
+void
+procdialog_create_kill_dialog (ProcData *procdata, int signal)
+{
+    GtkWidget *kill_alert_dialog;
+    gchar *primary, *secondary, *button_text;
+    struct KillArgs *kargs;
+
+    kargs = g_new(KillArgs, 1);
+    kargs->procdata = procdata;
+    kargs->signal = signal;
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if ( selected_count == 1 ) {
+        ProcInfo *selected_process = NULL;
+        // get the last selected row
+        gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &selected_process);
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing single process*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        } else {
+            /*xgettext: primary alert message for ending single process*/
+            primary = g_strdup_printf (_("Are you sure you want to end the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        }
+    } else {
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the %d selected processes?"),
+                                       selected_count);
+        } else {
+            /*xgettext: primary alert message for ending multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to end the %d selected processes?"),
+                                       selected_count);
+
+        }
+    }
+
+    if ( signal == SIGKILL ) {
+        /*xgettext: secondary alert message*/
+        secondary = _("Killing a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be killed.");
+        button_text = ngettext("_Kill Process", "_Kill Processes", selected_count);
+    } else {
+        /*xgettext: secondary alert message*/
+        secondary = _("Ending a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be ended.");
+        button_text = ngettext("_End Process", "_End Processes", selected_count);
+    }
+
+    kill_alert_dialog = gtk_message_dialog_new (GTK_WINDOW (procdata->app),
+                                                static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
+                                                GTK_MESSAGE_WARNING,
+                                                GTK_BUTTONS_NONE,
+                                                "%s",
+                                                primary);
+    g_free (primary);
+
+    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (kill_alert_dialog),
+                                              "%s",
+                                              secondary);
+
+    gtk_dialog_add_buttons (GTK_DIALOG (kill_alert_dialog),
+                            "gtk-cancel", GTK_RESPONSE_CANCEL,
+                            button_text, GTK_RESPONSE_OK,
+                            NULL);
+
+    gtk_dialog_set_default_response (GTK_DIALOG (kill_alert_dialog),
+                                     GTK_RESPONSE_CANCEL);
+
+    g_signal_connect (G_OBJECT (kill_alert_dialog), "response",
+                      G_CALLBACK (kill_dialog_button_pressed), kargs);
+
+    gtk_widget_show_all (kill_alert_dialog);
+}
+
+static void
+renice_scale_changed (GtkAdjustment *adj, gpointer data)
+{
+    GtkWidget *label = GTK_WIDGET (data);
+
+    new_nice_value = int(gtk_adjustment_get_value (adj));
+    gchar* text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (new_nice_value));
+    gtk_label_set_text (GTK_LABEL (label), text);
+    g_free(text);
+
+}
+
+static void
+renice_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (id == 100) {
+        if (new_nice_value == -100)
+            return;
+        renice(procdata, new_nice_value);
+    }
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+    renice_dialog = NULL;
+}
+
+void
+procdialog_create_renice_dialog (ProcData *procdata)
+{
+    ProcInfo  *info;
+    GtkWidget *dialog = NULL;
+    GtkWidget *dialog_vbox;
+    GtkWidget *vbox;
+    GtkWidget *label;
+    GtkWidget *priority_label;
+    GtkWidget *grid;
+    GtkAdjustment *renice_adj;
+    GtkWidget *hscale;
+    GtkWidget *button;
+    GtkWidget *icon;
+    gchar     *text;
+    gchar     *dialog_title;
+
+    if (renice_dialog)
+        return;
+
+    gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &info);
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if (!info)
+        return;
+
+    if ( selected_count == 1 ) {
+        dialog_title = g_strdup_printf (_("Change Priority of Process “%s†(PID: %u)"),
+                                        info->name, info->pid);
+    } else {
+        dialog_title = g_strdup_printf (_("Change Priority of %d Selected Processes"),
+                                        selected_count);
+    }
+
+    dialog = gtk_dialog_new_with_buttons (dialog_title, NULL,
+                                          GTK_DIALOG_DESTROY_WITH_PARENT,
+                                          "gtk-cancel", GTK_RESPONSE_CANCEL,
+                                          NULL);
+    g_free (dialog_title);
+
+    renice_dialog = dialog;
+    gtk_window_set_resizable (GTK_WINDOW (renice_dialog), FALSE);
+    gtk_container_set_border_width (GTK_CONTAINER (renice_dialog), 5);
+
+    button = gtk_button_new_with_mnemonic (_("Change _Priority"));
+    gtk_widget_set_can_default (button, TRUE);
+
+    icon = gtk_image_new_from_icon_name ("gtk-apply", GTK_ICON_SIZE_BUTTON);
+    gtk_button_set_image (GTK_BUTTON (button), icon);
+
+    gtk_dialog_add_action_widget (GTK_DIALOG (renice_dialog), button, 100);
+    gtk_dialog_set_default_response (GTK_DIALOG (renice_dialog), 100);
+    new_nice_value = -100;
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+    gtk_box_set_spacing (GTK_BOX (dialog_vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), vbox, TRUE, TRUE, 0);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+
+    grid = gtk_grid_new ();
+    gtk_grid_set_column_spacing (GTK_GRID(grid), 12);
+    gtk_grid_set_row_spacing (GTK_GRID(grid), 6);
+    gtk_box_pack_start (GTK_BOX (vbox), grid, TRUE, TRUE, 0);
+
+    label = gtk_label_new_with_mnemonic (_("_Nice value:"));
+    gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 2);
+
+    renice_adj = gtk_adjustment_new (info->nice, RENICE_VAL_MIN, RENICE_VAL_MAX, 1, 1, 0);
+    new_nice_value = 0;
+    hscale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, renice_adj);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), hscale);
+    gtk_scale_set_digits (GTK_SCALE (hscale), 0);
+    gtk_widget_set_hexpand (hscale, TRUE);
+    gtk_grid_attach (GTK_GRID (grid), hscale, 1, 0, 1, 1);
+    text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (info->nice));
+    priority_label = gtk_label_new (text);
+    gtk_grid_attach (GTK_GRID (grid), priority_label, 1, 1, 1, 1);
+    g_free(text);
+
+    text = g_strconcat("<small><i><b>", _("Note:"), "</b> ",
+        _("The priority of a process is given by its nice value. A lower nice value corresponds to a higher priority."),
+        "</i></small>", NULL);
+    label = gtk_label_new (_(text));
+    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+    g_free (text);
+
+    g_signal_connect (G_OBJECT (dialog), "response",
+                      G_CALLBACK (renice_dialog_button_pressed), procdata);
+    g_signal_connect (G_OBJECT (renice_adj), "value_changed",
+                      G_CALLBACK (renice_scale_changed), priority_label);
+
+    gtk_widget_show_all (dialog);
+
+
+}
+
+static void
+prefs_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    if (id == GTK_RESPONSE_HELP)
+    {
+        GError* error = 0;
+        if (!g_app_info_launch_default_for_uri("help:mate-system-monitor/mate-system-monitor-prefs", NULL, &error))
+        {
+            g_warning("Could not display preferences help : %s", error->message);
+            g_error_free(error);
+        }
+    }
+    else
+    {
+        gtk_widget_destroy (GTK_WIDGET (dialog));
+        prefs_dialog = NULL;
+    }
+}
+
+
+class SpinButtonUpdater
+{
+public:
+    SpinButtonUpdater(const string& key)
+        : key(key)
+    { }
+
+    static gboolean callback(GtkWidget *widget, GdkEventFocus *event, gpointer data)
+    {
+        SpinButtonUpdater* updater = static_cast<SpinButtonUpdater*>(data);
+        gtk_spin_button_update(GTK_SPIN_BUTTON(widget));
+        updater->update(GTK_SPIN_BUTTON(widget));
+        return FALSE;
+    }
+
+private:
+
+    void update(GtkSpinButton* spin)
+    {
+        int new_value = int(1000 * gtk_spin_button_get_value(spin));
+        g_settings_set_int(ProcData::get_instance()->settings,
+                           this->key.c_str(), new_value);
+
+        procman_debug("set %s to %d", this->key.c_str(), new_value);
+    }
+
+    const string key;
+};
+
+
+static void
+field_toggled (const gchar *child_schema, GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+    GtkTreeIter iter;
+    GtkTreeViewColumn *column;
+    gboolean toggled;
+    GSettings *settings = g_settings_get_child (ProcData::get_instance()->settings, child_schema);
+    gchar *key;
+    int id;
+
+    if (!path)
+        return;
+
+    gtk_tree_model_get_iter (model, &iter, path);
+
+    gtk_tree_model_get (model, &iter, 2, &column, -1);
+    toggled = gtk_cell_renderer_toggle_get_active (cell);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, !toggled, -1);
+    gtk_tree_view_column_set_visible (column, !toggled);
+
+    id = gtk_tree_view_column_get_sort_column_id (column);
+
+    key = g_strdup_printf ("col-%d-visible", id);
+    g_settings_set_boolean (settings, key, !toggled);
+    g_free (key);
+
+    gtk_tree_path_free (path);
+}
+
+static void
+proc_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("proctree", cell, path_str, data);
+}
+
+static void
+disk_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("disktreenew", cell, path_str, data);
+}
+
+static void
+create_field_page(GtkBuilder* builder, GtkWidget *tree, const gchar *widgetname)
+{
+    GtkTreeView *treeview;
+    GList *it, *columns;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;<--- Shadowed declaration
+    GtkCellRenderer *cell;
+    gchar *full_widgetname;
+
+    full_widgetname = g_strdup_printf ("%s_columns", widgetname);
+    treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, full_widgetname));
+    g_free (full_widgetname);
+
+    model = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER);
+
+    gtk_tree_view_set_model (GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(model));
+    g_object_unref (G_OBJECT (model));
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_toggle_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "active", 0,
+                                         NULL);
+
+    if (g_strcmp0 (widgetname, "proctree") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (proc_field_toggled), model);
+    else if (g_strcmp0 (widgetname, "disktreenew") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (disk_field_toggled), model);
+
+    gtk_tree_view_column_set_clickable (column, TRUE);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "text", 1,
+                                         NULL);
+
+    gtk_tree_view_column_set_title (column, "Not Shown");
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    for(it = columns; it; it = it->next)
+    {
+        GtkTreeViewColumn *column = static_cast<GtkTreeViewColumn*>(it->data);<--- Shadow variable
+        GtkTreeIter iter;
+        const gchar *title;
+        gboolean visible;
+        gint column_id;
+
+        title = gtk_tree_view_column_get_title (column);
+        if (!title)
+            title = _("Icon");
+
+        column_id = gtk_tree_view_column_get_sort_column_id(column);
+        if ((column_id == COL_CGROUP) && (!cgroups_enabled()))
+            continue;
+
+        if ((column_id == COL_UNIT ||
+             column_id == COL_SESSION ||
+             column_id == COL_SEAT ||
+             column_id == COL_OWNER)
+#ifdef HAVE_SYSTEMD
+            && !LOGIND_RUNNING()
+#endif
+                )
+            continue;
+
+        visible = gtk_tree_view_column_get_visible (column);
+
+        gtk_list_store_append (model, &iter);
+        gtk_list_store_set (model, &iter, 0, visible, 1, title, 2, column,-1);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procdialog_create_preferences_dialog (ProcData *procdata)
+{
+    typedef SpinButtonUpdater SBU;
+
+    static SBU interval_updater("update-interval");
+    static SBU graph_interval_updater("graph-update-interval");
+    static SBU disks_interval_updater("disks-interval");
+
+    GtkWidget *notebook;
+    GtkAdjustment *adjustment;
+    GtkWidget *spin_button;
+    GtkWidget *check_button;
+    GtkWidget *smooth_button;
+    GtkBuilder *builder;
+    gfloat update;
+
+    if (prefs_dialog)
+        return;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/preferences.ui");
+
+    prefs_dialog = GET_WIDGET("preferences_dialog");
+    notebook = GET_WIDGET("notebook");
+    spin_button = GET_WIDGET("processes_interval_spinner");
+
+    update = (gfloat) procdata->config.update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0,
+                                   MIN_UPDATE_INTERVAL / 1000,
+                                   MAX_UPDATE_INTERVAL / 1000,
+                                   0.25,
+                                   1.0,
+                                   0);
+
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK (SBU::callback), &interval_updater);
+
+    smooth_button = GET_WIDGET("smooth_button");
+    g_settings_bind(procdata->settings, SmoothRefresh::KEY.c_str(), smooth_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    check_button = GET_WIDGET("check_button");
+    g_settings_bind(procdata->settings, "kill-dialog", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    GtkWidget *solaris_button = GET_WIDGET("solaris_button");
+    g_settings_bind(procdata->settings, procman::settings::solaris_mode.c_str(), solaris_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->tree, "proctree");
+
+    update = (gfloat) procdata->config.graph_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0, 0.25,
+                                                      100.0, 0.25, 1.0, 0);
+
+    spin_button = GET_WIDGET("resources_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &graph_interval_updater);
+
+    GtkWidget *bits_button = GET_WIDGET("bits_button");
+    g_settings_bind(procdata->settings, procman::settings::network_in_bits.c_str(), bits_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+
+    update = (gfloat) procdata->config.disks_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new (update / 1000.0, 1.0,
+                                                       100.0, 1.0, 1.0, 0);
+
+    spin_button = GET_WIDGET("devices_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &disks_interval_updater);
+
+    check_button = GET_WIDGET("all_devices_check");
+    g_settings_bind(procdata->settings, "show-all-fs", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->disk_list, "disktreenew");
+
+    gtk_widget_show_all (prefs_dialog);
+    g_signal_connect (G_OBJECT (prefs_dialog), "response",
+                       G_CALLBACK (prefs_dialog_button_pressed), procdata);
+
+    switch (procdata->config.current_tab) {
+    case PROCMAN_TAB_SYSINFO:
+    case PROCMAN_TAB_PROCESSES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
+        break;
+    case PROCMAN_TAB_RESOURCES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 1);
+        break;
+    case PROCMAN_TAB_DISKS:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 2);
+        break;
+    }
+
+    gtk_builder_connect_signals (builder, NULL);
+    g_object_unref (G_OBJECT (builder));
+}
+
+
+static char *
+procman_action_to_command(ProcmanActionType type,
+                          gint pid,
+                          gint extra_value)
+{
+    switch (type) {
+    case PROCMAN_ACTION_KILL:
+           return g_strdup_printf("kill -s %d %d", extra_value, pid);
+    case PROCMAN_ACTION_RENICE:
+        return g_strdup_printf("renice %d %d", extra_value, pid);
+    default:
+        g_assert_not_reached();
+    }
+}
+
+
+/*
+ * type determines whether if dialog is for killing process or renice.
+ * type == PROCMAN_ACTION_KILL,   extra_value -> signal to send
+ * type == PROCMAN_ACTION_RENICE, extra_value -> new priority.
+ */
+gboolean
+procdialog_create_root_password_dialog(ProcmanActionType type,
+                                       ProcData *procdata,
+                                       gint pid,
+                                       gint extra_value)
+{
+    char * command;
+    gboolean ret = FALSE;
+
+    command = procman_action_to_command(type, pid, extra_value);
+
+    procman_debug("Trying to run '%s' as root", command);
+
+    if (procman_has_pkexec())
+        ret = procman_pkexec_create_root_password_dialog(command);
+    else if (procman_has_gksu())
+        ret = procman_gksu_create_root_password_dialog(command);
+
+    g_free(command);
+    return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/34.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/34.html new file mode 100644 index 00000000..b9fac436 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/34.html @@ -0,0 +1,261 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
#ifndef H_MATE_SYSTEM_MONITOR_GKSU_H_1132171928
+#define H_MATE_SYSTEM_MONITOR_GKSU_H_1132171928
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+gboolean
+procman_gksu_create_root_password_dialog(const char * command);
+
+gboolean
+procman_has_gksu(void) G_GNUC_CONST;
+
+#endif /* H_MATE_SYSTEM_MONITOR_GKSU_H_1132171928 */
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/35.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/35.html new file mode 100644 index 00000000..a61896ec --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/35.html @@ -0,0 +1,261 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
#ifndef _PROCMAN_PKEXEC_H_
+#define _PROCMAN_PKEXEC_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+gboolean
+procman_pkexec_create_root_password_dialog(const char *command);
+
+gboolean
+procman_has_pkexec(void) G_GNUC_CONST;
+
+#endif /* _PROCMAN_PKEXEC_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/36.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/36.html new file mode 100644 index 00000000..f3d2b88d --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/36.html @@ -0,0 +1,1109 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/close.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/sysinfo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman-app.h"
+#include "procman.h"
+#include "interface.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "argv.h"
+#include "util.h"
+
+static void
+mount_changed(const Glib::RefPtr<Gio::Mount>&)
+{
+    cb_update_disks(ProcData::get_instance());
+}
+
+
+static void
+init_volume_monitor(ProcData *procdata)
+{
+    using namespace Gio;
+    using namespace Glib;
+
+    RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+    monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
+}
+
+static gboolean
+has_key (gchar **keys, const gchar *key)
+{
+    gchar **loop = keys;
+
+    while (*loop) {
+        if (!strcmp (*loop++, key))
+            return TRUE;
+    }
+
+    return FALSE;
+}
+
+static void
+tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_tree = g_settings_get_boolean(settings, key);
+
+    g_object_set(G_OBJECT(procdata->tree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
+    proctable_update (procdata);
+}
+
+
+static void
+network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
+    // force scale to be redrawn
+    procdata->net_graph->clear_background();
+}
+
+static void
+view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.whose_process = g_settings_get_int (settings, key);
+    procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2);
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "kill-dialog")) {
+        procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
+    }
+}
+
+static void
+timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "update-interval")) {
+        procdata->config.update_interval = g_settings_get_int (settings, key);
+        procdata->config.update_interval =
+            MAX (procdata->config.update_interval, 1000);
+
+        procdata->smooth_refresh->reset();
+
+        if(procdata->timeout) {
+            g_source_remove (procdata->timeout);
+            procdata->timeout = g_timeout_add (procdata->config.update_interval,
+                                               cb_timeout,
+                                               procdata);
+        }
+    }
+    else if (g_str_equal (key, "graph-update-interval")){
+        procdata->config.graph_update_interval = g_settings_get_int (settings, key);
+        procdata->config.graph_update_interval =
+            MAX (procdata->config.graph_update_interval,
+                 250);
+        load_graph_change_speed(procdata->cpu_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->mem_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->net_graph,
+                                procdata->config.graph_update_interval);
+    }
+    else if (g_str_equal(key, "disks-interval")) {
+        procdata->config.disks_update_interval = g_settings_get_int (settings, key);
+        procdata->config.disks_update_interval =
+            MAX (procdata->config.disks_update_interval, 1000);
+
+        if(procdata->disk_timeout) {
+            g_source_remove (procdata->disk_timeout);
+            procdata->disk_timeout = \
+                g_timeout_add (procdata->config.disks_update_interval,
+                               cb_update_disks,
+                               procdata);
+        }
+    }
+    else {
+        g_assert_not_reached();
+    }
+}
+
+static void
+color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    gchar *color = g_settings_get_string (settings, key);
+
+    if (g_str_has_prefix (key, "cpu-color")) {
+        for (int i = 0; i < procdata->config.num_cpus; i++) {
+            string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
+            if (cpu_key == key) {
+                gdk_rgba_parse (&procdata->config.cpu_color[i], color);
+                procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
+                break;
+            }
+        }
+    }
+    else if (g_str_equal (key, "mem-color")) {
+        gdk_rgba_parse (&procdata->config.mem_color, color);
+        procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
+    }
+    else if (g_str_equal (key, "swap-color")) {
+        gdk_rgba_parse (&procdata->config.swap_color, color);
+        procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
+    }
+    else if (g_str_equal (key, "net-in-color")) {
+        gdk_rgba_parse (&procdata->config.net_in_color, color);
+        procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
+    }
+    else if (g_str_equal (key, "net-out-color")) {
+        gdk_rgba_parse (&procdata->config.net_out_color, color);
+        procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
+    }
+    else {
+        g_assert_not_reached();
+    }
+    g_free(color);
+}
+
+static void
+show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
+
+    cb_update_disks (data);
+}
+
+static ProcData *
+procman_data_new (GSettings *settings)
+{
+    GSettingsSchema *schema;
+    ProcData *pd;
+    gchar *color;
+    gchar **keys;
+    glibtop_cpu cpu;
+
+    pd = ProcData::get_instance();
+
+    g_settings_get (settings, "window-state", "(iiii)",
+                    &pd->config.width, &pd->config.height,
+                    &pd->config.xpos, &pd->config.ypos);
+
+    pd->config.maximized = g_settings_get_boolean(settings, "maximized");
+
+    pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
+    g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd);
+
+    pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
+    std::string detail_string("changed::" + procman::settings::solaris_mode);
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd);
+
+    pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
+    detail_string = "changed::" + procman::settings::network_in_bits;
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd);
+
+    pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
+    g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd);
+    pd->config.update_interval = g_settings_get_int (settings, "update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.graph_update_interval = g_settings_get_int (settings,
+                                                           "graph-update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",
+                      G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd);
+
+
+    /* show_all_fs */
+    pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
+    g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd);
+
+
+    pd->config.whose_process = g_settings_get_int (settings, "view-as");
+    g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd);
+    pd->config.current_tab = g_settings_get_int (settings, "current-tab");
+
+    glibtop_get_cpu (&cpu);
+    pd->frequency = cpu.frequency;
+    pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
+
+    g_object_get (settings, "settings-schema", &schema, NULL);
+    keys = g_settings_schema_list_keys (schema);
+    g_settings_schema_unref (schema);
+
+    for (int i = 0; i < pd->config.num_cpus; i++) {
+        gchar *key;
+        key = g_strdup_printf ("cpu-color%d", i);
+
+        if (has_key (keys, key))
+            color = g_settings_get_string (settings, key);
+        else
+            color = g_strdup ("#f25915e815e8");
+        detail_string = std::string("changed::") + std::string(key);
+        g_signal_connect (G_OBJECT(settings), detail_string.c_str(),
+                          G_CALLBACK(color_changed_cb), pd);
+        gdk_rgba_parse (&pd->config.cpu_color[i], color);
+        g_free (color);
+        g_free (key);
+    }
+    g_strfreev (keys);
+
+    color = g_settings_get_string (settings, "mem-color");
+    if (!color)
+        color = g_strdup ("#000000ff0082");
+    g_signal_connect (G_OBJECT(settings), "changed::mem-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.mem_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "swap-color");
+    if (!color)
+        color = g_strdup ("#00b6000000ff");
+    g_signal_connect (G_OBJECT(settings), "changed::swap-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.swap_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-in-color");
+    if (!color)
+        color = g_strdup ("#000000f200f2");
+    g_signal_connect (G_OBJECT(settings), "changed::net-in-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_in_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-out-color");
+    if (!color)
+        color = g_strdup ("#00f2000000c1");
+    g_signal_connect (G_OBJECT(settings), "changed::net-out-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_out_color, color);
+    g_free (color);
+
+    /* Sanity checks */
+    GdkDisplay *display;
+    GdkMonitor *monitor;
+    GdkRectangle monitor_geometry;
+
+    display = gdk_display_get_default ();
+    monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
+    if (monitor == NULL) {
+        monitor = gdk_display_get_monitor (display, 0);
+    }
+    gdk_monitor_get_geometry (monitor, &monitor_geometry);
+
+    pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width);
+    pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height);
+    pd->config.update_interval = MAX (pd->config.update_interval, 1000);
+    pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250);
+    pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000);
+    pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2);
+    pd->config.current_tab = CLAMP(pd->config.current_tab,
+                                   PROCMAN_TAB_SYSINFO,
+                                   PROCMAN_TAB_DISKS);
+
+    // delayed initialization as SmoothRefresh() needs ProcData
+    // i.e. we can't call ProcData::get_instance
+    pd->smooth_refresh = new SmoothRefresh(settings);
+
+    pd->terminating = FALSE;
+
+    return pd;
+}
+
+static void
+procman_free_data (ProcData *procdata)
+{
+
+    proctable_free_table (procdata);
+    delete procdata->smooth_refresh;
+}
+
+ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
+{
+    Glib::set_application_name(_("System Monitor"));
+}
+
+Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
+{
+    return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
+}
+
+void ProcmanApp::on_activate()
+{
+    gtk_window_present (GTK_WINDOW (procdata->app));
+}
+
+static void
+set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
+{
+    gtk_notebook_set_current_page(notebook, tab);
+    cb_change_current_page(notebook, tab, procdata);
+}
+
+int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
+{
+    int argc = 0;
+    char** argv = command_line->get_arguments(argc);
+
+    Glib::OptionContext context;
+    context.set_summary(_("A simple process and system monitor."));
+    context.set_ignore_unknown_options(true);
+    procman::OptionGroup option_group;
+    context.set_main_group(option_group);
+
+    try {
+        context.parse(argc, argv);
+    } catch (const Glib::Error& ex) {
+        g_error("Arguments parse error : %s", ex.what().c_str());
+    }
+
+    if (option_group.show_system_tab) {
+        procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_SYSINFO, procdata);
+    } else if (option_group.show_processes_tab) {
+        procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_PROCESSES, procdata);
+    } else if (option_group.show_resources_tab) {
+        procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_RESOURCES, procdata);
+    } else if (option_group.show_file_systems_tab) {
+        procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_DISKS, procdata);
+    }
+
+    on_activate ();
+
+    return 0;
+}
+
+void ProcmanApp::on_startup()
+{
+    Gtk::Application::on_startup();
+
+    GSettings *settings;
+
+    Gtk::Window::set_default_icon_name ("utilities-system-monitor");
+
+    settings = g_settings_new (GSM_GSETTINGS_SCHEMA);
+
+    glibtop_init ();
+
+    procdata = procman_data_new (settings);
+    procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA);
+
+    create_main_window (procdata);
+    init_volume_monitor (procdata);
+
+    Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app));
+    window->show();
+    window->set_name ("mate-system-monitor");
+
+    add_window (*window);
+}
+
+void ProcmanApp::on_shutdown()
+{
+    procman_free_data(procdata);
+    glibtop_close();
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/37.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/37.html new file mode 100644 index 00000000..9a0699dc --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/37.html @@ -0,0 +1,283 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
#ifndef _PROCMAN_PROCMAN_APP_H_
+#define _PROCMAN_PROCMAN_APP_H_
+
+#include <gtkmm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+class ProcmanApp : public Gtk::Application
+{
+    ProcData *procdata;
+protected:
+    ProcmanApp();
+public:
+    static Glib::RefPtr<ProcmanApp> create ();
+protected:
+    virtual void on_activate();
+    virtual int on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line);
+    virtual void on_startup();
+    virtual void on_shutdown();
+};
+
+#endif  /* _PROCMAN_PROCMAN_APP_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/38.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/38.html new file mode 100644 index 00000000..972eeaf8 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/38.html @@ -0,0 +1,671 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtkmm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman-app.h"
+#include "procman.h"
+#include "proctable.h"
+
+ProcData::ProcData()
+    : tree(NULL),
+      cpu_graph(NULL),
+      mem_graph(NULL),
+      net_graph(NULL),
+      selected_process(NULL),
+      timeout(0),
+      disk_timeout(0),
+      cpu_total_time(1),
+      cpu_total_time_last(1)
+{ }
+
+ProcData* ProcData::get_instance()
+{
+    static ProcData instance;
+    return &instance;
+}
+
+gboolean
+procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns, *it;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    sort_col = g_settings_get_int (pt_settings, "sort-col");
+
+    order = static_cast<GtkSortType>(g_settings_get_int (pt_settings, "sort-order"));
+
+    if (sort_col != -1)
+        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
+                                              sort_col,
+                                              order);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        for (it = columns; it; it = it->next)
+        {
+            GtkTreeViewColumn *column;
+            gint width;
+            gboolean visible;
+            int id;
+            gchar *key;
+
+            column = static_cast<GtkTreeViewColumn*>(it->data);
+            id = gtk_tree_view_column_get_sort_column_id (column);
+
+            key = g_strdup_printf ("col-%d-width", id);
+            g_settings_get (pt_settings, key, "i", &width);
+            g_free (key);
+
+            key = g_strdup_printf ("col-%d-visible", id);
+            visible = g_settings_get_boolean (pt_settings, key);
+            g_free (key);
+
+            gtk_tree_view_column_set_visible (column, visible);
+            if (visible) {
+                /* ensure column is really visible */
+                width = MAX(width, 20);
+                gtk_tree_view_column_set_fixed_width(column, width);
+            }
+        }
+
+        GVariant     *value;
+        GVariantIter iter;
+        int          sortIndex;
+
+        GSList *order = NULL;<--- Shadow variable
+
+        value = g_settings_get_value(pt_settings, "columns-order");
+        g_variant_iter_init(&iter, value);
+
+        while (g_variant_iter_loop (&iter, "i", &sortIndex))
+            order = g_slist_append(order, GINT_TO_POINTER(sortIndex));
+
+        proctable_set_columns_order(GTK_TREE_VIEW(tree), order);
+
+        g_variant_unref(value);
+        g_slist_free(order);
+    }
+
+    g_object_unref(pt_settings);
+    pt_settings = NULL;
+
+    g_list_free(columns);
+
+    return TRUE;
+}
+
+void
+procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    if (ProcData::get_instance()->terminating)
+        return;
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    if (gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (model), &sort_col,
+                                              &order)) {
+        g_settings_set_int (pt_settings, "sort-col", sort_col);
+        g_settings_set_int (pt_settings, "sort-order", order);
+    }
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        GSList *order;<--- Shadow variable
+        GSList *order_node;
+        GVariantBuilder *builder;
+        GVariant *order_variant;
+
+        order = proctable_get_columns_order(GTK_TREE_VIEW(tree));
+
+        builder = g_variant_builder_new (G_VARIANT_TYPE ("ai"));
+
+        for (order_node = order; order_node; order_node = order_node->next)
+            g_variant_builder_add(builder, "i", GPOINTER_TO_INT(order_node->data));
+
+        order_variant = g_variant_new("ai", builder);
+        g_settings_set_value(pt_settings, "columns-order", order_variant);
+
+        g_slist_free(order);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procman_save_config (ProcData *data)
+{
+    GSettings *settings = data->settings;
+
+    g_assert(data);
+
+    data->config.maximized = gdk_window_get_state(gtk_widget_get_window (data->app)) & GDK_WINDOW_STATE_MAXIMIZED;
+    if (!data->config.maximized) {
+        // we only want to store/overwrite size and position info with non-maximized state info
+        data->config.width  = gdk_window_get_width (gtk_widget_get_window (data->app));
+        data->config.height = gdk_window_get_height(gtk_widget_get_window (data->app));
+
+        gtk_window_get_position(GTK_WINDOW(data->app), &data->config.xpos, &data->config.ypos);
+
+        g_settings_set (settings, "window-state", "(iiii)",
+                        data->config.width, data->config.height,
+                        data->config.xpos, data->config.ypos);
+    }
+    g_settings_set_boolean (settings, "maximized", data->config.maximized);
+
+    g_settings_set_int (settings, "current-tab", data->config.current_tab);
+}
+
+int
+main (int argc, char *argv[])
+{
+    bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+    textdomain (GETTEXT_PACKAGE);
+    setlocale (LC_ALL, "");
+
+    Glib::RefPtr<ProcmanApp> application = ProcmanApp::create();
+    return application->run (argc, argv);
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/39.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/39.html new file mode 100644 index 00000000..c34d3e03 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/39.html @@ -0,0 +1,303 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "procman_gksu.h"
+
+gboolean
+procman_gksu_create_root_password_dialog (const char *command)
+{
+    gchar *command_line;
+    gboolean success;
+    GError *error = NULL;
+
+    command_line = g_strdup_printf ("gksu '%s'", command);
+    success = g_spawn_command_line_sync (command_line, NULL, NULL, NULL, &error);
+    g_free (command_line);
+
+    if (!success) {
+        g_critical ("Could not run gksu '%s' : %s\n",
+                    command, error->message);
+        g_error_free (error);
+        return FALSE;
+    }
+
+    g_debug ("gksu did fine\n");
+    return TRUE;
+}
+
+gboolean
+procman_has_gksu (void)
+{
+    return g_file_test ("/usr/bin/gksu", G_FILE_TEST_EXISTS);
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/4.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/4.html new file mode 100644 index 00000000..d7329c12 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/4.html @@ -0,0 +1,763 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef _PROCMAN_PROCMAN_H_
+#define _PROCMAN_PROCMAN_H_
+
+#include <glibmm/refptr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <cairo-gobject.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk-pixbuf/gdk-pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <map><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+struct ProcInfo;
+struct ProcData;
+struct LoadGraph;
+
+#include "smooth_refresh.h"
+#include "prettytable.h"
+
+#define GSM_GSETTINGS_SCHEMA "org.mate.system-monitor"
+
+enum
+{
+    ALL_PROCESSES,
+    MY_PROCESSES,
+    ACTIVE_PROCESSES
+};
+
+enum
+{
+    VERY_HIGH_PRIORITY,
+    HIGH_PRIORITY,
+    NORMAL_PRIORITY,
+    LOW_PRIORITY,
+    VERY_LOW_PRIORITY,
+    CUSTOM_PRIORITY
+};
+
+static const unsigned MIN_UPDATE_INTERVAL =   1 * 1000;
+static const unsigned MAX_UPDATE_INTERVAL = 100 * 1000;
+
+enum ProcmanTab
+{
+    PROCMAN_TAB_SYSINFO,
+    PROCMAN_TAB_PROCESSES,
+    PROCMAN_TAB_RESOURCES,
+    PROCMAN_TAB_DISKS
+};
+
+struct ProcConfig
+{
+    gint        width;
+    gint        height;
+    gint        xpos;
+    gint        ypos;
+    gboolean    maximized;
+    gboolean    show_kill_warning;
+    gboolean    show_tree;
+    gboolean    show_all_fs;
+    int         update_interval;
+    int         graph_update_interval;
+    int         disks_update_interval;
+    gint        whose_process;
+    gint        current_tab;
+    GdkRGBA     cpu_color[GLIBTOP_NCPU];
+    GdkRGBA     mem_color;
+    GdkRGBA     swap_color;
+    GdkRGBA     net_in_color;
+    GdkRGBA     net_out_color;
+    GdkRGBA     bg_color;
+    GdkRGBA     frame_color;
+    gint        num_cpus;
+    bool solaris_mode;
+    bool network_in_bits;
+};
+
+struct MutableProcInfo
+{
+MutableProcInfo()
+  : disk_write_bytes_current(0ULL),
+    disk_read_bytes_current(0ULL),
+    disk_write_bytes_total(0ULL),
+    disk_read_bytes_total(0ULL),
+    status(0U)
+    { }
+
+    std::string user;
+
+    gchar wchan[40];
+
+    // all these members are filled with libgtop which uses
+    // guint64 (to have fixed size data) but we don't need more
+    // than an unsigned long (even for 32bit apps on a 64bit
+    // kernel) as these data are amounts, not offsets.
+    gulong vmsize;
+    gulong memres;
+    gulong memshared;
+    gulong memwritable;
+    gulong mem;
+
+#ifdef HAVE_WNCK
+    // wnck gives an unsigned long
+    gulong memxserver;
+#endif
+
+    gulong start_time;
+    guint64 cpu_time;
+    guint64 disk_write_bytes_current;
+    guint64 disk_read_bytes_current;
+    guint64 disk_write_bytes_total;
+    guint64 disk_read_bytes_total;
+    guint status;
+    guint pcpu;
+    gint nice;
+    gchar *cgroup_name;
+
+    gchar *unit;
+    gchar *session;
+    gchar *seat;
+
+    std::string owner;
+};
+
+class ProcInfo
+: public MutableProcInfo
+{
+    /* undefined */ ProcInfo& operator=(const ProcInfo&);
+    /* undefined */ ProcInfo(const ProcInfo&);
+
+    typedef std::map<guint, std::string> UserMap;
+    /* cached username */
+    static UserMap users;
+
+  public:
+
+    // TODO: use a set instead
+    // sorted by pid. The map has a nice property : it is sorted
+    // by pid so this helps a lot when looking for the parent node
+    // as ppid is nearly always < pid.
+    typedef std::map<pid_t, ProcInfo*> List;
+    typedef List::iterator Iterator;
+
+    static List all;
+
+    static ProcInfo* find(pid_t pid);
+    static Iterator begin() { return ProcInfo::all.begin(); }
+    static Iterator end() { return ProcInfo::all.end(); }
+
+    ProcInfo(pid_t pid);
+    ~ProcInfo();
+    // adds one more ref to icon
+    void set_icon(Glib::RefPtr<Gdk::Pixbuf> icon);
+    void set_user(guint uid);
+    std::string lookup_user(guint uid);
+
+    GtkTreeIter      node;
+    cairo_surface_t *surface;
+    gchar           *tooltip;
+    gchar           *name;
+    gchar           *arguments;
+    gchar           *security_context;
+
+    const pid_t      pid;
+    pid_t            ppid;
+    guint            uid;
+
+// private:
+    // tracks cpu time per process keeps growing because if a
+    // ProcInfo is deleted this does not mean that the process is
+    // not going to be recreated on the next update.  For example,
+    // if dependencies + (My or Active), the proclist is cleared
+    // on each update.  This is a workaround
+    static std::map<pid_t, guint64> cpu_times;
+};
+
+struct ProcData
+{
+    // lazy initialization
+    static ProcData* get_instance();
+
+    GtkUIManager    *uimanager;
+    GtkActionGroup    *action_group;
+    GtkWidget    *statusbar;
+    gint        tip_message_cid;
+    GtkWidget    *tree;
+    GtkWidget    *loadavg;
+    GtkWidget    *endprocessbutton;
+    GtkWidget    *popup_menu;
+    GtkWidget    *disk_list;
+    GtkWidget    *notebook;
+    ProcConfig    config;
+    LoadGraph    *cpu_graph;
+    LoadGraph    *mem_graph;
+    LoadGraph    *net_graph;
+    gint        cpu_label_fixed_width;
+    gint        net_label_fixed_width;
+    ProcInfo    *selected_process;
+    GtkTreeSelection *selection;
+    guint        timeout;
+    guint        disk_timeout;
+
+    PrettyTable    pretty_table;
+
+    GSettings       *settings;
+    GtkWidget        *app;
+    GtkUIManager    *menu;
+
+    unsigned    frequency;
+
+    SmoothRefresh  *smooth_refresh;
+
+    guint64 cpu_total_time;
+    guint64 cpu_total_time_last;
+
+    gboolean terminating;
+
+private:
+    ProcData();
+    /* undefined */ ProcData(const ProcData &);
+    /* undefined */ ProcData& operator=(const ProcData &);
+};
+
+void        procman_save_config (ProcData *data);
+void        procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+gboolean    procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+
+struct ReniceArgs
+{
+    ProcData *procdata;
+    int nice_value;
+};
+
+struct KillArgs
+{
+    ProcData *procdata;
+    int signal;
+};
+
+#endif /* _PROCMAN_PROCMAN_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/40.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/40.html new file mode 100644 index 00000000..59cb183e --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/40.html @@ -0,0 +1,303 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman_pkexec.h"
+
+gboolean
+procman_pkexec_create_root_password_dialog (const char *command)
+{
+    gchar *command_line;
+    gboolean success;
+    GError *error = NULL;
+
+    command_line = g_strdup_printf ("pkexec --disable-internal-agent %s/msm-%s",
+                                    PKGLIBEXECDIR, command);
+    success = g_spawn_command_line_sync (command_line, NULL, NULL, NULL, &error);
+    g_free (command_line);
+
+    if (!success) {
+        g_critical ("Could not run pkexec (\"%s\") : %s\n",
+                    command, error->message);
+        g_error_free (error);
+        return FALSE;
+    }
+
+    g_debug ("pkexec did fine\n");
+    return TRUE;
+}
+
+gboolean
+procman_has_pkexec (void)
+{
+    return g_file_test("/usr/bin/pkexec", G_FILE_TEST_EXISTS);
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/41.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/41.html new file mode 100644 index 00000000..a96c88d2 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/41.html @@ -0,0 +1,913 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
/* Process properties dialog
+ * Copyright (C) 2010 Krishnan Parthasarathi <krishnan.parthasarathi@gmail.com>
+ *                    Robert Ancell <robert.ancell@canonical.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procmem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procmap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procstate.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "procproperties.h"
+#include "proctable.h"
+#include "util.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+enum
+{
+    COL_PROP = 0,
+    COL_VAL,
+    NUM_COLS,
+};
+
+typedef struct _proc_arg {
+    const gchar *prop;
+    gchar *val;
+} proc_arg;
+
+static void
+get_process_memory_writable (ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info (ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+static gchar*
+format_memsize(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
+}
+
+static gchar*
+format_size(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size(size);
+}
+
+static void
+fill_proc_properties (GtkWidget *tree, ProcInfo *info)
+{
+    guint i;
+    GtkListStore *store;
+
+    if (!info)
+        return;
+
+    get_process_memory_info(info);
+
+    proc_arg proc_props[] = {
+        { N_("Process Name"), g_strdup_printf("%s", info->name)},
+        { N_("User"), g_strdup_printf("%s (%d)", info->user.c_str(), info->uid)},
+        { N_("Status"), g_strdup(format_process_state(info->status))},
+        { N_("Memory"), format_memsize(info->mem)},
+        { N_("Virtual Memory"), format_memsize(info->vmsize)},
+        { N_("Resident Memory"), format_memsize(info->memres)},
+        { N_("Writable Memory"), format_memsize(info->memwritable)},
+        { N_("Shared Memory"), format_memsize(info->memshared)},
+#ifdef HAVE_WNCK
+        { N_("X Server Memory"), format_memsize(info->memxserver)},
+#endif
+        { N_("Disk Read Total"), format_size(info->disk_read_bytes_total)},
+        { N_("Disk Write Total"), format_size(info->disk_write_bytes_total)},
+        { N_("CPU"), g_strdup_printf("%d%%", info->pcpu)},
+        { N_("CPU Time"), procman::format_duration_for_display(100 * info->cpu_time / ProcData::get_instance()->frequency) },
+        { N_("Started"), procman_format_date_for_display(info->start_time) },
+        { N_("Nice"), g_strdup_printf("%d", info->nice)},
+        { N_("Priority"), g_strdup_printf("%s", procman::get_nice_level(info->nice)) },
+        { N_("ID"), g_strdup_printf("%d", info->pid)},
+        { N_("Security Context"), info->security_context ? g_strdup_printf("%s", info->security_context) : g_strdup(_("N/A"))},
+        { N_("Command Line"), g_strdup_printf("%s", info->arguments)},
+        { N_("Waiting Channel"), g_strdup_printf("%s", info->wchan)},
+        { N_("Control Group"), info->cgroup_name ? g_strdup_printf("%s", info->cgroup_name) : g_strdup(_("N/A"))},
+        { NULL, NULL}
+    };
+
+    store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
+    for (i = 0; proc_props[i].prop; i++) {
+        GtkTreeIter iter;
+
+        if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL(store), &iter, NULL, i)) {
+            gtk_list_store_append(store, &iter);
+            gtk_list_store_set(store, &iter, COL_PROP, _(proc_props[i].prop), -1);
+        }
+
+        gtk_list_store_set(store, &iter, COL_VAL, g_strstrip(proc_props[i].val), -1);
+        g_free(proc_props[i].val);
+    }
+}
+
+static void
+update_procproperties_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    fill_proc_properties(tree, info);
+}
+
+static void
+close_procprop_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    guint timer;
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static GtkWidget *
+create_procproperties_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    model = gtk_list_store_new (NUM_COLS,
+                                G_TYPE_STRING,	/* Property */
+                                G_TYPE_STRING	/* Value */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_COLS; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        column = gtk_tree_view_column_new_with_attributes (NULL,
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tree), FALSE);
+    fill_proc_properties(tree, procdata->selected_process);
+
+    return tree;
+}
+
+static gboolean
+procprop_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_procproperties_dialog (tree);
+
+    return TRUE;
+}
+
+static void
+create_single_procproperties_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                     GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *procpropdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    procpropdialog = gtk_dialog_new_with_buttons (_("Process Properties"), NULL,
+                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                  "gtk-close", GTK_RESPONSE_CLOSE,
+                                                  NULL);
+    gtk_window_set_resizable (GTK_WINDOW (procpropdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (procpropdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (procpropdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (procpropdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("Properties of process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_procproperties_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (procpropdialog), "response",
+                      G_CALLBACK (close_procprop_dialog), tree);
+
+    gtk_widget_show_all (procpropdialog);
+
+    timer = g_timeout_add_seconds (5, procprop_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_procproperties_dialog (tree);
+}
+
+void
+create_procproperties_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_procproperties_dialog,
+                                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/42.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/42.html new file mode 100644 index 00000000..194f1844 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/42.html @@ -0,0 +1,2635 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
/* Procman tree view and process updating
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <cairo-gobject.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gprintf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/loadavg.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/proclist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procstate.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procmem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procmap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/proctime.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procuid.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procargs.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/prockernel.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/swap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <pwd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <set><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <list><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef HAVE_SYSTEMD
+#include <systemd/sd-login.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include "procman.h"
+#include "selection.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "util.h"
+#include "interface.h"
+#include "selinux.h"
+#include "cgroups.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+ProcInfo::UserMap ProcInfo::users;
+ProcInfo::List ProcInfo::all;
+std::map<pid_t, guint64> ProcInfo::cpu_times;
+
+
+ProcInfo* ProcInfo::find(pid_t pid)
+{
+    Iterator it(ProcInfo::all.find(pid));
+    return (it == ProcInfo::all.end() ? NULL : it->second);
+}
+
+void
+get_last_selected (GtkTreeModel *model, GtkTreePath *path,
+           GtkTreeIter *iter, gpointer data)
+{
+    ProcInfo **info = static_cast<ProcInfo**>(data);
+
+    gtk_tree_model_get (model, iter, COL_POINTER, info, -1);
+}
+
+static void
+cb_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "proctree");
+}
+
+static void
+cb_sort_changed (GtkTreeSortable *model, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state (procdata->settings,
+                             GTK_WIDGET (procdata->tree),
+                             "proctree");
+}
+
+
+static GtkTreeViewColumn*
+my_gtk_tree_view_get_column_with_sort_column_id(GtkTreeView *treeview, int id)
+{
+    GList *columns, *it;
+    GtkTreeViewColumn *col = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(it = columns; it; it = it->next)
+    {
+        if(gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(it->data)) == id)
+        {
+            col = static_cast<GtkTreeViewColumn*>(it->data);
+            break;
+        }
+    }
+
+    g_list_free(columns);
+
+    return col;
+}
+
+
+void
+proctable_set_columns_order(GtkTreeView *treeview, GSList *order)
+{
+    GtkTreeViewColumn* last = NULL;
+    GSList *it;
+
+    for(it = order; it; it = it->next)
+    {
+        int id;
+        GtkTreeViewColumn *cur;
+
+        id = GPOINTER_TO_INT(it->data);
+
+        cur = my_gtk_tree_view_get_column_with_sort_column_id(treeview, id);
+
+        if(cur && cur != last)
+        {
+            gtk_tree_view_move_column_after(treeview, cur, last);
+            last = cur;
+        }
+    }
+}
+
+
+GSList*
+proctable_get_columns_order(GtkTreeView *treeview)
+{
+    GList *columns, *col;
+    GSList *order = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(col = columns; col; col = col->next)
+    {
+        int id;
+
+        id = gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(col->data));
+        order = g_slist_prepend(order, GINT_TO_POINTER(id));
+    }
+
+    g_list_free(columns);
+
+    order = g_slist_reverse(order);
+
+    return order;
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "proctree");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_proctable_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+static gboolean
+search_equal_func(GtkTreeModel *model,
+                  gint column,
+                  const gchar *key,
+                  GtkTreeIter *iter,
+                  gpointer search_data)
+{
+    char* name;
+    char* user;
+    gboolean found;
+
+    gtk_tree_model_get(model, iter,
+                       COL_NAME, &name,
+                       COL_USER, &user,
+                       -1);
+
+    found = !((name && strcasestr(name, key))
+              || (user && strcasestr(user, key)));
+
+    g_free(name);
+    g_free(user);
+
+    return found;
+}
+
+
+
+GtkWidget *
+proctable_new (ProcData * const procdata)
+{
+    GtkWidget *proctree;
+    GtkTreeStore *model;
+    GtkTreeSelection *selection;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell_renderer;
+
+    const gchar *titles[] = {
+        N_("Process Name"),
+        N_("User"),
+        N_("Status"),
+        N_("Virtual Memory"),
+        N_("Resident Memory"),
+        N_("Writable Memory"),
+        N_("Shared Memory"),
+        N_("X Server Memory"),
+        /* xgettext:no-c-format */ N_("% CPU"),
+        N_("CPU Time"),
+        N_("Started"),
+        N_("Nice"),
+        N_("ID"),
+        N_("Security Context"),
+        N_("Command Line"),
+        N_("Memory"),
+        /* xgettext: combined noun, the function the process is waiting in, see wchan ps(1) */
+        N_("Waiting Channel"),
+        N_("Control Group"),
+        N_("Unit"),
+        N_("Session"),
+        /* TRANSLATORS: Seat = i.e. the physical seat the session of the process belongs to, only
+	for multi-seat environments. See http://en.wikipedia.org/wiki/Multiseat_configuration */
+        N_("Seat"),
+        N_("Owner"),
+        N_("Disk Read Total"),
+        N_("Disk Write Total"),
+        N_("Disk Read"),
+        N_("Disk Write"),
+        N_("Priority"),
+        NULL,
+        "POINTER"
+    };
+
+    gint i;
+
+    model = gtk_tree_store_new (NUM_COLUMNS,
+                                G_TYPE_STRING,              /* Process Name */
+                                G_TYPE_STRING,              /* User         */
+                                G_TYPE_UINT,                /* Status       */
+                                G_TYPE_ULONG,               /* VM Size      */
+                                G_TYPE_ULONG,               /* Resident Memory */
+                                G_TYPE_ULONG,               /* Writable Memory */
+                                G_TYPE_ULONG,               /* Shared Memory */
+                                G_TYPE_ULONG,               /* X Server Memory */
+                                G_TYPE_UINT,                /* % CPU        */
+                                G_TYPE_UINT64,              /* CPU time     */
+                                G_TYPE_ULONG,               /* Started      */
+                                G_TYPE_INT,                 /* Nice         */
+                                G_TYPE_UINT,                /* ID           */
+                                G_TYPE_STRING,              /* Security Context */
+                                G_TYPE_STRING,              /* Arguments    */
+                                G_TYPE_ULONG,               /* Memory       */
+                                G_TYPE_STRING,              /* wchan        */
+                                G_TYPE_STRING,              /* Cgroup       */
+                                G_TYPE_STRING,              /* Unit         */
+                                G_TYPE_STRING,              /* Session      */
+                                G_TYPE_STRING,              /* Seat         */
+                                G_TYPE_STRING,              /* Owner        */
+                                G_TYPE_UINT64,              /* Disk read total */
+                                G_TYPE_UINT64,              /* Disk write total*/
+                                G_TYPE_UINT64,              /* Disk read    */
+                                G_TYPE_UINT64,              /* Disk write   */
+                                G_TYPE_STRING,              /* Priority     */
+                                CAIRO_GOBJECT_TYPE_SURFACE, /* Icon         */
+                                G_TYPE_POINTER,             /* ProcInfo     */
+                                G_TYPE_STRING               /* Sexy tooltip */
+        );
+
+    proctree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (proctree), COL_TOOLTIP);
+    g_object_set(G_OBJECT(proctree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+    gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (proctree),
+                                         search_equal_func,
+                                         NULL,
+                                         NULL);
+    g_object_unref (G_OBJECT (model));
+
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree));
+    gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+
+    column = gtk_tree_view_column_new ();
+
+    cell_renderer = gtk_cell_renderer_pixbuf_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "surface", COL_SURFACE,
+                                         NULL);
+
+    cell_renderer = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "text", COL_NAME,
+                                         NULL);
+    gtk_tree_view_column_set_title (column, _(titles[0]));
+    gtk_tree_view_column_set_sort_column_id (column, COL_NAME);
+    gtk_tree_view_column_set_resizable (column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+    gtk_tree_view_column_set_min_width (column, 20);
+    gtk_tree_view_column_set_reorderable (column, TRUE);
+    g_signal_connect(G_OBJECT(column), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (proctree), column);
+    gtk_tree_view_set_expander_column (GTK_TREE_VIEW (proctree), column);
+
+
+    for (i = COL_USER; i <= COL_PRIORITY; i++) {
+
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+#ifndef HAVE_WNCK
+        if (i == COL_MEMXSERVER) {
+          continue;
+        }
+#endif
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(proctree), col);
+
+        // type
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_CPU_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::duration_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_START_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::time_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_STATUS:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::status_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::io_rate_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_PRIORITY:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::priority_cell_data_func,
+                                                        GUINT_TO_POINTER(COL_NICE),
+                                                        NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+        }
+
+        // sorting
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+            case COL_CPU:
+            case COL_CPU_TIME:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_START_TIME:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::number_compare_func, GUINT_TO_POINTER(i),
+                                                NULL);
+                break;
+            case COL_PRIORITY:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::priority_compare_func,
+                                                GUINT_TO_POINTER(COL_NICE), NULL);
+                break;
+            default:
+                break;
+        }
+
+        // xalign
+        switch(i)
+        {
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMWRITABLE:
+            case COL_MEMSHARED:
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_CPU:
+            case COL_NICE:
+            case COL_PID:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_CPU_TIME:
+            case COL_MEM:
+                g_object_set(G_OBJECT(cell), "xalign", 1.0f, NULL);
+                break;
+        }
+
+        // sizing
+        switch (i) {
+            case COL_ARGS:
+                gtk_tree_view_column_set_min_width(col, 150);
+                break;
+            default:
+                gtk_tree_view_column_set_min_width(col, 20);
+                break;
+        }
+    }
+
+    procdata->tree = proctree;
+
+    procman_get_tree_state (procdata->settings, proctree, "proctree");
+
+    /* Override column settings by hiding this column if it's meaningless: */
+    if (!can_show_security_context_column ()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id (GTK_TREE_VIEW (proctree), COL_SECURITYCONTEXT);
+        gtk_tree_view_column_set_visible (column, FALSE);
+    }
+
+    if (!cgroups_enabled()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), COL_CGROUP);
+        gtk_tree_view_column_set_visible(column, FALSE);
+    }
+
+#ifdef HAVE_SYSTEMD
+    if (!LOGIND_RUNNING())
+#endif
+    {
+        for (i = COL_UNIT; i <= COL_OWNER; i++) {
+            column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), i);
+            gtk_tree_view_column_set_visible(column, FALSE);
+        }
+    }
+
+    g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree))),
+                      "changed",
+                      G_CALLBACK (cb_row_selected), procdata);
+    g_signal_connect (G_OBJECT (proctree), "popup_menu",
+                      G_CALLBACK (cb_tree_popup_menu), procdata);
+    g_signal_connect (G_OBJECT (proctree), "button_press_event",
+                      G_CALLBACK (cb_tree_button_pressed), procdata);
+
+    g_signal_connect (G_OBJECT(proctree), "columns-changed",
+                      G_CALLBACK(cb_columns_changed), procdata);
+
+    g_signal_connect (G_OBJECT (model), "sort-column-changed",
+                      G_CALLBACK (cb_sort_changed), procdata);
+
+    return proctree;
+}
+
+
+ProcInfo::~ProcInfo()
+{
+    g_free(this->name);
+    g_free(this->tooltip);
+    g_free(this->arguments);
+    g_free(this->security_context);
+    g_free(this->cgroup_name);
+    g_free(this->unit);
+    g_free(this->session);
+    g_free(this->seat);
+    cairo_surface_destroy(this->surface);
+}
+
+
+static void
+get_process_name (ProcInfo *info,
+                  const gchar *cmd, const GStrv args)
+{
+    if (args) {
+        // look for /usr/bin/very_long_name
+        // and also /usr/bin/interpreter /usr/.../very_long_name
+        // which may have use prctl to alter 'cmd' name
+        for (int i = 0; i != 2 && args[i]; ++i) {
+            char* basename;
+            basename = g_path_get_basename(args[i]);
+
+            if (g_str_has_prefix(basename, cmd)) {
+                info->name = basename;
+                return;
+            }
+
+            g_free(basename);
+        }
+    }
+
+    info->name = g_strdup (cmd);
+}
+
+std::string
+ProcInfo::lookup_user(guint uid)
+{
+    typedef std::pair<ProcInfo::UserMap::iterator, bool> Pair;
+    ProcInfo::UserMap::value_type hint(uid, "");
+    Pair p(ProcInfo::users.insert(hint));
+
+    // procman_debug("User lookup for uid %u: %s", uid, (p.second ? "MISS" : "HIT"));
+
+    if (p.second) {
+        struct passwd* pwd;
+        pwd = getpwuid(uid);
+
+        if (pwd && pwd->pw_name)
+            p.first->second = pwd->pw_name;
+        else {
+            char username[16];
+            g_sprintf(username, "%u", uid);
+            p.first->second = username;
+        }
+    }
+
+    return p.first->second;
+}
+
+void
+ProcInfo::set_user(guint uid)
+{
+    if (G_LIKELY(this->uid == uid))
+        return;
+
+    this->uid = uid;
+    this->user = lookup_user(uid);
+}
+
+static void get_process_memory_writable(ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info(ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+
+static void
+update_info_mutable_cols(ProcInfo *info)
+{
+    ProcData * const procdata = ProcData::get_instance();
+    GtkTreeModel *model;
+    model = gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->tree));
+
+    using procman::tree_store_update;
+
+    tree_store_update(model, &info->node, COL_STATUS, info->status);
+    tree_store_update(model, &info->node, COL_USER, info->user.c_str());
+    tree_store_update(model, &info->node, COL_VMSIZE, info->vmsize);
+    tree_store_update(model, &info->node, COL_MEMRES, info->memres);
+    tree_store_update(model, &info->node, COL_MEMWRITABLE, info->memwritable);
+    tree_store_update(model, &info->node, COL_MEMSHARED, info->memshared);
+#ifdef HAVE_WNCK
+    tree_store_update(model, &info->node, COL_MEMXSERVER, info->memxserver);
+#endif
+    tree_store_update(model, &info->node, COL_CPU, info->pcpu);
+    tree_store_update(model, &info->node, COL_CPU_TIME, info->cpu_time);
+    tree_store_update(model, &info->node, COL_DISK_READ_TOTAL, info->disk_read_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_TOTAL, info->disk_write_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_READ_CURRENT, info->disk_read_bytes_current);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_CURRENT, info->disk_write_bytes_current);
+    tree_store_update(model, &info->node, COL_START_TIME, info->start_time);
+    tree_store_update(model, &info->node, COL_NICE, info->nice);
+    tree_store_update(model, &info->node, COL_MEM, info->mem);
+    tree_store_update(model, &info->node, COL_WCHAN, info->wchan);
+    tree_store_update(model, &info->node, COL_CGROUP, info->cgroup_name);
+    tree_store_update(model, &info->node, COL_UNIT, info->unit);
+    tree_store_update(model, &info->node, COL_SESSION, info->session);
+    tree_store_update(model, &info->node, COL_SEAT, info->seat);
+    tree_store_update(model, &info->node, COL_OWNER, info->owner.c_str());
+}
+
+
+
+static void
+insert_info_to_tree (ProcInfo *info, ProcData *procdata, bool forced = false)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    if (procdata->config.show_tree) {
+
+        ProcInfo *parent = 0;
+
+        if (not forced)
+            parent = ProcInfo::find(info->ppid);
+
+        if (parent) {
+            GtkTreePath *parent_node = gtk_tree_model_get_path(model, &parent->node);
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, &parent->node, 0);
+
+            if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(procdata->tree), parent_node)
+#ifdef __linux__
+                // on linuxes we don't want to expand kthreadd by default (always has pid 2)
+                && (parent->pid != 2)
+#endif
+            )
+                gtk_tree_view_expand_row(GTK_TREE_VIEW(procdata->tree), parent_node, FALSE);
+            gtk_tree_path_free(parent_node);
+        } else
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, NULL, 0);
+    }
+    else
+        gtk_tree_store_insert (GTK_TREE_STORE (model), &info->node, NULL, 0);
+
+    gtk_tree_store_set (GTK_TREE_STORE (model), &info->node,
+                        COL_POINTER, info,
+                        COL_NAME, info->name,
+                        COL_ARGS, info->arguments,
+                        COL_TOOLTIP, info->tooltip,
+                        COL_PID, info->pid,
+                        COL_SECURITYCONTEXT, info->security_context,
+                        -1);
+
+    procdata->pretty_table.set_icon(*info);
+
+    procman_debug("inserted %d%s", info->pid, (forced ? " (forced)" : ""));
+}
+
+
+/* Removing a node with children - make sure the children are queued
+** to be readded.
+*/
+template<typename List>
+static void
+remove_info_from_tree (ProcData *procdata, GtkTreeModel *model,
+                       ProcInfo *current, List &orphans, unsigned lvl = 0)
+{
+    GtkTreeIter child_node;
+
+    if (std::find(orphans.begin(), orphans.end(), current) != orphans.end()) {
+        procman_debug("[%u] %d already removed from tree", lvl, int(current->pid));
+        return;
+    }
+
+    procman_debug("[%u] pid %d, %d children", lvl, int(current->pid),
+                  gtk_tree_model_iter_n_children(model, &current->node));
+
+    // it is not possible to iterate&erase over a treeview so instead we
+    // just pop one child after another and recursively remove it and
+    // its children
+
+    while (gtk_tree_model_iter_children(model, &child_node, &current->node)) {
+        ProcInfo *child = 0;
+        gtk_tree_model_get(model, &child_node, COL_POINTER, &child, -1);
+        remove_info_from_tree(procdata, model, child, orphans, lvl + 1);
+    }
+
+    g_assert(not gtk_tree_model_iter_has_child(model, &current->node));
+
+    if (procdata->selected_process == current)
+        procdata->selected_process = NULL;
+
+    orphans.push_back(current);
+    gtk_tree_store_remove(GTK_TREE_STORE(model), &current->node);
+    procman::poison(current->node, 0x69);
+}
+
+static void
+get_process_systemd_info(ProcInfo *info)
+{
+#ifdef HAVE_SYSTEMD
+    uid_t uid;
+
+    if (!LOGIND_RUNNING())
+        return;
+
+    free(info->unit);
+    info->unit = NULL;
+    sd_pid_get_unit(info->pid, &info->unit);
+
+    free(info->session);
+    info->session = NULL;
+    sd_pid_get_session(info->pid, &info->session);
+
+    free(info->seat);
+    info->seat = NULL;
+
+    if (info->session != NULL)
+        sd_session_get_seat(info->session, &info->seat);
+
+    if (sd_pid_get_owner_uid(info->pid, &uid) >= 0)
+        info->owner = info->lookup_user(uid);
+    else
+        info->owner = "";
+#endif
+}
+
+static void
+update_info (ProcData *procdata, ProcInfo *info)
+{
+    glibtop_proc_state procstate;
+    glibtop_proc_uid procuid;
+    glibtop_proc_time proctime;
+    glibtop_proc_kernel prockernel;
+    glibtop_proc_io procio;
+
+    glibtop_get_proc_kernel(&prockernel, info->pid);
+    g_strlcpy(info->wchan, prockernel.wchan, sizeof info->wchan);
+
+    glibtop_get_proc_state (&procstate, info->pid);
+    info->status = procstate.state;
+
+    glibtop_get_proc_uid (&procuid, info->pid);
+    glibtop_get_proc_time (&proctime, info->pid);
+    glibtop_get_proc_io (&procio, info->pid);
+
+    get_process_memory_info(info);
+
+    info->set_user(procstate.uid);
+
+    // if the cpu time has increased reset the status to running
+    // regardless of kernel state (https://bugzilla.gnome.org/606579)
+    guint64 difference = proctime.rtime - info->cpu_time;
+    if (difference > 0)
+        info->status = GLIBTOP_PROCESS_RUNNING;
+    info->pcpu = difference * 100 / procdata->cpu_total_time;
+    info->pcpu = MIN(info->pcpu, 100);
+
+    if (not procdata->config.solaris_mode)
+      info->pcpu *= procdata->config.num_cpus;
+
+    ProcInfo::cpu_times[info->pid] = info->cpu_time = proctime.rtime;
+    info->nice = procuid.nice;
+
+    gdouble update_interval_seconds = procdata->config.update_interval / 1000.0;
+    difference = procio.disk_wbytes - info->disk_write_bytes_total;
+    info->disk_write_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+    difference = procio.disk_rbytes - info->disk_read_bytes_total;
+    info->disk_read_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+
+    info->disk_write_bytes_total = procio.disk_wbytes;
+    info->disk_read_bytes_total = procio.disk_rbytes;
+
+    // set the ppid only if one can exist
+    // i.e. pid=0 can never have a parent
+    if (info->pid > 0) {
+        info->ppid = procuid.ppid;
+    }
+
+    g_assert(info->pid != info->ppid);
+    g_assert(info->ppid != -1 || info->pid == 0);
+
+    /* get cgroup data */
+    get_process_cgroup_info(info);
+
+    get_process_systemd_info(info);
+}
+
+
+ProcInfo::ProcInfo(pid_t pid)
+    : node(),
+      surface(),
+      tooltip(NULL),
+      name(NULL),
+      arguments(NULL),
+      security_context(NULL),
+      pid(pid),
+      ppid(-1),
+      uid(-1)
+{
+    ProcInfo * const info = this;
+    glibtop_proc_state procstate;
+    glibtop_proc_time proctime;
+    glibtop_proc_args procargs;
+    gchar** arguments;<--- Shadow variable
+
+    glibtop_get_proc_state (&procstate, pid);
+    glibtop_get_proc_time (&proctime, pid);
+    arguments = glibtop_get_proc_argv (&procargs, pid, 0);
+
+    /* FIXME : wrong. name and arguments may change with exec* */
+    get_process_name (info, procstate.cmd, static_cast<const GStrv>(arguments));
+
+    std::string tooltip = make_string(g_strjoinv(" ", arguments));<--- Shadow variable
+    if (tooltip.empty())
+        tooltip = procstate.cmd;
+
+    info->tooltip = g_markup_escape_text(tooltip.c_str(), -1);
+
+    info->arguments = g_strescape(tooltip.c_str(), "\\\"");
+    g_strfreev(arguments);
+
+    guint64 cpu_time = proctime.rtime;
+    std::map<pid_t, guint64>::iterator it(ProcInfo::cpu_times.find(pid));
+    if (it != ProcInfo::cpu_times.end())
+    {
+        if (proctime.rtime >= it->second)
+          cpu_time = it->second;
+    }
+    info->cpu_time = cpu_time;
+    info->start_time = proctime.start_time;
+
+    get_process_selinux_context (info);
+    info->cgroup_name = NULL;
+    get_process_cgroup_info(info);
+
+    info->unit = info->session = info->seat = NULL;
+    get_process_systemd_info(info);
+}
+
+static void
+refresh_list (ProcData *procdata, const pid_t* pid_list, const guint n)
+{
+    typedef std::list<ProcInfo*> ProcList;
+    ProcList addition;
+
+    GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+    guint i;
+
+    // Add or update processes in the process list
+    for(i = 0; i < n; ++i) {
+        ProcInfo *info = ProcInfo::find(pid_list[i]);
+
+        if (!info) {
+            info = new ProcInfo(pid_list[i]);
+            ProcInfo::all[info->pid] = info;
+            addition.push_back(info);
+        }
+
+        update_info (procdata, info);
+    }
+
+
+    // Remove dead processes from the process list and from the
+    // tree. children are queued to be readded at the right place
+    // in the tree.
+
+    const std::set<pid_t> pids(pid_list, pid_list + n);
+
+    ProcInfo::Iterator it(ProcInfo::begin());<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration
+
+    while (it != ProcInfo::end()) {
+        ProcInfo * const info = it->second;
+        ProcInfo::Iterator next(it);
+        ++next;
+
+        if (pids.find(info->pid) == pids.end()) {
+            procman_debug("ripping %d", info->pid);
+            remove_info_from_tree(procdata, model, info, addition);
+            addition.remove(info);
+            ProcInfo::all.erase(it);
+            delete info;
+        }
+
+        it = next;
+    }
+
+    // INVARIANT
+    // pid_list == ProcInfo::all + addition
+
+
+    if (procdata->config.show_tree) {
+
+        // insert process in the tree. walk through the addition list
+        // (new process + process that have a new parent). This loop
+        // handles the dependencies because we cannot insert a process
+        // until its parent is in the tree.
+
+        std::set<pid_t> in_tree(pids);
+
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            in_tree.erase((*it)->pid);
+
+
+        while (not addition.empty()) {
+            procman_debug("looking for %d parents", int(addition.size()));
+            ProcList::iterator it(addition.begin());<--- Shadow variable
+
+            while (it != addition.end()) {
+                procman_debug("looking for %d's parent with ppid %d",
+                              int((*it)->pid), int((*it)->ppid));
+
+
+                // inserts the process in the treeview if :
+                // - it has no parent (ppid = -1),
+                //   ie it is for example the [kernel] on FreeBSD
+                // - it is init
+                // - its parent is already in tree
+                // - its parent is unreachable
+                //
+                // rounds == 2 means that addition contains processes with
+                // unreachable parents
+                //
+                // FIXME: this is broken if the unreachable parent becomes active
+                // i.e. it gets active or changes ower
+                // so we just clear the tree on __each__ update
+                // see proctable_update_list (ProcData * const procdata)
+
+
+                if ((*it)->ppid <= 0 or in_tree.find((*it)->ppid) != in_tree.end()) {
+                    insert_info_to_tree(*it, procdata);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ProcInfo *parent = ProcInfo::find((*it)->ppid);<--- Variable 'parent' can be declared as pointer to const
+                // if the parent is unreachable
+                if (not parent) {
+                    // or std::find(addition.begin(), addition.end(), parent) == addition.end()) {
+                    insert_info_to_tree(*it, procdata, true);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ++it;
+            }
+        }
+    }
+    else {
+        // don't care of the tree
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            insert_info_to_tree(*it, procdata);
+    }
+
+
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)<--- Shadow variable
+        update_info_mutable_cols(it->second);
+}
+
+
+static void
+proctable_update_list (ProcData * const procdata)
+{
+    pid_t* pid_list;
+    glibtop_proclist proclist;
+    glibtop_cpu cpu;
+    gint which, arg;
+    procman::SelectionMemento selection;
+
+    switch (procdata->config.whose_process) {
+        case ALL_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL;
+            arg = 0;
+            break;
+
+        case ACTIVE_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL | GLIBTOP_EXCLUDE_IDLE;
+            arg = 0;
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+
+        default:
+            which = GLIBTOP_KERN_PROC_UID;
+            arg = getuid ();
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+    }
+
+    pid_list = glibtop_get_proclist (&proclist, which, arg);
+
+    /* FIXME: total cpu time elapsed should be calculated on an individual basis here
+    ** should probably have a total_time_last gint in the ProcInfo structure */
+    glibtop_get_cpu (&cpu);
+    procdata->cpu_total_time = MAX(cpu.total - procdata->cpu_total_time_last, 1);
+    procdata->cpu_total_time_last = cpu.total;
+
+    // FIXME: not sure if glibtop always returns a sorted list of pid
+    // but it is important otherwise refresh_list won't find the parent
+    std::sort(pid_list, pid_list + proclist.number);
+
+    refresh_list (procdata, pid_list, proclist.number);
+
+    selection.restore(procdata->tree);
+
+    g_free (pid_list);
+
+    /* proclist.number == g_list_length(procdata->info) == g_hash_table_size(procdata->pids) */
+}
+
+
+void
+proctable_update (ProcData * const procdata)
+{
+    char* string;
+
+    string = make_loadavg_string();
+    gtk_label_set_text (GTK_LABEL(procdata->loadavg), string);
+    g_free (string);
+
+    proctable_update_list (procdata);
+}
+
+
+void
+proctable_free_table (ProcData * const procdata)
+{
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)
+        delete it->second;
+
+    ProcInfo::all.clear();
+}
+
+
+void
+proctable_clear_tree (ProcData * const procdata)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    gtk_tree_store_clear (GTK_TREE_STORE (model));
+
+    proctable_free_table (procdata);
+
+    update_sensitivity(procdata);
+}
+
+
+char*
+make_loadavg_string(void)
+{
+    glibtop_loadavg buf;
+
+    glibtop_get_loadavg(&buf);
+
+    return g_strdup_printf(
+        _("Load averages for the last 1, 5, 15 minutes: "
+          "%0.2f, %0.2f, %0.2f"),
+        buf.loadavg[0],
+        buf.loadavg[1],
+        buf.loadavg[2]);
+}
+
+
+
+void
+ProcInfo::set_icon(Glib::RefPtr<Gdk::Pixbuf> icon)
+{
+  this->surface = gdk_cairo_surface_create_from_pixbuf (icon->gobj(), 0, NULL);
+
+  GtkTreeModel *model;
+  model = gtk_tree_view_get_model(GTK_TREE_VIEW(ProcData::get_instance()->tree));
+  gtk_tree_store_set(GTK_TREE_STORE(model), &this->node,
+                     COL_SURFACE, this->surface,
+                    -1);
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/43.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/43.html new file mode 100644 index 00000000..dc1ef059 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/43.html @@ -0,0 +1,279 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
#ifndef H_MATE_SYSTEM_MONITOR_SELECTION_H_1183113337
+#define H_MATE_SYSTEM_MONITOR_SELECTION_H_1183113337
+
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <vector><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+namespace procman
+{
+    class SelectionMemento
+    {
+        std::vector<pid_t> pids;
+        static void add_to_selected(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer data);
+
+    public:
+        void save(GtkWidget* tree);
+        void restore(GtkWidget* tree);
+    };
+}
+
+#endif /* H_MATE_SYSTEM_MONITOR_SELECTION_H_1183113337 */
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/44.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/44.html new file mode 100644 index 00000000..b0525da6 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/44.html @@ -0,0 +1,265 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
#ifndef PROCMAN_SELINUX_H_20050525
+#define PROCMAN_SELINUX_H_20050525
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+void
+get_process_selinux_context (ProcInfo *info);
+
+gboolean
+can_show_security_context_column (void) G_GNUC_CONST;
+
+#endif /* PROCMAN_SELINUX_H_20050525 */
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/45.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/45.html new file mode 100644 index 00000000..dc3f8198 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/45.html @@ -0,0 +1,323 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "selection.h"
+#include "proctable.h"
+#include "util.h"
+
+namespace procman
+{
+    void SelectionMemento::add_to_selected(GtkTreeModel* model, GtkTreePath*, GtkTreeIter* iter, gpointer data)
+    {
+        guint pid = 0;
+        gtk_tree_model_get(model, iter, COL_PID, &pid, -1);
+        if (pid)
+            static_cast<SelectionMemento*>(data)->pids.push_back(pid);
+    }
+
+
+    void SelectionMemento::save(GtkWidget* tree)
+    {
+        GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
+        gtk_tree_selection_selected_foreach(selection, &SelectionMemento::add_to_selected, this);
+    }
+
+
+    void SelectionMemento::restore(GtkWidget* tree)
+    {
+        if (not this->pids.empty())
+        {
+            GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
+            typedef std::vector<pid_t>::iterator iterator;
+            for (iterator it(this->pids.begin()); it != this->pids.end(); ++it)
+            {
+                if (ProcInfo* proc = ProcInfo::find(*it))
+                {
+                    gtk_tree_selection_select_iter(selection, &proc->node);
+                    procman_debug("Re-selected process %u", unsigned(*it));
+                }
+                else
+                    procman_debug("Could not find process %u, cannot re-select it", unsigned(*it));
+            }
+        }
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/46.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/46.html new file mode 100644 index 00000000..de751e8f --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/46.html @@ -0,0 +1,405 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "selinux.h"
+#include "procman.h"
+#include "util.h"
+
+
+static int (*getpidcon)(pid_t, char**);
+static void (*freecon)(char*);
+static int (*is_selinux_enabled)(void);
+
+static gboolean has_selinux;
+
+static gboolean load_selinux(void)
+{
+    return load_symbols("libselinux.so.1",
+                        "getpidcon", &getpidcon,
+                        "freecon", &freecon,
+                        "is_selinux_enabled", &is_selinux_enabled,
+                        NULL);
+}
+
+
+
+void
+get_process_selinux_context (ProcInfo *info)
+{
+    char *con;
+
+    if (has_selinux && !getpidcon (info->pid, &con)) {
+        info->security_context = g_strdup (con);
+        freecon (con);
+    }
+}
+
+
+
+gboolean
+can_show_security_context_column (void)
+{
+    if (!(has_selinux = load_selinux()))
+        return FALSE;
+
+    switch (is_selinux_enabled()) {
+        case 1:
+            /* We're running on an SELinux kernel */
+            return TRUE;
+
+        case -1:
+            /* Error; hide the security context column */
+
+        case 0:
+            /* We're not running on an SELinux kernel:
+               hide the security context column */
+
+        default:
+            g_warning("SELinux was found but is not enabled.\n");
+            return FALSE;
+    }
+}
+
+
+
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/47.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/47.html new file mode 100644 index 00000000..9b078f12 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/47.html @@ -0,0 +1,553 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/proctime.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <algorithm><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "smooth_refresh.h"
+#include "procman.h"
+#include "util.h"
+
+
+const string SmoothRefresh::KEY("smooth-refresh");
+
+
+unsigned SmoothRefresh::get_own_cpu_usage()
+{
+    glibtop_cpu cpu;
+    glibtop_proc_time proctime;
+    guint64 elapsed;
+    unsigned usage = PCPU_LO;
+
+    glibtop_get_cpu (&cpu);
+    elapsed = cpu.total - this->last_total_time;
+
+    if (elapsed) { // avoid division by 0
+        glibtop_get_proc_time(&proctime, getpid());
+        usage = (proctime.rtime - this->last_cpu_time) * 100 / elapsed;
+        this->last_cpu_time = proctime.rtime;
+    }
+
+    usage = MIN (usage, 100);
+
+    this->last_total_time = cpu.total;
+
+    return usage;
+}
+
+
+
+void SmoothRefresh::status_changed(GSettings *settings,
+                                   const gchar *key,
+                                   gpointer user_data)
+{
+    static_cast<SmoothRefresh*>(user_data)->load_settings_value(key);
+}
+
+void SmoothRefresh::load_settings_value(const gchar *key)
+{
+    this->active = g_settings_get_boolean(settings, key);
+
+    if (this->active)
+        procman_debug("smooth_refresh is enabled");
+}
+
+SmoothRefresh::SmoothRefresh(GSettings *a_settings)
+    :
+    settings(a_settings)
+{
+    this->connection = g_signal_connect(G_OBJECT(settings),
+                                        "changed::smooth-refresh",
+                                        G_CALLBACK(status_changed),
+                                        this);
+
+  this->reset();
+  this->load_settings_value(KEY.c_str());
+}
+
+
+
+void SmoothRefresh::reset()
+{
+    glibtop_cpu cpu;
+    glibtop_proc_time proctime;
+
+    glibtop_get_cpu(&cpu);
+    glibtop_get_proc_time(&proctime, getpid());
+
+    this->interval = ProcData::get_instance()->config.update_interval;
+    this->last_pcpu = PCPU_LO;
+    this->last_total_time = cpu.total;
+    this->last_cpu_time = proctime.rtime;
+}
+
+
+
+SmoothRefresh::~SmoothRefresh()
+{
+    if (this->connection)
+        g_signal_handler_disconnect(G_OBJECT(settings), this->connection);
+}
+
+
+
+bool
+SmoothRefresh::get(guint &new_interval)
+{
+    const unsigned config_interval = ProcData::get_instance()->config.update_interval;
+
+    g_assert(this->interval >= config_interval);
+
+    if (not this->active)
+        return false;
+
+
+    const unsigned pcpu = this->get_own_cpu_usage();
+    /*
+      invariant: MAX_UPDATE_INTERVAL >= interval >= config_interval >= MIN_UPDATE_INTERVAL
+
+      i see 3 cases:
+
+      a) interval is too big (CPU usage < 10%)
+      -> increase interval
+
+      b) interval is too small (CPU usage > 10%) AND interval != config_interval
+      >
+      -> decrease interval
+
+      c) interval is config_interval (start or interval is perfect)
+
+    */
+
+    if (pcpu > PCPU_HI && this->last_pcpu > PCPU_HI)
+        new_interval = this->interval * 11 / 10;
+    else if (this->interval != config_interval && pcpu < PCPU_LO && this->last_pcpu < PCPU_LO)
+        new_interval = this->interval * 9 / 10;
+    else
+        new_interval = this->interval;
+
+    new_interval = CLAMP(new_interval, config_interval, config_interval * 2);
+    new_interval = CLAMP(new_interval, MIN_UPDATE_INTERVAL, MAX_UPDATE_INTERVAL);
+
+    bool changed = this->interval != new_interval;
+
+    if (changed)
+        this->interval = new_interval;
+
+    this->last_pcpu = pcpu;
+
+
+    if (changed) {
+        procman_debug("CPU usage is %3u%%, changed refresh_interval to %u (config %u)",
+                      this->last_pcpu,
+                      this->interval,
+                      config_interval);
+    }
+
+    g_assert(this->interval == new_interval);
+    g_assert(this->interval >= config_interval);
+
+    return changed;
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/48.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/48.html new file mode 100644 index 00000000..cbae209f --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/48.html @@ -0,0 +1,2359 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <libxml/parser.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libxml/xpath.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libxml/xpathInternals.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibtop/fsusage.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mountlist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/sysinfo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <netdb.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/socket.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/wait.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <exception><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <vector><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <fstream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sstream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/utsname.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "sysinfo.h"
+#include "procman.h"
+#include "util.h"
+
+
+using std::string;
+using std::vector;
+
+
+namespace {
+
+    class SysInfo
+    {
+    public:
+        string hostname;
+        string distro_name;
+        string distro_release;
+        string kernel;
+        string mate_version;
+        guint64 memory_bytes;
+        guint64 free_space_bytes;
+
+        string graphics;
+        string processors;
+
+        SysInfo()
+        {
+            this->load_processors_info();
+            this->load_graphics_info();
+            this->load_memory_info();
+            this->load_disk_info();
+            this->load_uname_info();
+            this->load_mate_version();
+        }
+
+        virtual ~SysInfo()
+        { }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Virtual function in base class
+        {
+            g_object_set(G_OBJECT(name),
+                        "label",
+                        ("<big><big><b>" + this->distro_name + "</b></big></big>").c_str(),
+                        NULL);
+
+            char* markup;
+#ifdef __linux__
+            if (this->distro_release != "")
+            {
+                /* Translators: The first string parameter is release version (codename),
+                 * the second one is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("Release %s %s"),
+                                         this->distro_release.c_str(),
+                                         SysInfo::get_os_type().c_str());
+            }
+            else
+            {
+                /* Translators: The string parameter is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("%s Version"),
+                                         SysInfo::get_os_type().c_str());
+            }
+#else
+            /* Translators: The string parameter is release version (codename) */
+            markup = g_strdup_printf(_("Release %s"),
+                                     this->distro_release.c_str());
+#endif
+
+            g_object_set(G_OBJECT(release),
+                         "label",
+                         markup,
+                         NULL);
+
+            g_free(markup);
+        }
+
+        static string release()
+        {
+            return uname().release;
+        }
+
+        static string system()
+        {
+            return uname().sysname;
+        }
+
+    private:
+
+        void load_memory_info()
+        {
+            glibtop_mem mem;
+
+            glibtop_get_mem(&mem);
+            this->memory_bytes = mem.total;
+        }
+
+        static string get_os_type ()<--- Unused private function: 'SysInfo::get_os_type'
+        {
+            int bits;
+
+            if (GLIB_SIZEOF_VOID_P == 8)
+                bits = 64;
+            else
+                bits = 32;
+
+            /* translators: This is the type of architecture, for example:
+             * "64-bit" or "32-bit" */
+            char* bytes = g_strdup_printf (_("%d-bit"), bits);
+            string retval(bytes);
+            g_free(bytes);
+            return retval;
+        }
+
+        typedef struct
+        {
+            const char* regex;
+            const char* replacement;
+        } ReplaceStrings;
+
+        static char* remove_duplicate_whitespace (const char* old)
+        {
+            char* result;
+            GRegex* re;
+            GError* error = NULL;
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+
+            re = g_regex_new ("[ \t\n\r]+", G_REGEX_MULTILINE, flags, &error);
+            if (re == NULL) {
+                g_warning ("Error building regex: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+            result = g_regex_replace (re, old, -1, 0, " ", flags, &error);
+            g_regex_unref (re);
+            if (result == NULL) {
+                g_warning ("Error replacing string: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+
+            return result;
+        }
+
+        static char* prettify_info (const char *info)
+        {
+            char* pretty;
+            const GRegexCompileFlags cflags = static_cast<GRegexCompileFlags>(0);
+            const GRegexMatchFlags mflags = static_cast<GRegexMatchFlags>(0);
+
+            static const ReplaceStrings rs[] = {
+                { "Intel[(]R[)]", "Intel\302\256"},
+                { "Core[(]TM[)]", "Core\342\204\242"},
+                { "Atom[(]TM[)]", "Atom\342\204\242"},
+            };
+
+            pretty = g_markup_escape_text (info, -1);
+
+            for (uint i = 0; i < G_N_ELEMENTS (rs); i++) {
+                GError* error;
+                GRegex* re;
+                char* result;
+
+                error = NULL;
+
+                re = g_regex_new (rs[i].regex, cflags, mflags, &error);
+                if (re == NULL) {
+                    g_warning ("Error building regex: %s", error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                result = g_regex_replace_literal (re, pretty, -1, 0,
+                                             rs[i].replacement, mflags, &error);
+
+                g_regex_unref (re);
+
+                if (error != NULL) {
+                    g_warning ("Error replacing %s: %s", rs[i].regex, error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                g_free (pretty);
+                pretty = result;
+            }
+
+            return pretty;
+        }
+
+        static char* get_renderer_from_helper (gboolean discrete_gpu)
+        {
+            int status;
+            const char *argv[] = { LIBEXECDIR "/mate-session-check-accelerated", NULL };
+            g_auto(GStrv) envp = NULL;
+            g_autofree char *renderer = NULL;
+            g_autoptr(GError) error = NULL;
+
+            if (discrete_gpu)
+            {
+                envp = g_get_environ ();
+                envp = g_environ_setenv (envp, "DRI_PRIME", "1", TRUE);
+            }
+
+            if (!g_spawn_sync (NULL, (char **) argv, envp, G_SPAWN_DEFAULT, NULL, NULL, &renderer, NULL, &status, &error))
+            {
+                g_debug ("Failed to get %s GPU: %s",
+                         discrete_gpu ? "discrete" : "integrated",
+                         error->message);
+                return NULL;
+            }
+
+            if (!g_spawn_check_exit_status (status, NULL))
+                return NULL;
+
+            if (renderer == NULL || *renderer == '\0')
+                return NULL;
+
+            return prettify_info (renderer);
+        }
+
+
+        void load_graphics_info()
+        {
+            g_autofree char *renderer = NULL;
+
+            try
+            {
+                g_autoptr(GDBusProxy) session_proxy = NULL;
+                g_autoptr(GVariant) renderer_variant = NULL;
+                g_autoptr(GError) error = NULL;
+
+                session_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                               G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL,
+                                                               "org.gnome.SessionManager",
+                                                               "/org/gnome/SessionManager",
+                                                               "org.gnome.SessionManager",
+                                                               NULL, &error);
+                if (error != NULL)
+                {
+                    throw std::runtime_error ("Unable to connect to create a proxy for org.gnome.SessionManager");
+                }
+
+                renderer_variant = g_dbus_proxy_get_cached_property (session_proxy, "Renderer");
+                if (!renderer_variant)
+                {
+                    throw std::runtime_error ("Unable to retrieve org.gnome.SessionManager.Renderer property.");
+                }
+
+                renderer = prettify_info (g_variant_get_string (renderer_variant, NULL));
+            }
+            catch (std::exception& e)
+            {
+                g_warning ("%s", e.what());
+            }
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (FALSE);
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (TRUE);
+
+            if (renderer)
+            {
+                this->graphics = g_strdup (renderer);
+            }
+            else
+            {
+                this->graphics = _("Unknown");
+            }
+        }
+
+        void load_processors_info()
+        {
+            const glibtop_sysinfo *info = glibtop_get_sysinfo();
+
+            GHashTable* counts;
+            GString* cpu;
+            GHashTableIter iter;
+            gpointer key, value;
+
+            counts = g_hash_table_new (g_str_hash, g_str_equal);
+
+            /* count duplicates */
+            for (uint i = 0; i != info->ncpu; ++i) {
+                const char* const keys[] = { "model name", "cpu", "Processor" };
+                char* model;
+                int* count;
+
+                model = NULL;
+
+                for (int j = 0; model == NULL && j != G_N_ELEMENTS (keys); ++j) {
+                    model = static_cast<char*>(g_hash_table_lookup (info->cpuinfo[i].values,
+                                                 keys[j]));
+                }
+
+                if (model == NULL)
+                    continue;
+
+                count = static_cast<int*>(g_hash_table_lookup (counts, model));
+                if (count == NULL)
+                    g_hash_table_insert (counts, model, GINT_TO_POINTER (1));
+                else
+                    g_hash_table_replace (counts, model, GINT_TO_POINTER (GPOINTER_TO_INT (count) + 1));
+            }
+
+            cpu = g_string_new (NULL);
+            g_hash_table_iter_init (&iter, counts);
+            while (g_hash_table_iter_next (&iter, &key, &value)) {
+                char* stripped;
+                int   count;
+
+                count = GPOINTER_TO_INT (value);
+                stripped = remove_duplicate_whitespace ((const char *)key);
+                if (count > 1)
+                    g_string_append_printf (cpu, "%s \303\227 %d ", stripped, count);
+                else
+                    g_string_append_printf (cpu, "%s ", stripped);
+                g_free (stripped);
+            }
+
+            g_hash_table_destroy (counts);
+            this->processors = string(prettify_info (cpu->str));
+            g_string_free (cpu, TRUE);
+        }
+
+        void load_disk_info()
+        {
+            GHashTable *devices;
+            glibtop_mountentry *entries;
+            glibtop_mountlist mountlist;
+
+            entries = glibtop_get_mountlist(&mountlist, 0);
+            devices = g_hash_table_new(g_str_hash, g_str_equal);
+            this->free_space_bytes = 0;
+
+            for (guint i = 0; i != mountlist.number; ++i) {
+                if ((string(entries[i].mountdir).compare("/") == 0) && \
+                    (string(entries[i].type).compare("zfs") == 0)) {
+                    // Root filesystem is ZFS based: Calculate usage based on "/".
+                    glibtop_fsusage usage;
+                    glibtop_get_fsusage(&usage, "/");
+                    this->free_space_bytes = usage.bavail * usage.block_size;
+                    break;
+                }
+
+                if (string(entries[i].devname).find("/dev/") != 0)
+                    continue;
+
+                if (string(entries[i].mountdir).find("/media/") == 0)
+                    continue;
+
+                /* avoid adding a device more than once such as for btrfs filesystem */
+                if (g_hash_table_contains (devices, entries[i].devname))
+                    continue;
+                else
+                    g_hash_table_insert (devices, entries[i].devname, entries[i].mountdir);
+
+                glibtop_fsusage usage;
+                glibtop_get_fsusage(&usage, entries[i].mountdir);
+                this->free_space_bytes += usage.bavail * usage.block_size;
+            }
+
+            g_hash_table_destroy (devices);
+            g_free(entries);
+        }
+
+        static const struct utsname & uname()
+        {
+            static struct utsname name;
+
+            if (!name.sysname[0]) {
+                ::uname(&name);
+            }
+
+            return name;
+        }
+
+        void load_uname_info()
+        {
+            this->hostname = uname().nodename;
+#if defined(__linux__)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().machine;
+#elif defined(__sun) && defined(__SVR4)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().version + ' ' + uname().machine;
+#else
+            this->kernel = string(uname().version) + ' ' + uname().machine;
+#endif
+        }
+
+
+        void load_mate_version()
+        {
+            xmlDocPtr document;
+            xmlXPathContextPtr context;
+            const string nodes[3] = { "string(/mate-version/platform)",
+                                      "string(/mate-version/minor)",
+                                      "string(/mate-version/micro)" };
+            string values[3];
+
+            if (not (document = xmlParseFile(DATADIR "/mate-about/mate-version.xml")))
+                return;
+
+            if (not (context = xmlXPathNewContext(document)))
+                return;
+
+            for (size_t i = 0; i != 3; ++i)
+            {
+                xmlXPathObjectPtr xpath;
+                xpath = xmlXPathEvalExpression(BAD_CAST nodes[i].c_str(), context);
+
+                if (xpath and xpath->type == XPATH_STRING)
+                    values[i] = reinterpret_cast<const char*>(xpath->stringval);
+
+                xmlXPathFreeObject(xpath);
+            }
+
+            xmlXPathFreeContext(context);
+            xmlFreeDoc(document);
+
+            if (!values[0].empty() && !values[1].empty() && !values[2].empty())
+                this->mate_version = values[0] + '.' + values[1] + '.' + values[2];
+        }
+    };
+
+    class FreeBSDSysInfo
+        : public SysInfo
+    {
+    public:
+	FreeBSDSysInfo()
+        {
+            this->load_freebsd_info();
+        }
+
+    private:
+        void load_freebsd_info()
+        {
+            this->distro_name = "FreeBSD";
+            this->distro_release = release();
+        }
+    };
+
+    class SolarisSysInfo
+        : public SysInfo
+    {
+    public:
+        SolarisSysInfo()
+        {
+            this->load_solaris_info();
+        }
+
+    private:
+        void load_solaris_info()
+        {
+            std::ifstream input("/etc/release");
+
+            if (input) {
+                std::string s;
+                std::getline(input, s);
+                std::size_t found = s.find("OpenIndiana ");
+                if (found!=std::string::npos) {
+                    this->distro_name = "OpenIndiana";
+                    this->distro_release = s.substr(found + strlen("OpenIndiana "));
+                } else if (!s.empty()) {
+                    this->distro_release = s;
+                }
+            }
+
+            if (this->distro_release.empty()) {
+                this->distro_name = "Solaris";
+            }
+        }
+    };
+
+
+    class LSBSysInfo
+        : public SysInfo
+    {
+    public:
+        LSBSysInfo()
+            : re(Glib::Regex::create("^.+?:\\s*(.+)\\s*$"))
+        {
+            // start();
+        }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Function in derived class
+        {
+            this->name = name;
+            this->release = release;
+
+            this->start();
+        }
+
+
+    private:
+
+        sigc::connection child_watch;
+        int lsb_fd;
+        GtkWidget* name;
+        GtkWidget* release;<--- Shadowed declaration<--- Shadowed declaration
+
+        void strip_description(string &s) const
+        {
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+            GMatchInfo* info = 0;
+
+           if (g_regex_match(this->re->gobj(), s.c_str(), flags, &info)) {
+               s = make_string(g_match_info_fetch(info, 1));
+               g_match_info_free(info);
+           }
+        }
+
+        std::istream& get_value(std::istream &is, string &s) const
+        {
+            if (std::getline(is, s))
+                this->strip_description(s);
+            return is;
+        }
+
+
+        void read_lsb(Glib::Pid pid, int status)
+        {
+            this->child_watch.disconnect();
+
+            if (!WIFEXITED(status) or WEXITSTATUS(status) != 0) {
+                g_error("Child %d failed with status %d", int(pid), status);
+                return;
+            }
+
+            Glib::RefPtr<Glib::IOChannel> channel = Glib::IOChannel::create_from_fd(this->lsb_fd);
+            Glib::ustring content;
+
+            while (channel->read_to_end(content) == Glib::IO_STATUS_AGAIN)
+                ;
+
+            channel->close();
+            Glib::spawn_close_pid(pid);
+
+            procman_debug("lsb_release output = '%s'", content.c_str());
+
+            string release, codename;<--- Shadow variable
+            std::istringstream input(content);
+
+            this->get_value(input, this->distro_name)
+                and this->get_value(input, release)
+                and this->get_value(input, codename);
+
+            this->distro_release = release;
+            if (codename != "" && codename != "n/a")
+                this->distro_release += " (" + codename + ')';
+
+            this->SysInfo::set_distro_labels(this->name, this->release);
+        }
+
+
+        void start()
+        {
+            std::vector<string> argv(2);
+            argv[0] = "lsb_release";
+            argv[1] = "-irc";
+
+            Glib::SpawnFlags flags = Glib::SPAWN_DO_NOT_REAP_CHILD
+                | Glib::SPAWN_SEARCH_PATH
+                | Glib::SPAWN_STDERR_TO_DEV_NULL;
+
+            Glib::Pid child;
+
+            try {
+                Glib::spawn_async_with_pipes("/", // wd
+                                             argv,
+                                             flags,
+                                             sigc::slot<void>(), // child setup
+                                             &child,
+                                             0, // stdin
+                                             &this->lsb_fd); // stdout
+            } catch (Glib::SpawnError &e) {
+                g_error("g_spawn_async_with_pipes error: %s", e.what().c_str());
+                return;
+            }
+
+            sigc::slot<void,GPid, int> slot = sigc::mem_fun(this, &LSBSysInfo::read_lsb);
+            this->child_watch = Glib::signal_child_watch().connect(slot, child);
+        }
+
+
+        void sync_lsb_release()<--- Unused private function: 'LSBSysInfo::sync_lsb_release'
+        {
+            char *out= 0;
+            GError *error = 0;
+            int status;
+
+            if (g_spawn_command_line_sync("lsb_release -irc",
+                                          &out,
+                                          0,
+                                          &status,
+                                          &error)) {
+                string release, codename;<--- Shadow variable
+                if (!error and WIFEXITED(status) and WEXITSTATUS(status) == 0) {
+                    std::istringstream input(out);
+                    this->get_value(input, this->distro_name)
+                        and this->get_value(input, release)
+                        and this->get_value(input, codename);
+                    this->distro_release = release;
+                if (codename != "" && codename != "n/a")
+                    this->distro_release += " (" + codename + ')';
+                }
+            }
+
+            if (error)
+                g_error_free(error);
+
+            g_free(out);
+        }
+
+    private:
+        Glib::RefPtr<Glib::Regex> re;
+    };
+
+
+    class NetBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        NetBSDSysInfo()
+        {
+            this->load_netbsd_info();
+        }
+
+    private:
+        void load_netbsd_info()
+        {
+            this->distro_name = "NetBSD";
+
+            std::ifstream input("/etc/release");
+
+            if (input)
+                std::getline(input, this->distro_release);
+        }
+    };
+
+
+    class GenericSysInfo
+        : public SysInfo
+    {
+    public:
+        GenericSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            std::ifstream input("/etc/os-release");
+
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int start;
+                    std::getline(input, s);
+                    if (s.find("NAME=") == 0) {
+                        start = strlen("NAME=");
+                        if ((s.at(start) == '\"') && (s.at(s.size() - 1) == '\"')) {
+                            this->distro_name = s.substr(start + 1, s.size() - start - 2);
+                        } else {
+                            this->distro_name = s.substr(start);
+                        }
+                    } else if (s.find("VERSION=") == 0) {
+                        start = strlen("VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    } else if (s.find("# VERSION=") == 0) {
+                        start = strlen("# VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    }
+                }
+                input.close();
+                input.clear();
+            }
+            if (this->distro_release.empty()) {
+                input.open("/etc/debian_version");
+                if (input) {
+                    getline(input, this->distro_release);
+                }
+            }
+        }
+    };
+
+    class MintSysInfo
+        : public SysInfo
+    {
+    public:
+        MintSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            this->distro_name = "Linux Mint";
+            std::ifstream input("/etc/linuxmint/info");
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int len;
+                    std::getline(input, s);
+                    if (s.find("DESCRIPTION=") == 0) {
+                        len = strlen("DESCRIPTION=");
+                        // also strip the surrounding quotes
+                       this->distro_release = s.substr(len + 1, s.size() - len - 2);
+                   }
+                }
+            }
+        }
+    };
+
+    class OpenBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        OpenBSDSysInfo()
+        {
+            this->load_openbsd_info();
+        }
+
+    private:
+        void load_openbsd_info()
+        {
+            this->distro_name = "OpenBSD";
+            this->distro_release = this->kernel;
+
+            std::ifstream input("/etc/motd");
+
+            if (input)
+                std::getline(input, this->kernel);
+        }
+    };
+
+    SysInfo* get_sysinfo()
+    {
+        if (g_file_test ("/etc/linuxmint/info", G_FILE_TEST_EXISTS)) {
+            return new MintSysInfo;
+        }
+        else if (g_file_test ("/etc/os-release", G_FILE_TEST_EXISTS)) {
+            return new GenericSysInfo;
+        }
+        else if (char *p = g_find_program_in_path("lsb_release")) {
+            g_free(p);
+            return new LSBSysInfo;
+        }
+        else if (SysInfo::system() == "FreeBSD") {
+            return new FreeBSDSysInfo;
+        }
+        else if (SysInfo::system() == "SunOS") {
+            return new SolarisSysInfo;
+        }
+        else if (SysInfo::system() == "NetBSD") {
+            return new NetBSDSysInfo;
+        }
+        else if (SysInfo::system() == "OpenBSD") {
+            return new OpenBSDSysInfo;
+        }
+
+        return new SysInfo;
+    }
+}
+
+
+#define X_PAD  0
+#define Y_PAD  0
+#define LOGO_W 92
+#define LOGO_H 351
+#define RADIUS 5
+
+static gboolean sysinfo_logo_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    GtkStyle *style;
+    cairo_t *cr;
+    cairo_pattern_t *cp;
+
+    cr = gdk_cairo_create(gtk_widget_get_window(widget));
+
+    gtk_widget_get_allocation (widget, &allocation);
+    cairo_translate(cr, allocation.x, allocation.y);
+
+    cairo_move_to(cr, X_PAD + RADIUS, Y_PAD);
+    cairo_line_to(cr, X_PAD + LOGO_W - RADIUS, Y_PAD);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + RADIUS, RADIUS, -0.5 * M_PI, 0);
+    cairo_line_to(cr, X_PAD + LOGO_W, Y_PAD + LOGO_H - RADIUS);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0, 0.5 * M_PI);
+    cairo_line_to(cr, X_PAD + RADIUS, Y_PAD + LOGO_H);
+    cairo_arc(cr, X_PAD + RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0.5 * M_PI, -1.0 * M_PI);
+    cairo_line_to(cr, X_PAD, Y_PAD + RADIUS);
+    cairo_arc(cr,  X_PAD + RADIUS, Y_PAD + RADIUS, RADIUS, -1.0 * M_PI, -0.5 * M_PI);
+
+    cp = cairo_pattern_create_linear(0, Y_PAD, 0, Y_PAD + LOGO_H);
+    style = gtk_widget_get_style (widget);
+    cairo_pattern_add_color_stop_rgba(cp, 0.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      1.0);
+    cairo_pattern_add_color_stop_rgba(cp, 1.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      0.0);
+    cairo_set_source(cr, cp);
+    cairo_fill(cr);
+
+    cairo_pattern_destroy(cp);
+    cairo_destroy(cr);
+
+    return FALSE;
+}
+
+static GtkWidget*
+add_section(GtkBox *vbox , const char * title, int num_row, int num_col, GtkWidget **out_frame)
+{
+    GtkWidget *table;
+
+    GtkWidget *frame = gtk_frame_new(title);
+    gtk_frame_set_label_align(GTK_FRAME(frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
+
+    table = gtk_grid_new();
+    gtk_grid_set_row_spacing(GTK_GRID(table), 6);
+    gtk_grid_set_column_spacing(GTK_GRID(table), 6);
+    gtk_widget_set_margin_start (GTK_WIDGET(table), 12);
+    gtk_container_set_border_width(GTK_CONTAINER(table), 6);
+    gtk_container_add(GTK_CONTAINER(frame), table);
+
+    if(out_frame)
+        *out_frame = frame;
+
+    return table;
+}
+
+
+static GtkWidget*
+add_row(GtkGrid * table, const char * label, const char * value, int row)
+{
+    GtkWidget *header = gtk_label_new(NULL);
+    gtk_label_set_markup(GTK_LABEL(header), label);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        table, header,
+        0, row, 1, 1);
+
+    GtkWidget *label_widget = gtk_label_new(value);
+    gtk_label_set_selectable(GTK_LABEL(label_widget), TRUE);
+    gtk_widget_set_can_focus(label_widget, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (label_widget), 0.0);
+    gtk_grid_attach(
+        table, label_widget,
+        1, row, 1, 1);
+
+    return label_widget;
+}
+
+
+static GtkWidget *
+procman_create_sysinfo_view(void)
+{
+    GtkWidget *hbox;
+    GtkWidget *vbox;
+
+    SysInfo *data = get_sysinfo();;
+
+    GtkWidget * logo;
+
+    GtkWidget *distro_frame;
+    GtkWidget *distro_release_label;
+    GtkWidget *distro_table;
+
+    GtkWidget *hardware_table;
+    GtkWidget *disk_space_table;
+
+    GtkWidget *header;
+
+    gchar *markup;
+
+    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);
+
+    /* left-side logo */
+    if (g_file_test (DATADIR "/pixmaps/mate-system-monitor/distribution/side.png", G_FILE_TEST_EXISTS)) {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/distribution/side.png");
+    }
+    else {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/side.png");
+    }
+    gtk_widget_set_valign (logo, GTK_ALIGN_START);
+    gtk_widget_set_margin_start (logo, 5);
+    gtk_widget_set_margin_end (logo, 5);
+    gtk_widget_set_margin_top (logo, 12);
+    gtk_widget_set_margin_bottom (logo, 12);
+    gtk_box_pack_start(GTK_BOX(hbox), logo, FALSE, FALSE, 0);
+
+    g_signal_connect(G_OBJECT(logo), "draw", G_CALLBACK(sysinfo_logo_draw), NULL);
+
+    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
+    gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
+
+    // hostname
+
+    markup = g_strdup_printf("<big><big><b><u>%s</u></b></big></big>",
+                             data->hostname.c_str());
+    GtkWidget *hostname_frame = gtk_frame_new(markup);
+    g_free(markup);
+    gtk_frame_set_label_align(GTK_FRAME(hostname_frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(hostname_frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(hostname_frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), hostname_frame, FALSE, FALSE, 0);
+
+
+    /* distro section */
+
+    unsigned table_size = 2;
+    if (data->mate_version != "")
+        table_size++;
+    distro_table = add_section(GTK_BOX(vbox), "???", table_size, 1, &distro_frame);
+
+    unsigned table_count = 0;
+
+    distro_release_label = gtk_label_new("???");
+    gtk_label_set_selectable(GTK_LABEL(distro_release_label), TRUE);
+    gtk_widget_set_can_focus(distro_release_label, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (distro_release_label), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), distro_release_label,
+        0, table_count, 1, 1);
+    table_count++;
+    data->set_distro_labels(gtk_frame_get_label_widget(GTK_FRAME(distro_frame)), distro_release_label);
+
+    markup = g_strdup_printf(_("Kernel %s"), data->kernel.c_str());
+    header = gtk_label_new(markup);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    g_free(markup);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), header,
+        0, table_count, 1, 1);
+    table_count++;
+
+    if (data->mate_version != "")
+    {
+        markup = g_strdup_printf(_("MATE %s"), data->mate_version.c_str());
+        header = gtk_label_new(markup);
+        gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+        gtk_widget_set_can_focus(header, FALSE);
+        g_free(markup);
+        gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+        gtk_grid_attach(
+            GTK_GRID(distro_table), header,
+            0, table_count, 1, 1);
+        table_count++;<--- Variable 'table_count' is assigned a value that is never used.
+    }
+
+    /* hardware section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("Hardware"));
+    hardware_table = add_section(GTK_BOX(vbox), markup, 1, 3, NULL);
+    g_free(markup);
+
+    markup = g_format_size_full(data->memory_bytes, G_FORMAT_SIZE_IEC_UNITS);
+    add_row(GTK_GRID(hardware_table), _("Memory:"), markup, 0);
+    g_free(markup);
+
+    add_row(GTK_GRID(hardware_table), _("Processor:"),
+            data->processors.c_str(), 1);
+    add_row(GTK_GRID(hardware_table), _("Graphics:"),
+            data->graphics.c_str(), 2);
+
+    /* disk space section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("System Status"));
+    disk_space_table = add_section(GTK_BOX(vbox), markup, 1, 2, NULL);
+    g_free(markup);
+
+    markup = g_format_size(data->free_space_bytes);
+    add_row(GTK_GRID(disk_space_table), _("Available disk space:"), markup, 0);
+    g_free(markup);
+
+    return hbox;
+}
+
+
+
+namespace procman
+{
+    void build_sysinfo_ui()
+    {
+        static GtkWidget* ui;
+
+        if (!ui) {
+            ProcData* procdata = ProcData::get_instance();
+            ui = procman_create_sysinfo_view();
+            GtkBox* box = GTK_BOX(gtk_notebook_get_nth_page(GTK_NOTEBOOK(procdata->notebook),
+                                                            PROCMAN_TAB_SYSINFO));
+            gtk_box_pack_start(box, ui, TRUE, TRUE, 0);
+            gtk_widget_show_all(ui);
+        }
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/49.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/49.html new file mode 100644 index 00000000..598373c6 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/49.html @@ -0,0 +1,1557 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gprintf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibtop/proctime.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procstate.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <stddef.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <cstring><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "util.h"
+#include "procman.h"
+
+gchar *
+procman_format_date_for_display(time_t time_raw)
+{
+    gchar *result = NULL;
+    const char *format;
+    GDateTime *date_time, *today;
+    GTimeSpan date_age;
+
+    date_time = g_date_time_new_from_unix_local (time_raw);
+    today = g_date_time_new_now_local ();
+
+    date_age = g_date_time_difference (today, date_time);
+    if (date_age < G_TIME_SPAN_DAY) {
+        format = _("Today %l:%M %p");
+    } else if (date_age < 2 * G_TIME_SPAN_DAY) {
+        format = _("Yesterday %l:%M %p");
+    } else if (date_age < 7 * G_TIME_SPAN_DAY) {
+        format = _("%a %l:%M %p");
+    } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
+        format = _("%b %d %l:%M %p");
+    } else {
+	format = _("%b %d %Y");
+    }
+
+    g_date_time_unref (today);
+    result = g_date_time_format (date_time, format);
+    g_date_time_unref (date_time);
+
+    return result;
+}
+
+const char*
+format_process_state(guint state)
+{
+    const char *status;
+
+    switch (state)
+        {
+        case GLIBTOP_PROCESS_RUNNING:
+            status = _("Running");
+            break;
+
+        case GLIBTOP_PROCESS_STOPPED:
+            status = _("Stopped");
+            break;
+
+        case GLIBTOP_PROCESS_ZOMBIE:
+            status = _("Zombie");
+            break;
+
+        case GLIBTOP_PROCESS_UNINTERRUPTIBLE:
+            status = _("Uninterruptible");
+            break;
+
+        default:
+            status = _("Sleeping");
+            break;
+        }
+
+    return status;
+}
+
+
+
+static char *
+mnemonic_safe_process_name(const char *process_name)
+{
+    const char *p;
+    GString *name;
+
+    name = g_string_new ("");
+
+    for(p = process_name; *p; ++p)
+    {
+        g_string_append_c (name, *p);
+
+        if(*p == '_')
+            g_string_append_c (name, '_');
+    }
+
+    return g_string_free (name, FALSE);
+}
+
+
+
+static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
+{
+    *q = *r / d;
+    *r = *r % d;
+    return *q != 0;
+}
+
+
+/*
+ * @param d: duration in centiseconds
+ * @type d: unsigned
+ */
+gchar *
+procman::format_duration_for_display(unsigned centiseconds)
+{
+    unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
+
+    (void)(divide(&seconds, &centiseconds, 100)
+           && divide(&minutes, &seconds, 60)
+           && divide(&hours, &minutes, 60)
+           && divide(&days, &hours, 24)
+           && divide(&weeks, &days, 7));
+
+    if (weeks)
+        /* xgettext: weeks, days */
+        return g_strdup_printf(_("%uw%ud"), weeks, days);
+
+    if (days)
+        /* xgettext: days, hours (0 -> 23) */
+        return g_strdup_printf(_("%ud%02uh"), days, hours);
+
+    if (hours)
+        /* xgettext: hours (0 -> 23), minutes, seconds */
+        return g_strdup_printf(_("%u:%02u:%02u"), hours, minutes, seconds);
+
+    /* xgettext: minutes, seconds, centiseconds */
+    return g_strdup_printf(_("%u:%02u.%02u"), minutes, seconds, centiseconds);
+}
+
+
+
+GtkWidget*
+procman_make_label_for_mmaps_or_ofiles(const char *format,
+                                       const char *process_name,
+                                       unsigned pid)
+{
+    GtkWidget *label;
+    char *name, *title;
+
+    name = mnemonic_safe_process_name (process_name);
+    title = g_strdup_printf(format, name, pid);
+    label = gtk_label_new_with_mnemonic (title);
+    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+
+    g_free (title);
+    g_free (name);
+
+    return label;
+}
+
+gchar *
+procman::get_nice_level (gint nice)
+{
+    if (nice < -7)
+        return _("Very High");
+    else if (nice < -2)
+        return _("High");
+    else if (nice < 3)
+        return _("Normal");
+    else if (nice < 7)
+        return _("Low");
+    else
+        return _("Very Low");
+}
+
+
+gboolean
+load_symbols(const char *module, ...)
+{
+    GModule *mod;
+    gboolean found_all = TRUE;
+    va_list args;
+
+    mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
+
+    if (!mod)
+        return FALSE;
+
+    procman_debug("Found %s", module);
+
+    va_start(args, module);
+
+    while (1) {
+        const char *name;
+        void **symbol;
+
+        name = va_arg(args, char*);
+
+        if (!name)
+            break;
+
+        symbol = va_arg(args, void**);
+
+        if (g_module_symbol(mod, name, symbol)) {
+            procman_debug("Loaded %s from %s", name, module);
+        }
+        else {
+            procman_debug("Could not load %s from %s", name, module);
+            found_all = FALSE;
+            break;
+        }
+    }
+
+    va_end(args);
+
+
+    if (found_all)
+        g_module_make_resident(mod);
+    else
+        g_module_close(mod);
+
+    return found_all;
+}
+
+
+static gboolean
+is_debug_enabled(void)
+{
+    static gboolean init;
+    static gboolean enabled;
+
+    if (!init) {
+        enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL;
+        init = TRUE;
+    }
+
+    return enabled;
+}
+
+
+#if GLIB_CHECK_VERSION(2,61,2)
+static gint64
+get_relative_time(void)
+{
+    static unsigned long start_time;
+    gint64 tv;
+
+    if (G_UNLIKELY(!start_time)) {
+        glibtop_proc_time buf;
+        glibtop_get_proc_time(&buf, getpid());
+        start_time = buf.start_time;
+    }
+
+    tv = g_get_real_time ();
+    return tv - (gint64) start_time;
+}
+#else
+static double
+get_relative_time(void)
+{
+    static unsigned long start_time;
+    GTimeVal tv;
+
+    if (G_UNLIKELY(!start_time)) {
+        glibtop_proc_time buf;
+        glibtop_get_proc_time(&buf, getpid());
+        start_time = buf.start_time;
+    }
+
+    g_get_current_time(&tv);
+    return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
+}
+#endif
+
+static guint64
+get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
+                             const guint index)
+{
+    GValue value = { 0 };
+    gtk_tree_model_get_value(model, first, index, &value);
+
+    guint64 size;
+    switch (G_VALUE_TYPE(&value)) {
+        case G_TYPE_UINT:
+            size = g_value_get_uint(&value);
+            break;
+        case G_TYPE_ULONG:
+            size = g_value_get_ulong(&value);
+            break;
+        case G_TYPE_UINT64:
+            size = g_value_get_uint64(&value);
+            break;
+        default:
+            g_assert_not_reached();
+    }
+
+    g_value_unset(&value);
+    return size;
+}
+
+void
+procman_debug_real(const char *file, int line, const char *func,
+                   const char *format, ...)
+{
+    va_list args;
+    char *msg;
+
+    if (G_LIKELY(!is_debug_enabled()))
+        return;
+
+    va_start(args, format);
+    msg = g_strdup_vprintf(format, args);
+    va_end(args);
+
+#if GLIB_CHECK_VERSION(2,61,2)
+    g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
+#else
+    g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
+#endif
+    g_free(msg);
+}
+
+
+
+namespace procman
+{
+    void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                    GtkTreeModel *model, GtkTreeIter *iter,
+                                    gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+            case G_TYPE_UINT64:
+                size = g_value_get_uint64(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
+        g_object_set(renderer, "text", str, NULL);
+        g_free(str);
+    }
+
+    /*
+      Same as above but handles size == 0 as not available
+     */
+    void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                       GtkTreeModel *model, GtkTreeIter *iter,
+                                       gpointer user_data)
+    {
+     	const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+          case G_TYPE_UINT64:
+              size = g_value_get_uint64(&value);
+              break;
+
+          default:
+              g_assert_not_reached();
+        }
+
+	g_value_unset(&value);
+
+        if (size == 0) {
+            char *str = g_strdup_printf ("<i>%s</i>", _("N/A"));
+            g_object_set(renderer, "markup", str, NULL);
+            g_free(str);
+        }
+	else {
+            char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
+            g_object_set(renderer, "text", str, NULL);
+            g_free(str);
+        }
+    }
+
+    void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                     GtkTreeModel *model, GtkTreeIter *iter,
+                                     gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+            case G_TYPE_UINT64:
+                size = g_value_get_uint64(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        char *str = g_format_size(size);
+        g_object_set(renderer, "text", str, NULL);
+        g_free(str);
+    }
+
+    /*
+      Same as above but handles size == 0 as not available
+     */
+    void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                        GtkTreeModel *model, GtkTreeIter *iter,
+                                        gpointer user_data)
+    {
+     	const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+          case G_TYPE_UINT64:
+              size = g_value_get_uint64(&value);
+              break;
+
+          default:
+              g_assert_not_reached();
+        }
+
+	g_value_unset(&value);
+
+        if (size == 0) {
+            char *str = g_strdup_printf ("<i>%s</i>", _("N/A"));
+            g_object_set(renderer, "markup", str, NULL);
+            g_free(str);
+        }
+	else {
+            char *str = g_format_size(size);
+            g_object_set(renderer, "text", str, NULL);
+            g_free(str);
+        }
+    }
+
+    void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                                GtkTreeModel *model, GtkTreeIter *iter,
+                                gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+            case G_TYPE_UINT64:
+                size = g_value_get_uint64(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        if (size == 0) {
+            char *str = g_strdup_printf ("<i>%s</i>", _("N/A"));
+            g_object_set(renderer, "markup", str, NULL);
+            g_free(str);
+        }
+        else {
+            char *str = g_format_size(size);
+            char *formatted_str = g_strdup_printf(_("%s/s"), str);
+            g_object_set(renderer, "text", formatted_str, NULL);
+            g_free(formatted_str);
+            g_free(str);
+        }
+
+    }
+
+    void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                                 GtkTreeModel *model, GtkTreeIter *iter,
+                                 gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        unsigned time;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+            time = g_value_get_ulong(&value);
+            break;
+
+            case G_TYPE_UINT64:
+                time = g_value_get_uint64(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        time = 100 * time / ProcData::get_instance()->frequency;
+        char *str = format_duration_for_display(time);
+        g_object_set(renderer, "text", str, NULL);
+        g_free(str);
+    }
+
+
+    void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                             GtkTreeModel *model, GtkTreeIter *iter,
+                             gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        time_t time;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                time = g_value_get_ulong(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        gchar *str = procman_format_date_for_display(time);
+        g_object_set(renderer, "text", str, NULL);
+        g_free(str);
+    }
+
+    void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                               GtkTreeModel *model, GtkTreeIter *iter,
+                               gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint state;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_UINT:
+                state = g_value_get_uint(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        const char *str = format_process_state(state);
+        g_object_set(renderer, "text", str, NULL);
+    }
+
+    void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                             GtkTreeModel *model, GtkTreeIter *iter,
+                             gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        gint priority = g_value_get_int(&value);
+
+        g_value_unset(&value);
+
+        g_object_set(renderer, "text", procman::get_nice_level(priority), NULL);
+
+    }
+
+    gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
+                            GtkTreeIter* second, gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+        GValue value1 = { 0 };
+        GValue value2 = { 0 };
+        gtk_tree_model_get_value(model, first, index, &value1);
+        gtk_tree_model_get_value(model, second, index, &value2);
+        gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
+        g_value_unset(&value1);
+        g_value_unset(&value2);
+        return result;
+    }
+
+    gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
+                            GtkTreeIter* second, gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size1, size2;
+        size1 = get_size_from_column(model, first, index);
+        size2 = get_size_from_column(model, second, index);
+
+        if ( size2 > size1 )
+            return 1;
+        else if ( size2 < size1 )
+            return -1;
+        return 0;
+    }
+
+    template<>
+    void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
+    {
+        char* current_value;
+
+        gtk_tree_model_get(model, iter, column, &current_value, -1);
+
+        if (g_strcmp0(current_value, new_value) != 0)
+            gtk_tree_store_set(GTK_TREE_STORE(model), iter, column, new_value, -1);
+
+        g_free(current_value);
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/5.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/5.html new file mode 100644 index 00000000..111df8f5 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/5.html @@ -0,0 +1,435 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
#ifndef _PROCMAN_SMOOTH_REFRESH
+#define _PROCMAN_SMOOTH_REFRESH
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+using std::string;
+
+class SmoothRefresh
+{
+  public:
+
+    /*
+      smooth_refresh_new
+
+      @config_interval : pointer to config_interval so we can observe
+      config_interval changes.
+
+      @return : initialized SmoothRefresh
+    */
+    SmoothRefresh(GSettings *a_settings);
+
+    ~SmoothRefresh();
+
+    /*
+      smooth_refresh_reset
+
+      Resets state and re-read config_interval
+    */
+    void reset();
+
+    /*
+      smooth_refresh_get
+
+      Computes the new refresh_interval so that CPU usage is lower than
+      SMOOTH_REFRESH_PCPU.
+
+      @new_interval : where the new refresh_interval is stored.
+
+      @return : TRUE is refresh_interval has changed. The new refresh_interval
+      is stored in @new_interval. Else FALSE;
+    */
+    bool get(guint &new_interval);
+
+    static const string KEY;
+    static const bool KEY_DEFAULT_VALUE;
+
+  private:
+
+    unsigned get_own_cpu_usage();
+
+    static void status_changed(GSettings *settings,
+                               const gchar *key,
+                               gpointer user_data);
+
+    void load_settings_value(const gchar *key);
+
+    /*
+      fuzzy logic:
+      - decrease refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_LO
+      - increase refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_HI
+
+    */
+
+    enum
+    {
+        PCPU_HI = 22,
+        PCPU_LO = 18
+    };
+
+    /*
+      -self : procman's PID (so we call getpid() only once)
+
+      -interval : current refresh interval
+
+      -config_interval : pointer to the configuration refresh interval.
+      Used to watch configuration changes
+
+      -interval >= -config_interval
+
+      -last_pcpu : to avoid spikes, the last CPU%. See PCPU_{LO,HI}
+
+      -last_total_time:
+      -last_cpu_time: Save last cpu and process times to compute CPU%
+    */
+
+    GSettings *settings;
+    bool active;
+    guint connection;
+    guint interval;
+    unsigned  last_pcpu;
+    guint64 last_total_time;
+    guint64 last_cpu_time;
+};
+
+#endif /* _PROCMAN_SMOOTH_REFRESH */
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/50.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/50.html new file mode 100644 index 00000000..70b6b8df --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/50.html @@ -0,0 +1,275 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+int main(int argc, char* argv[])<--- Parameter 'argv' can be declared as const array
+{
+    gchar **argv_modified = g_new0 (gchar *, (size_t)(argc + 1));
+    memcpy (argv_modified, argv, (size_t)(argc) * sizeof (char*));
+    argv_modified[0] = COMMAND;
+    int errsv = 0;
+
+    if (execvp (COMMAND, argv_modified) == -1) {
+        errsv = errno;
+    }
+
+    g_free (argv_modified);
+    return errsv;
+}
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/6.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/6.html new file mode 100644 index 00000000..7792f2fa --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/6.html @@ -0,0 +1,385 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
// -*- c++ -*-
+
+#ifndef _PROCMAN_PRETTYTABLE_H_
+#define _PROCMAN_PRETTYTABLE_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk-pixbuf/gdk-pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/refptr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdkmm/pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/filemonitor.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <map><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef HAVE_WNCK
+extern "C" {
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+}
+#endif
+
+#include "iconthemewrapper.h"
+
+class ProcInfo;
+
+using std::string;
+
+class PrettyTable
+{
+ public:
+    PrettyTable();
+    ~PrettyTable();
+
+    void set_icon(ProcInfo &);
+
+private:
+
+#ifdef HAVE_WNCK
+    static void on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_opened'
+    static void on_application_closed(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_closed'
+
+    void register_application(pid_t pid, Glib::RefPtr<Gdk::Pixbuf> icon);
+    void unregister_application(pid_t pid);
+#endif
+
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_theme(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_default(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_gio(const ProcInfo &);
+#ifdef HAVE_WNCK
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_wnck(const ProcInfo &);
+#endif
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_name(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_for_kernel(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_dummy(const ProcInfo &);
+
+    bool get_default_icon_name(const string &cmd, string &name);
+    void file_monitor_event (Glib::RefPtr<Gio::File>,
+                             Glib::RefPtr<Gio::File>,
+                             Gio::FileMonitorEvent);
+    void init_gio_app_cache ();
+
+    typedef std::map<string, Glib::RefPtr<Gdk::Pixbuf> > IconCache;
+    typedef std::map<pid_t, Glib::RefPtr<Gdk::Pixbuf> > IconsForPID;
+    typedef std::map<string, Glib::RefPtr<Gio::AppInfo> > AppCache;
+    typedef std::map<string, Glib::RefPtr<Gio::FileMonitor> > DesktopDirMonitors;
+
+    IconsForPID apps;
+    IconCache defaults;
+    DesktopDirMonitors monitors;
+    AppCache gio_apps;
+    procman::IconThemeWrapper theme;
+};
+
+#endif /* _PROCMAN_PRETTYTABLE_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/7.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/7.html new file mode 100644 index 00000000..e4d2cec9 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/7.html @@ -0,0 +1,287 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
#ifndef H_PROCMAN_ICONTHEMEWRAPPER_H_1185707711
+#define H_PROCMAN_ICONTHEMEWRAPPER_H_1185707711
+
+#include <glibmm/refptr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/ustring.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtkmm/icontheme.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdkmm/pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+namespace procman
+{
+    class IconThemeWrapper
+    {
+      public:
+        // returns 0 instead of raising an exception
+        Glib::RefPtr<Gdk::Pixbuf>
+            load_icon(const Glib::ustring& icon_name, int size) const;
+        Glib::RefPtr<Gdk::Pixbuf>
+            load_gicon(const Glib::RefPtr<Gio::Icon>& gicon, int size, Gtk::IconLookupFlags flags) const;
+
+        const IconThemeWrapper* operator->() const
+        { return this; }
+    };
+}
+
+#endif // H_PROCMAN_ICONTHEMEWRAPPER_H_1185707711
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/8.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/8.html new file mode 100644 index 00000000..f0a0b119 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/8.html @@ -0,0 +1,385 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
/*
+ * Mate system monitor color pickers
+ * Copyright (C) 2007 Karl Lattimer <karl@qdh.org.uk>
+ * Copyright (C) 2012-2021 MATE Developers
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with the software; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GSM_COLOR_BUTTON_H__
+#define __GSM_COLOR_BUTTON_H__
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+/* The GtkColorSelectionButton widget is a simple color picker in a button.
+ * The button displays a sample of the currently selected color. When
+ * the user clicks on the button, a color selection dialog pops up.
+ * The color picker emits the "color_set" signal when the color is set.
+ */
+#define GSM_TYPE_COLOR_BUTTON            (gsm_color_button_get_type ())
+G_DECLARE_DERIVABLE_TYPE (GSMColorButton, gsm_color_button, GSM, COLOR_BUTTON, GtkDrawingArea)
+
+/* Widget types */
+enum
+{
+    GSMCP_TYPE_CPU,
+    GSMCP_TYPE_PIE,
+    GSMCP_TYPE_NETWORK_IN,
+    GSMCP_TYPE_NETWORK_OUT,
+    GSMCP_TYPES
+};
+
+struct _GSMColorButtonClass
+{
+    GtkWidgetClass parent_class;
+
+    void (*color_set) (GSMColorButton * cp);
+
+    /* Padding for future expansion */
+    void (*_gtk_reserved1) (void);
+    void (*_gtk_reserved2) (void);
+    void (*_gtk_reserved3) (void);
+    void (*_gtk_reserved4) (void);
+};
+
+GtkWidget *gsm_color_button_new (const GdkRGBA * color, guint type);
+void gsm_color_button_set_color (GSMColorButton * color_button, const GdkRGBA * color);
+void gsm_color_button_set_fraction (GSMColorButton * color_button, const gdouble fraction);
+void gsm_color_button_set_cbtype (GSMColorButton * color_button, guint type);
+void gsm_color_button_get_color (GSMColorButton * color_button, GdkRGBA * color);
+gdouble gsm_color_button_get_fraction (GSMColorButton * color_button);
+guint gsm_color_button_get_cbtype (GSMColorButton * color_button);
+void gsm_color_button_set_title (GSMColorButton * color_button, const gchar * title);
+const gchar* gsm_color_button_get_title(GSMColorButton* color_button);
+
+G_END_DECLS
+#endif /* __GSM_COLOR_BUTTON_H__ */
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/9.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/9.html new file mode 100644 index 00000000..0b6fb092 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/9.html @@ -0,0 +1,305 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
/* Procman - main window
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef _PROCMAN_INTERFACE_H_
+#define _PROCMAN_INTERFACE_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+void            create_main_window (ProcData *data);
+void            update_sensitivity (ProcData *data);
+void            block_priority_changed_handlers(ProcData *data, bool block);
+void            do_popup_menu(ProcData *data, GdkEventButton *event);
+GtkWidget *     make_title_label (const char *text);
+
+#endif /* _PROCMAN_INTERFACE_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/index.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/index.html new file mode 100644 index 00000000..12e0179e --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/index.html @@ -0,0 +1,663 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
src/argv.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibmm/optionentry.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/argv.h
4missingIncludeSysteminformationInclude file: <glibmm/optiongroup.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/callbacks.cpp
21missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <giomm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/callbacks.h
24missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/cgroups.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <cstring> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27variableScope398styleThe scope of the variable 'paren_offset' can be reduced.
27variableScope398styleThe scope of the variable 'off' can be reduced.
27variableScope398styleThe scope of the variable 'tmp_size' can be reduced.
55cstyleCast398styleC-style pointer casting
src/cgroups.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/defaulttable.h
4missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibmm/refptr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glibmm/regex.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/disks.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <mntent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <giomm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <giomm/themedicon.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <glibtop/mountlist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <glibtop/fsusage.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
202redundantAssignment563styleVariable 'res' is reassigned a value before the old one has been used.
src/gsm_color_button.c
23missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <cairo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <librsvg/rsvg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
522constParameterPointer398styleParameter 'color' can be declared as pointer to const
648variableScope398styleThe scope of the variable 'color_chooser' can be reduced.
723constParameterCallback398styleParameter 'event' can be declared as pointer to const. However it seems that 'gsm_color_button_pressed' is a callback function, if 'event' is declared with const you might also need to cast function pointer(s).
src/gsm_color_button.h
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gdk/gdk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/iconthemewrapper.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <gtkmm/icontheme.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <giomm/error.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/iconthemewrapper.h
4missingIncludeSysteminformationInclude file: <glibmm/refptr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibmm/ustring.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <gtkmm/icontheme.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <gdkmm/pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/interface.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
452cstyleCast398styleC-style pointer casting
454cstyleCast398styleC-style pointer casting
src/interface.h
24missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/load-graph.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <gdkmm/pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <dirent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <glibtop.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
16missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <glibtop/mem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
18missingIncludeSysteminformationInclude file: <glibtop/swap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
19missingIncludeSysteminformationInclude file: <glibtop/netload.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
20missingIncludeSysteminformationInclude file: <glibtop/netlist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
21missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <algorithm> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41shadowVariable398styleLocal variable 'n' shadows outer variable
164shadowVariable398styleLocal variable 'i' shadows outer variable
836constParameterPointer398styleParameter 'graph' can be declared as pointer to const
842constParameterPointer398styleParameter 'graph' can be declared as pointer to const
848constParameterPointer398styleParameter 'graph' can be declared as pointer to const
src/load-graph.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36noExplicitConstructor398styleStruct 'LoadGraph' has a constructor with 1 argument that is not explicit.
src/lsof.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <gtkmm/messagedialog.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibmm/regex.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glibtop/procopenfiles.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <sys/wait.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <set> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <sstream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <iterator> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <glibmm/regex.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
164shadowVariable398styleLocal variable 'count' shadows outer variable
src/lsof.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/memmaps.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glibtop/procmap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibtop/mountlist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <map> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <sstream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <iomanip> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <stdexcept> not found. Please note: Cppcheck does not need standard library headers to get proper results.
269shadowVariable398styleLocal variable 'iter' shadows outer variable
src/memmaps.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/msm-resources.c
1missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9unusedStructMember563styleunion member 'Anonymous0::alignment' is never used.
9unusedStructMember563styleunion member 'Anonymous0::ptr' is never used.
src/openfiles.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibtop/procopenfiles.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <netdb.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <sys/socket.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <netinet/in.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <arpa/inet.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
73nullPointerRedundantCheck476warningEither the condition 'res' is redundant or there is possible null pointer dereference: res.
205shadowVariable398styleLocal variable 'openfiles' shadows outer variable
247variableScope398styleThe scope of the variable 'column' can be reduced.
248variableScope398styleThe scope of the variable 'cell' can be reduced.
src/openfiles.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/prettytable.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <libwnck/libwnck.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <dirent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <gdk-pixbuf/gdk-pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <glibtop/procstate.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <giomm/error.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <giomm/file.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
16missingIncludeSysteminformationInclude file: <glibmm/miscutils.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <iostream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
19missingIncludeSysteminformationInclude file: <vector> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/prettytable.h
6missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <gdk-pixbuf/gdk-pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <glibmm/refptr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <gdkmm/pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <giomm/filemonitor.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <map> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
18missingIncludeSysteminformationInclude file: <libwnck/libwnck.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_opened'
40unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_closed'
src/procactions.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <sys/time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <sys/resource.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procdialogs.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
294noExplicitConstructor398styleClass 'SpinButtonUpdater' has a constructor with 1 argument that is not explicit.
415shadowVariable398styleLocal variable 'column' shadows outer variable
475cstyleCast398styleC-style pointer casting
498cstyleCast398styleC-style pointer casting
513cstyleCast398styleC-style pointer casting
src/procdialogs.h
23missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman-app.cpp
1missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
2missingIncludeSysteminformationInclude file: <glibtop.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glibtop/close.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibtop/sysinfo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
348uninitMemberVar398warningMember variable 'ProcmanApp::procdata' is not initialized in the constructor.
src/procman-app.h
4missingIncludeSysteminformationInclude file: <gtkmm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman.cpp
21missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gtkmm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34uninitMemberVarPrivate398warningMember variable 'ProcData::uimanager' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::action_group' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::statusbar' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::loadavg' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::endprocessbutton' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::popup_menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::disk_list' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::notebook' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::config' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::selection' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::settings' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::app' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::frequency' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::smooth_refresh' is not initialized in the constructor.
112shadowVariable398styleLocal variable 'order' shadows outer variable
162shadowVariable398styleLocal variable 'order' shadows outer variable
src/procman.h
23missingIncludeSysteminformationInclude file: <glibmm/refptr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <cairo-gobject.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gdk-pixbuf/gdk-pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <map> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
103uninitMemberVar398warningMember variable 'MutableProcInfo::cgroup_name' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::unit' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::session' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::seat' is not initialized in the constructor.
173noExplicitConstructor398styleClass 'ProcInfo' has a constructor with 1 argument that is not explicit.
src/procman_gksu.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman_gksu.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman_pkexec.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman_pkexec.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procproperties.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glibtop/procmem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glibtop/procmap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glibtop/procstate.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
208variableScope398styleThe scope of the variable 'column' can be reduced.
209variableScope398styleThe scope of the variable 'cell' can be reduced.
src/procproperties.h
25missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/proctable.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <cairo-gobject.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gprintf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glibtop.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <glibtop/loadavg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <glibtop/proclist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <glibtop/procio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <glibtop/procstate.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <glibtop/procmem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <glibtop/procmap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <glibtop/proctime.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <glibtop/procuid.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <glibtop/procargs.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <glibtop/prockernel.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
40missingIncludeSysteminformationInclude file: <glibtop/mem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <glibtop/swap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
42missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
43missingIncludeSysteminformationInclude file: <pwd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
44missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
46missingIncludeSysteminformationInclude file: <set> not found. Please note: Cppcheck does not need standard library headers to get proper results.
47missingIncludeSysteminformationInclude file: <list> not found. Please note: Cppcheck does not need standard library headers to get proper results.
50missingIncludeSysteminformationInclude file: <systemd/sd-login.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
64missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
920shadowVariable398styleLocal variable 'arguments' shadows outer variable
929shadowVariable398styleLocal variable 'tooltip' shadows outer variable
1016shadowVariable398styleLocal variable 'it' shadows outer variable
1022shadowVariable398styleLocal variable 'it' shadows outer variable
1052constVariablePointer398styleVariable 'parent' can be declared as pointer to const
1068shadowVariable398styleLocal variable 'it' shadows outer variable
1073shadowVariable398styleLocal variable 'it' shadows outer variable
src/proctable.h
24missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/selection.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/selection.h
4missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <vector> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/selinux.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
21varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
src/selinux.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/settings-keys.h
4missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/smooth_refresh.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <glibtop.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <glibtop/proctime.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <algorithm> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/smooth_refresh.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
22noExplicitConstructor398styleClass 'SmoothRefresh' has a constructor with 1 argument that is not explicit.
src/sysinfo.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibmm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <libxml/parser.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <libxml/xpath.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <libxml/xpathInternals.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <glibtop/fsusage.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <glibtop/mountlist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <glibtop/mem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <glibtop/sysinfo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
18missingIncludeSysteminformationInclude file: <netdb.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
19missingIncludeSysteminformationInclude file: <sys/socket.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
20missingIncludeSysteminformationInclude file: <sys/wait.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
21missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
22missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <exception> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <vector> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <fstream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <sstream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <sys/utsname.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
126unusedPrivateFunction398styleUnused private function: 'SysInfo::get_os_type'
233cstyleCast398styleC-style pointer casting
343cstyleCast398styleC-style pointer casting
509uninitMemberVar398warningMember variable 'LSBSysInfo::lsb_fd' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::name' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::release' is not initialized in the constructor.
515missingOverridestyleThe function 'set_distro_labels' overrides a function in a base class but is not marked with a 'override' specifier.
570shadowVariable398styleLocal variable 'release' shadows outer variable
615unusedPrivateFunction398styleUnused private function: 'LSBSysInfo::sync_lsb_release'
626variableScope398styleThe scope of the variable 'codename' can be reduced.
626shadowVariable398styleLocal variable 'release' shadows outer variable
690stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
697stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
701stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
736variableScope398styleThe scope of the variable 'len' can be reduced.
738stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
1001unreadVariable563styleVariable 'table_count' is assigned a value that is never used.
src/util.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib/gprintf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <glibtop/proctime.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <glibtop/procstate.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <stddef.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <cstring> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/util.h
6missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
123constParameterPointer398styleParameter 'new_value' can be declared as pointer to const
tools/msm_execute_helper.c
1missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
2missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6constParameter398styleParameter 'argv' can be declared as const array
+
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/stats.html b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/stats.html new file mode 100644 index 00000000..a2e83e06 --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/stats.html @@ -0,0 +1,201 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+

Top 10 files for warning severity, total findings: 24
+   15  src/procman.cpp
+   4   src/procman.h
+   3   src/sysinfo.cpp
+   1   src/procman-app.cpp
+   1   src/openfiles.cpp
+

+

Top 10 files for portability severity, total findings: 1
+   1  src/selinux.cpp
+

+

Top 10 files for performance severity, total findings: 4
+   4  src/sysinfo.cpp
+

+

Top 10 files for style severity, total findings: 55
+   10  src/sysinfo.cpp
+   7   src/proctable.cpp
+   5   src/procdialogs.cpp
+   5   src/load-graph.cpp
+   4   src/cgroups.cpp
+   3   src/openfiles.cpp
+   3   src/gsm_color_button.c
+   2   src/procproperties.cpp
+   2   src/procman.cpp
+   2   src/prettytable.h
+

+

Top 10 files for information severity, total findings: 269
+   26  src/proctable.cpp
+   24  src/sysinfo.cpp
+   18  src/load-graph.cpp
+   14  src/prettytable.cpp
+   12  src/gsm_color_button.c
+   11  src/procman.h
+   11  src/lsof.cpp
+   10  src/util.cpp
+   10  src/memmaps.cpp
+   10  src/interface.cpp
+

+ +
+ +
+ + diff --git a/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/style.css b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/style.css new file mode 100644 index 00000000..3897bfaf --- /dev/null +++ b/2023-10-02-170336-6685-cppcheck@3d354f8f4fd2_test-CI/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-10-16-145104-6166-1@382528349dca_fix-build/index.html b/2023-10-16-145104-6166-1@382528349dca_fix-build/index.html new file mode 100644 index 00000000..b3c9d8ab --- /dev/null +++ b/2023-10-16-145104-6166-1@382528349dca_fix-build/index.html @@ -0,0 +1,136 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@6cc4b86a2a82
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 16.0.6 (Fedora 16.0.6-3.fc38) +
Date:Mon Oct 16 14:51:04 2023
+

Bug Summary

+ + + + + + + +
Bug TypeQuantityDisplay?
All Bugs14
Logic error
Use of identical expressions1
Unused code
Dead assignment1
Unreachable code12
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
Unused codeDead assignmentrootdir/src/disks.cppget_mount_opt2011View Report
Unused codeUnreachable coderootdir/src/procman-app.cppon_command_line3811View Report
Unused codeUnreachable coderootdir/src/util.cppio_rate_cell_data_func4941View Report
Unused codeUnreachable coderootdir/src/util.cppstatus_cell_data_func5911View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_gicon421View Report
Unused codeUnreachable coderootdir/src/util.cppduration_cell_data_func5351View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_na_cell_data_func3841View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_na_cell_data_func4561View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_cell_data_func4221View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_icon131View Report
Unused codeUnreachable coderootdir/src/util.cpptime_cell_data_func5641View Report
Unused codeUnreachable coderootdir/src/procman-app.cpptimeouts_changed_cb1511View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_cell_data_func3501View Report
Logic errorUse of identical expressionsusr/include/sigc++-2.0/sigc++/visit_each.hoperator()981View Report
+ + diff --git a/2023-10-16-145104-6166-1@382528349dca_fix-build/report-22e004.html b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-22e004.html new file mode 100644 index 00000000..be12ee03 --- /dev/null +++ b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-22e004.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 381, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-145104-6166-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
This statement is never executed
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2023-10-16-145104-6166-1@382528349dca_fix-build/report-491eb3.html b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-491eb3.html new file mode 100644 index 00000000..67555117 --- /dev/null +++ b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-491eb3.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 494, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-145104-6166-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-16-145104-6166-1@382528349dca_fix-build/report-4d889d.html b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-4d889d.html new file mode 100644 index 00000000..5fe27dcb --- /dev/null +++ b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-4d889d.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 591, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-145104-6166-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-16-145104-6166-1@382528349dca_fix-build/report-633ebf.html b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-633ebf.html new file mode 100644 index 00000000..cce7d5f6 --- /dev/null +++ b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-633ebf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 42, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-145104-6166-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
This statement is never executed
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2023-10-16-145104-6166-1@382528349dca_fix-build/report-6c54e6.html b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-6c54e6.html new file mode 100644 index 00000000..cd708329 --- /dev/null +++ b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-6c54e6.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 535, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-145104-6166-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-16-145104-6166-1@382528349dca_fix-build/report-6c8186.html b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-6c8186.html new file mode 100644 index 00000000..7bc1d927 --- /dev/null +++ b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-6c8186.html @@ -0,0 +1,886 @@ + + + +/usr/include/sigc++-2.0/sigc++/visit_each.h + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:usr/include/sigc++-2.0/sigc++/visit_each.h
Warning:line 98, column 64
identical expressions on both sides of logical operator
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-145104-6166-1 -x c++ procman.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright 2002, The libsigc++ Development Team
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18#ifndef _SIGC_VISIT_EACH_HPP_
19#define _SIGC_VISIT_EACH_HPP_
20
21#include <sigc++/type_traits.h>
22#include <type_traits>
23
24namespace sigc {
25
26#ifndef DOXYGEN_SHOULD_SKIP_THIS
27namespace internal {
28
29//This should really be an inner class of limit_derived_target, without the T_limit template type,
30//But the SUN CC 5.7 (not earlier versions) compiler finds it ambiguous when we specify a particular specialization of it.
31//and does not seem to allow us to tell it explicitly that it's an inner class.
32template <bool I_derived, class T_type, class T_limit>
33struct with_type;
34
35//Specialization for I_derived = false
36template <class T_type, class T_limit> struct
37with_type<false, T_type, T_limit>
38{
39 static void execute_(const T_type&, const T_limit&) {}
40};
41
42//Specialization for I_derived = true
43template <class T_type, class T_limit>
44struct with_type<true, T_type, T_limit>
45{
46 static void execute_(const T_type& _A_type, const T_limit& _A_action)
47 { _A_action.action_(_A_type); }
48};
49
50
51/// Helper struct for visit_each_type().
52template <class T_target, class T_action>
53struct limit_derived_target
54{
55 typedef limit_derived_target<T_target, T_action> T_self;
56
57 template <class T_type>
58 void operator()(const T_type& _A_type) const
59 {
60 with_type<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
61 }
62
63 limit_derived_target(const T_action& _A_action)
64 : action_(_A_action)
65 {}
66
67 T_action action_;
68};
69
70// Specialization for T_target pointer types, to provide a slightly different execute_() implementation.
71
72template <bool I_derived, class T_type, class T_limit>
73struct with_type_pointer;
74
75//Specialization for I_derived = false
76template <class T_type, class T_limit>
77struct with_type_pointer<false, T_type, T_limit>
78{
79 static void execute_(const T_type&, const T_limit&) {}
80};
81
82//Specialization for I_derived = true
83template <class T_type, class T_limit>
84struct with_type_pointer<true, T_type, T_limit>
85{
86 static void execute_(const T_type& _A_type, const T_limit& _A_action)
87 { _A_action.action_(&_A_type); }
88};
89
90template <class T_target, class T_action>
91struct limit_derived_target<T_target*, T_action>
92{
93 typedef limit_derived_target<T_target*, T_action> T_self;
94
95 template <class T_type>
96 void operator()(const T_type& _A_type) const
97 {
98 with_type_pointer<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
identical expressions on both sides of logical operator
99 }
100
101 limit_derived_target(const T_action& _A_action)
102 : action_(_A_action)
103 {}
104
105 T_action action_;
106};
107
108} /* namespace internal */
109#endif // DOXYGEN_SHOULD_SKIP_THIS
110
111// struct visitor was introduced as a result of https://bugzilla.gnome.org/show_bug.cgi?id=724496
112// The advantage of using specializations of a template struct instead of overloads of
113// a template function is described by Herb Sutter in http://www.gotw.ca/publications/mill17.htm
114// In libsigc++ the main reason for using this technique is that we can avoid using ADL
115// (argument-dependent lookup), and therefore there is no risk that a visit_each() overload
116// in e.g. Boost is selected by mistake.
117
118/** sigc::visitor<T_functor>::do_visit_each() performs a functor on each of the targets of a functor.
119 * All unknown types just call @a _A_action on them.
120 * Add specializations that specialize the @a T_functor argument for your own
121 * functor types, so that subobjects get visited. This is needed to enable
122 * auto-disconnection support for your functor types.
123 *
124 * @par Example:
125 * @code
126 * namespace some_ns
127 * {
128 * struct some_functor
129 * {
130 * void operator()() {}
131 * some_possibly_sigc_trackable_derived_type some_data_member;
132 * some_other_functor_type some_other_functor;
133 * };
134 * }
135 *
136 * namespace sigc
137 * {
138 * template <>
139 * struct visitor<some_ns::some_functor>
140 * {
141 * template <class T_action>
142 * static void do_visit_each(const T_action& _A_action,
143 * const some_ns::some_functor& _A_target)
144 * {
145 * sigc::visit_each(_A_action, _A_target.some_data_member);
146 * sigc::visit_each(_A_action, _A_target.some_other_functor);
147 * }
148 * };
149 * }
150 * @endcode
151 *
152 * @ingroup sigcfunctors
153 */
154template <class T_functor>
155struct visitor
156{
157 template <class T_action>
158 static void do_visit_each(const T_action& _A_action, const T_functor& _A_functor)
159 {
160 _A_action(_A_functor);
161 }
162};
163
164/** This function performs a functor on each of the targets of a functor.
165 *
166 * @ingroup sigcfunctors
167 */
168template <class T_action, class T_functor>
169void visit_each(const T_action& _A_action, const T_functor& _A_functor)
170{ sigc::visitor<T_functor>::do_visit_each(_A_action, _A_functor); }
171
172/** This function performs a functor on each of the targets
173 * of a functor limited to a restricted type.
174 *
175 * @ingroup sigcfunctors
176 */
177template <class T_type, class T_action, class T_functor>
178void visit_each_type(const T_action& _A_action, const T_functor& _A_functor)
179{
180 typedef internal::limit_derived_target<T_type, T_action> type_limited_action;
181
182 type_limited_action limited_action(_A_action);
183
184 //specifying the types of the template specialization prevents disconnection of bound trackable references (such as with std::ref()),
185 //probably because the visit_each<> specializations take various different template types,
186 //in various sequences, and we are probably specifying only a subset of them with this.
187 //
188 //But this is required by the AIX (and maybe IRIX MipsPro and Tru64) compilers.
189 //I guess that std::ref() therefore does not work on those platforms. murrayc
190 // sigc::visit_each<type_limited_action, T_functor>(limited_action, _A_functor);
191
192 //g++ (even slightly old ones) is our primary platform, so we could use the non-crashing version.
193 //However, the explicit version also fixes a crash in a slightly more common case: http://bugzilla.gnome.org/show_bug.cgi?id=169225
194 //Users (and distributors) of libsigc++ on AIX (and maybe IRIX MipsPro and Tru64) do
195 //need to use the version above instead, to allow compilation.
196
197 //Added 2014-03-20: The preceding comment probably does not apply any more,
198 //now when the visit_each<>() overloads have been replaced by visitor<> specializations.
199 //It's probably safe to add explicit template parameters on calls to visit_each(),
200 //visit_each_type() and visitor::do_visit_each(), if necessary.
201
202 sigc::visit_each(limited_action, _A_functor);
203}
204
205} /* namespace sigc */
206#endif
diff --git a/2023-10-16-145104-6166-1@382528349dca_fix-build/report-77634b.html b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-77634b.html new file mode 100644 index 00000000..922d49f3 --- /dev/null +++ b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-77634b.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 384, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-145104-6166-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-16-145104-6166-1@382528349dca_fix-build/report-7bbc8c.html b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-7bbc8c.html new file mode 100644 index 00000000..7c4ceebe --- /dev/null +++ b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-7bbc8c.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 456, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-145104-6166-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-16-145104-6166-1@382528349dca_fix-build/report-7ce786.html b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-7ce786.html new file mode 100644 index 00000000..0af3a13e --- /dev/null +++ b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-7ce786.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 422, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-145104-6166-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-16-145104-6166-1@382528349dca_fix-build/report-802eaf.html b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-802eaf.html new file mode 100644 index 00000000..f933261d --- /dev/null +++ b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-802eaf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 13, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-145104-6166-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
This statement is never executed
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2023-10-16-145104-6166-1@382528349dca_fix-build/report-8e6c9c.html b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-8e6c9c.html new file mode 100644 index 00000000..fd4c2e1e --- /dev/null +++ b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-8e6c9c.html @@ -0,0 +1,1200 @@ + + + +disks.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/disks.cpp
Warning:line 201, column 13
Value stored to 'res' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name disks.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-145104-6166-1 -x c++ disks.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#ifdef __linux__1
4#include <mntent.h>
5#endif // __linux__
6
7#include <giomm.h>
8#include <giomm/themedicon.h>
9#include <gtk/gtk.h>
10#include <glibtop/mountlist.h>
11#include <glibtop/fsusage.h>
12#include <glib/gi18n.h>
13
14#include "procman.h"
15#include "disks.h"
16#include "util.h"
17#include "interface.h"
18#include "iconthemewrapper.h"
19
20namespace
21{
22 const unsigned DISK_ICON_SIZE = 24;
23}
24
25enum DiskColumns
26{
27 /* string columns* */
28 DISK_DEVICE,
29 DISK_DIR,
30 DISK_TYPE,
31 DISK_SUBVOLUME,
32 DISK_TOTAL,
33 DISK_FREE,
34 DISK_AVAIL,
35 /* USED has to be the last column */
36 DISK_USED,
37 // then unvisible columns
38 /* Surface column */
39 DISK_ICON,
40 /* numeric columns */
41 DISK_USED_PERCENTAGE,
42 DISK_N_COLUMNS
43};
44
45
46
47static void
48fsusage_stats(const glibtop_fsusage *buf,
49 guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
50 gint *percentage)
51{
52 guint64 total = buf->blocks * buf->block_size;
53
54 if (!total) {
55 /* not a real device */
56 *btotal = *bfree = *bavail = *bused = 0ULL;
57 *percentage = 0;
58 } else {
59 int percent;
60 *btotal = total;
61 *bfree = buf->bfree * buf->block_size;
62 *bavail = buf->bavail * buf->block_size;
63 *bused = *btotal - *bfree;
64 /* percent = 100.0f * *bused / *btotal; */
65 percent = 100 * *bused / (*bused + *bavail);
66 *percentage = CLAMP(percent, 0, 100)(((percent) > (100)) ? (100) : (((percent) < (0)) ? (0)
: (percent)))
;
67 }
68}
69
70
71namespace
72{
73 string get_icon_for_path(const std::string& path)
74 {
75 using namespace Glib;
76 using namespace Gio;
77
78 // FIXME: I don't know whether i should use Volume or Mount or UnixMount
79 // all i need an icon name.
80 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
81
82 std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
83
84 for (size_t i = 0; i != mounts.size(); ++i) {
85 if (mounts[i]->get_name() != path)
86 continue;
87
88 RefPtr<Icon> icon = mounts[i]->get_icon();
89 RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
90
91 if (themed_icon) {
92 char* name = 0;
93 // FIXME: not wrapped yet
94 g_object_get(G_OBJECT(themed_icon->gobj())((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((themed_icon->gobj())), (((GType) ((20) << (2)))
)))))
, "name", &name, NULL__null);
95 return make_string(name);
96 }
97 }
98
99 return "";
100 }
101}
102
103
104static Glib::RefPtr<Gdk::Pixbuf>
105get_icon_for_device(const char *mountpoint)
106{
107 procman::IconThemeWrapper icon_theme;
108 string icon_name = get_icon_for_path(mountpoint);
109 if (icon_name == "")
110 // FIXME: defaults to a safe value
111 icon_name = "drive-harddisk"; // get_icon_for_path("/");
112 return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
113}
114
115
116static gboolean
117find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
118 GtkTreeIter *result)
119{
120 GtkTreeIter iter;
121 gboolean found = FALSE(0);
122
123 if (gtk_tree_model_get_iter_first(model, &iter)) {
124 do {
125 char *dir;
126
127 gtk_tree_model_get(model, &iter,
128 DISK_DIR, &dir,
129 -1);
130
131 if (dir && !strcmp(dir, mountpoint)) {
132 *result = iter;
133 found = TRUE(!(0));
134 }
135
136 g_free(dir);
137
138 } while (!found && gtk_tree_model_iter_next(model, &iter));
139 }
140
141 return found;
142}
143
144
145
146static void
147remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
148{
149 GtkTreeIter iter;
150
151 if (!gtk_tree_model_get_iter_first(model, &iter))
152 return;
153
154 while (true) {
155 char *dir;
156 guint i;
157 gboolean found = FALSE(0);
158
159 gtk_tree_model_get(model, &iter,
160 DISK_DIR, &dir,
161 -1);
162
163 for (i = 0; i != n; ++i) {
164 if (!strcmp(dir, entries[i].mountdir)) {
165 found = TRUE(!(0));
166 break;
167 }
168 }
169
170 g_free(dir);
171
172 if (!found) {
173 if (!gtk_list_store_remove(GTK_LIST_STORE(model)((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_list_store_get_type ()))))))
, &iter))
174 break;
175 else
176 continue;
177 }
178
179 if (!gtk_tree_model_iter_next(model, &iter))
180 break;
181 }
182}
183
184#ifdef __linux__1
185static char *
186get_mount_opt(const glibtop_mountentry *entry, const char* opt)
187{
188 char *opt_value = NULL__null;
189 const struct mntent *mnt;
190 FILE *fp;
191
192 if (!(fp = setmntent(MOUNTED"/etc/mtab", "r"))) {
193 goto out;
194 }
195
196 while ((mnt = getmntent(fp))) {
197 if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
198 (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
199 char *res;
200
201 res = hasmntopt(mnt, "subvol");
Value stored to 'res' is never read
202 if ((res = hasmntopt(mnt, "subvol")) != NULL__null) {
203 char **strs = g_strsplit_set(res, "=", 2);
204
205 if (g_strv_length(strs) == 2) {
206 char *value = strs[1];
207 if (g_strcmp0 (value,"/root") == 0)
208 opt_value = g_strdup("/")g_strdup_inline ("/");
209 else
210 opt_value = g_strdup(strs[1])g_strdup_inline (strs[1]);
211 g_strfreev(strs);
212 }
213 }
214 break;
215 }
216 }
217
218 endmntent(fp);
219
220 out:
221 return opt_value;
222}
223#endif // __linux__
224
225
226static void
227add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
228{
229 Glib::RefPtr<Gdk::Pixbuf> pixbuf;
230 cairo_surface_t *surface;
231 GtkTreeIter iter;
232 glibtop_fsusage usage;
233 guint64 bused, bfree, bavail, btotal;
234 gint percentage;
235#ifdef __linux__1
236 char *subvol = NULL__null;
237#endif // __linux__
238
239 glibtop_get_fsusage(&usage, entry->mountdir);
240
241 if (not show_all_fs and usage.blocks == 0) {
242 if (find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
243 gtk_list_store_remove(list, &iter);
244 return;
245 }
246
247 fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
248#ifdef __linux__1
249 subvol = get_mount_opt(entry, "subvol");
250#endif // __linux__
251 pixbuf = get_icon_for_device(entry->mountdir);
252 surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL__null);
253
254 /* if we can find a row with the same mountpoint, we get it but we
255 still need to update all the fields.
256 This makes selection persistent.
257 */
258 if (!find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
259 gtk_list_store_append(list, &iter);
260
261 gtk_list_store_set(list, &iter,
262 DISK_ICON, surface,
263 DISK_DEVICE, entry->devname,
264 DISK_DIR, entry->mountdir,
265 DISK_TYPE, entry->type,
266#ifdef __linux__1
267
268 DISK_SUBVOLUME, subvol != NULL__null ? subvol : "",
269#else
270 DISK_SUBVOLUME, "",
271#endif // __linux__
272 DISK_USED_PERCENTAGE, percentage,
273 DISK_TOTAL, btotal,
274 DISK_FREE, bfree,
275 DISK_AVAIL, bavail,
276 DISK_USED, bused,
277 -1);
278#ifdef __linux__1
279 g_free (subvol);
280#endif // __linux__
281}
282
283
284
285int
286cb_update_disks(gpointer data)
287{
288 ProcData *const procdata = static_cast<ProcData*>(data);
289
290 GtkListStore *list;
291 glibtop_mountentry * entries;
292 glibtop_mountlist mountlist;
293 guint i;
294
295 list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)))((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_tree_view_get_model(((((GtkTreeView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((procdata->disk_list)), ((gtk_tree_view_get_type
()))))))))), ((gtk_list_store_get_type ()))))))
;
296
297 entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
298
299 remove_old_disks(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entries, mountlist.number);
300
301 for (i = 0; i < mountlist.number; i++)
302 add_disk(list, &entries[i], procdata->config.show_all_fs);
303
304 g_free(entries);
305
306 return TRUE(!(0));
307}
308
309
310static void
311cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
312{
313 ProcData * const procdata = static_cast<ProcData*>(user_data);
314
315 procman_save_tree_state(procdata->settings,
316 GTK_WIDGET(treeview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_widget_get_type ()))))))
,
317 "disktreenew");
318}
319
320
321static void
322open_dir(GtkTreeView *tree_view,
323 GtkTreePath *path,
324 GtkTreeViewColumn *column,
325 gpointer user_data)
326{
327 GtkTreeIter iter;
328 GtkTreeModel *model;
329 char *dir, *url;
330
331 model = gtk_tree_view_get_model(tree_view);
332
333 if (!gtk_tree_model_get_iter(model, &iter, path)) {
334 char *p;
335 p = gtk_tree_path_to_string(path);
336 g_warning("Cannot get iter for path '%s'\n", p);
337 g_free(p);
338 return;
339 }
340
341 gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
342
343 url = g_strdup_printf("file://%s", dir);
344
345 GError* error = 0;
346 if (!g_app_info_launch_default_for_uri(url, NULL__null, &error)) {
347 g_warning("Cannot open '%s' : %s\n", url, error->message);
348 g_error_free(error);
349 }
350
351 g_free(url);
352 g_free(dir);
353}
354
355static guint timeout_id = 0;
356static GtkTreeViewColumn *current_column;
357
358static gboolean
359save_column_width (gpointer data)
360{
361 gint width;
362 gchar *key;
363 int id;
364 GSettings *settings;
365
366 settings = g_settings_get_child (G_SETTINGS (data)((((GSettings*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((g_settings_get_type ()))))))
, "disktreenew");
367 id = gtk_tree_view_column_get_sort_column_id (current_column);
368 width = gtk_tree_view_column_get_width (current_column);
369
370 key = g_strdup_printf ("col-%d-width", id);
371 g_settings_set_int(settings, key, width);
372 g_free (key);
373
374 if (timeout_id) {
375 g_source_remove (timeout_id);
376 timeout_id = 0;
377 }
378
379 return FALSE(0);
380}
381
382static void
383cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
384{
385 current_column = GTK_TREE_VIEW_COLUMN(widget)((((GtkTreeViewColumn*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((widget)), ((gtk_tree_view_column_get_type (
)))))))
;
386
387 if (timeout_id)
388 g_source_remove (timeout_id);
389
390 timeout_id = g_timeout_add (250, save_column_width, data);
391}
392
393void
394create_disk_view(ProcData *procdata, GtkBuilder *builder)
395{
396 GtkWidget *scrolled;
397 GtkWidget *disk_tree;
398 GtkListStore *model;
399 GtkTreeViewColumn *col;
400 GtkCellRenderer *cell;
401 guint i;
402
403 const gchar * const titles[] = {
404 N_("Device")("Device"),
405 N_("Directory")("Directory"),
406 N_("Type")("Type"),
407 N_("SubVolume")("SubVolume"),
408 N_("Total")("Total"),
409 N_("Free")("Free"),
410 N_("Available")("Available"),
411 N_("Used")("Used")
412 };
413
414 scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "disks_scrolled"))), ((
gtk_widget_get_type ()))))))
;
415
416 model = gtk_list_store_new(DISK_N_COLUMNS, /* n columns */
417 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DEVICE */
418 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DIR */
419 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_TYPE */
420 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_SUBVOLUME */
421 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_TOTAL */
422 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_FREE */
423 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_AVAIL */
424 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_USED */
425 CAIRO_GOBJECT_TYPE_SURFACEcairo_gobject_surface_get_type (), /* DISK_ICON */
426 G_TYPE_INT((GType) ((6) << (2)))); /* DISK_USED_PERCENTAGE */
427
428 disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_model_get_type ()))))))
);
429 g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("row-activated"), (((GCallback) (open_dir))), (__null
), __null, (GConnectFlags) 0)
;
430 procdata->disk_list = disk_tree;
431 gtk_container_add(GTK_CONTAINER(scrolled)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((scrolled)), ((gtk_container_get_type ()))))))
, disk_tree);
432 g_object_unref(G_OBJECT(model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
);
433
434 /* icon + device */
435
436 col = gtk_tree_view_column_new();
437 cell = gtk_cell_renderer_pixbuf_new();
438 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
439 gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
440 NULL__null);
441
442 cell = gtk_cell_renderer_text_new();
443 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
444 gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
445 NULL__null);
446 gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE])gettext (titles[DISK_DEVICE]));
447 gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
448 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
449 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
450 gtk_tree_view_column_set_min_width (col, 30);
451 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
452 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
453 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
454
455 /* sizes - used */
456
457 for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
458 cell = gtk_cell_renderer_text_new();
459 col = gtk_tree_view_column_new();
460 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
461 gtk_tree_view_column_set_title(col, _(titles[i])gettext (titles[i]));
462 gtk_tree_view_column_set_sort_column_id(col, i);
463 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
464 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
465 gtk_tree_view_column_set_min_width (col, 30);
466 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
467 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
468 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
469
470 switch (i) {
471 case DISK_TOTAL:
472 case DISK_FREE:
473 case DISK_AVAIL:
474 g_object_set(cell, "xalign", 1.0f, NULL__null);
475 gtk_tree_view_column_set_cell_data_func(col, cell,
476 &procman::storage_size_cell_data_func,
477 GUINT_TO_POINTER(i)((gpointer) (gulong) (i)),
478 NULL__null);
479 break;
480
481 default:
482 gtk_tree_view_column_set_attributes(col, cell,
483 "text", i,
484 NULL__null);
485 break;
486 }
487 }
488
489 /* used + percentage */
490
491 col = gtk_tree_view_column_new();
492 cell = gtk_cell_renderer_text_new();
493 g_object_set(cell, "xalign", 1.0f, NULL__null);
494 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
495 gtk_tree_view_column_set_cell_data_func(col, cell,
496 &procman::storage_size_cell_data_func,
497 GUINT_TO_POINTER(DISK_USED)((gpointer) (gulong) (DISK_USED)),
498 NULL__null);
499
500 cell = gtk_cell_renderer_progress_new();
501 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
502 gtk_tree_view_column_set_attributes(col, cell, "value",
503 DISK_USED_PERCENTAGE, NULL__null);
504 gtk_tree_view_column_set_title(col, _(titles[DISK_USED])gettext (titles[DISK_USED]));
505 gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
506 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
507 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
508 gtk_tree_view_column_set_min_width (col, 150);
509 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
510 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
511 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
512
513 /* numeric sort */
514
515 procman_get_tree_state(procdata->settings, disk_tree,
516 "disktreenew");
517
518 g_signal_connect (G_OBJECT(disk_tree), "columns-changed",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
519 G_CALLBACK(cb_disk_columns_changed), procdata)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
;
520}
diff --git a/2023-10-16-145104-6166-1@382528349dca_fix-build/report-c673b5.html b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-c673b5.html new file mode 100644 index 00000000..23d4dcec --- /dev/null +++ b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-c673b5.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 564, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-145104-6166-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-16-145104-6166-1@382528349dca_fix-build/report-d507c5.html b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-d507c5.html new file mode 100644 index 00000000..d9879a01 --- /dev/null +++ b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-d507c5.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 151, column 9
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-145104-6166-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
This statement is never executed
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2023-10-16-145104-6166-1@382528349dca_fix-build/report-e8ff80.html b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-e8ff80.html new file mode 100644 index 00000000..fcbd8b25 --- /dev/null +++ b/2023-10-16-145104-6166-1@382528349dca_fix-build/report-e8ff80.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 350, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-145104-6166-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-16-145104-6166-1@382528349dca_fix-build/scanview.css b/2023-10-16-145104-6166-1@382528349dca_fix-build/scanview.css new file mode 100644 index 00000000..cf8a5a6a --- /dev/null +++ b/2023-10-16-145104-6166-1@382528349dca_fix-build/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/2023-10-16-145104-6166-1@382528349dca_fix-build/sorttable.js b/2023-10-16-145104-6166-1@382528349dca_fix-build/sorttable.js new file mode 100644 index 00000000..32faa078 --- /dev/null +++ b/2023-10-16-145104-6166-1@382528349dca_fix-build/sorttable.js @@ -0,0 +1,492 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse',''); + cell.className = cell.className.replace('sorttable_sorted',''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j=0; j 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } + else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } + else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i=0; i=0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a,b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); + if (isNaN(bb)) bb = 0; + return aa-bb; + }, + sort_alpha: function(a,b) { + if (a[0]==b[0]) return 0; + if (a[0] 0 ) { + var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for(var i = t; i > b; --i) { + if ( comp_func(list[i], list[i-1]) < 0 ) { + var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write(" + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/optionentry.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+
+#include "argv.h"
+
+namespace procman
+{
+    OptionGroup::OptionGroup()
+        : Glib::OptionGroup("", ""),
+          show_system_tab(false),
+          show_processes_tab(false),
+          show_resources_tab(false),
+          show_file_systems_tab(false)
+    {
+        Glib::OptionEntry sys_tab;
+        sys_tab.set_long_name("show-system-tab");
+        sys_tab.set_short_name('s');
+        sys_tab.set_description(_("Show the System tab"));
+
+        Glib::OptionEntry proc_tab;
+        proc_tab.set_long_name("show-processes-tab");
+        proc_tab.set_short_name('p');
+        proc_tab.set_description(_("Show the Processes tab"));
+
+        Glib::OptionEntry res_tab;
+        res_tab.set_long_name("show-resources-tab");
+        res_tab.set_short_name('r');
+        res_tab.set_description(_("Show the Resources tab"));
+
+        Glib::OptionEntry fs_tab;
+        fs_tab.set_long_name("show-file-systems-tab");
+        fs_tab.set_short_name('f');
+        fs_tab.set_description(_("Show the File Systems tab"));
+
+        this->add_entry(sys_tab, this->show_system_tab);
+        this->add_entry(proc_tab, this->show_processes_tab);
+        this->add_entry(res_tab, this->show_resources_tab);
+        this->add_entry(fs_tab, this->show_file_systems_tab);
+    }
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/1.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/1.html new file mode 100644 index 00000000..9abf2d68 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/1.html @@ -0,0 +1,279 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
#ifndef H_PROCMAN_ARGV_1205873424
+#define H_PROCMAN_ARGV_1205873424
+
+#include <glibmm/optiongroup.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+namespace procman
+{
+    class OptionGroup
+        : public Glib::OptionGroup
+    {
+      public:
+        OptionGroup();
+
+        bool show_system_tab;
+        bool show_processes_tab;
+        bool show_resources_tab;
+        bool show_file_systems_tab;
+    };
+}
+
+#endif // H_PROCMAN_ARGV_1205873424
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/10.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/10.html new file mode 100644 index 00000000..4d43bbc7 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/10.html @@ -0,0 +1,391 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
/* Procman - tree view
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef _PROCMAN_PROCTABLE_H_
+#define _PROCMAN_PROCTABLE_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+enum
+{
+    COL_NAME = 0,
+    COL_USER,
+    COL_STATUS,
+    COL_VMSIZE,
+    COL_MEMRES,
+    COL_MEMWRITABLE,
+    COL_MEMSHARED,
+    COL_MEMXSERVER,
+    COL_CPU,
+    COL_CPU_TIME,
+    COL_START_TIME,
+    COL_NICE,
+    COL_PID,
+    COL_SECURITYCONTEXT,
+    COL_ARGS,
+    COL_MEM,
+    COL_WCHAN,
+    COL_CGROUP,
+    COL_UNIT,
+    COL_SESSION,
+    COL_SEAT,
+    COL_OWNER,
+    COL_DISK_WRITE_TOTAL,
+    COL_DISK_READ_TOTAL,
+    COL_DISK_WRITE_CURRENT,
+    COL_DISK_READ_CURRENT,
+    COL_PRIORITY,
+    COL_SURFACE,
+    COL_POINTER,
+    COL_TOOLTIP,
+    NUM_COLUMNS
+};
+
+GtkWidget*      proctable_new (ProcData *data);
+void            proctable_update_table (ProcData *data);
+void            proctable_update (ProcData *data);
+void            proctable_clear_tree (ProcData *data);
+void            proctable_free_table (ProcData *data);
+
+GSList*         proctable_get_columns_order(GtkTreeView *treeview);
+void            proctable_set_columns_order(GtkTreeView *treeview, GSList *order);
+
+char*           make_loadavg_string(void);
+
+void            get_last_selected (GtkTreeModel *model, GtkTreePath *path,
+                                   GtkTreeIter *iter, gpointer data);
+
+#endif /* _PROCMAN_PROCTABLE_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/11.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/11.html new file mode 100644 index 00000000..cd51236f --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/11.html @@ -0,0 +1,499 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
// -*- mode: c++ -*-
+
+#ifndef H_MATE_SYSTEM_MONITOR_UTIL_1123178725
+#define H_MATE_SYSTEM_MONITOR_UTIL_1123178725
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+using std::string;
+
+/* check if logind is running */
+#define LOGIND_RUNNING() (access("/run/systemd/seats/", F_OK) >= 0)
+
+GtkWidget*
+procman_make_label_for_mmaps_or_ofiles(const char *format,
+                                       const char *process_name,
+                                       unsigned pid);
+
+gboolean
+load_symbols(const char *module, ...) G_GNUC_NULL_TERMINATED;
+
+gchar *
+procman_format_date_for_display(time_t time_raw);
+
+const char*
+format_process_state(guint state);
+
+void
+procman_debug_real(const char *file, int line, const char *func,
+                   const char *format, ...) G_GNUC_PRINTF(4, 5);
+
+#define procman_debug(FMT, ...) procman_debug_real(__FILE__, __LINE__, __func__, FMT, ##__VA_ARGS__)
+
+inline string make_string(char *c_str)
+{
+    if (!c_str) {
+        procman_debug("NULL string");
+        return string();
+    }
+
+    string s(c_str);
+    g_free(c_str);
+    return s;
+}
+
+namespace procman
+{
+    gchar* format_duration_for_display(unsigned centiseconds);
+
+    void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                    GtkTreeModel *model, GtkTreeIter *iter,
+                                    gpointer user_data);
+
+    void io_rate_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                GtkTreeModel *model, GtkTreeIter *iter,
+                                gpointer user_data);
+
+    void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                       GtkTreeModel *model, GtkTreeIter *iter,
+                                       gpointer user_data);
+
+    void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                     GtkTreeModel *model, GtkTreeIter *iter,
+                                     gpointer user_data);
+
+    void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                        GtkTreeModel *model, GtkTreeIter *iter,
+                                        gpointer user_data);
+
+    void duration_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                   GtkTreeModel *model, GtkTreeIter *iter,
+                   gpointer user_data);
+
+    void time_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                             GtkTreeModel *model, GtkTreeIter *iter,
+                             gpointer user_data);
+
+    void status_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                               GtkTreeModel *model, GtkTreeIter *iter,
+                               gpointer user_data);
+    void priority_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                               GtkTreeModel *model, GtkTreeIter *iter,
+                               gpointer user_data);
+    gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
+                            GtkTreeIter* second, gpointer user_data);
+    gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
+                            GtkTreeIter* second, gpointer user_data);
+
+    template<typename T>
+    void poison(T &t, char c)
+    {
+        memset(&t, c, sizeof t);
+    }
+
+    //
+    // Stuff to update a tree_store in a smart way
+    //
+
+    template<typename T>
+    void tree_store_update(GtkTreeModel* model, GtkTreeIter* iter, int column, const T& new_value)
+    {
+        T current_value;
+
+        gtk_tree_model_get(model, iter, column, &current_value, -1);
+
+        if (current_value != new_value)
+            gtk_tree_store_set(GTK_TREE_STORE(model), iter, column, new_value, -1);
+    }
+
+    // undefined
+    // catch every thing about pointers
+    // just to make sure i'm not doing anything wrong
+    template<typename T>
+    void tree_store_update(GtkTreeModel* model, GtkTreeIter* iter, int column, T* new_value);
+
+    // specialized versions for strings
+    template<>
+    void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value);
+
+    template<>
+    inline void tree_store_update<char>(GtkTreeModel* model, GtkTreeIter* iter, int column, char* new_value)<--- Parameter 'new_value' can be declared as pointer to const
+    {
+         tree_store_update<const char>(model, iter, column, new_value);
+    }
+
+    gchar* get_nice_level (gint nice);
+}
+
+#endif /* H_MATE_SYSTEM_MONITOR_UTIL_1123178725 */
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/12.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/12.html new file mode 100644 index 00000000..5c3897fb --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/12.html @@ -0,0 +1,341 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
/* Procman - dialogs
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef _PROCDIALOGS_H_
+#define _PROCDIALOGS_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+/* These are the actual range of settable values. Values outside this range
+   are scaled back to these limits. So show these limits in the slider
+*/
+#ifdef __linux__
+#define RENICE_VAL_MIN -20
+#define RENICE_VAL_MAX 19
+#else /* ! linux */
+#define RENICE_VAL_MIN -20
+#define RENICE_VAL_MAX 20
+#endif
+
+typedef enum
+{
+    PROCMAN_ACTION_RENICE,
+    PROCMAN_ACTION_KILL
+} ProcmanActionType;
+
+void                    procdialog_create_kill_dialog (ProcData *data, int signal);
+void                    procdialog_create_renice_dialog (ProcData *data);
+gboolean                procdialog_create_root_password_dialog (ProcmanActionType type,
+                                                                ProcData *procdata,
+                                                                gint pid, gint extra_value);
+void                    procdialog_create_memmaps_dialog (ProcData *data);
+void                    procdialog_create_preferences_dialog (ProcData *data);
+
+#endif
+
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/13.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/13.html new file mode 100644 index 00000000..07b0403f --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/13.html @@ -0,0 +1,255 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
1
+2
+3
+4
+5
+6
+7
+8
+9
#ifndef _PROCMAN_MEMMAPS_H_
+#define _PROCMAN_MEMMAPS_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+void            create_memmaps_dialog (ProcData *procdata);
+
+#endif /* _PROCMAN_MEMMAPS_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/14.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/14.html new file mode 100644 index 00000000..b5c26f21 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/14.html @@ -0,0 +1,257 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
#ifndef _OPENFILES_H_
+#define _OPENFILES_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+void            create_openfiles_dialog (ProcData *procdata);
+
+#endif
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/15.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/15.html new file mode 100644 index 00000000..119b30ea --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/15.html @@ -0,0 +1,299 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
/* Process properties dialog
+ * Copyright (C) 2010 Krishnan Parthasarathi <krishnan.parthasarathi@gmail.com>
+ *                    Robert Ancell <robert.ancell@canonical.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef _PROCPROPERTIES_H_
+#define _PROCPROPERTIES_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+void create_procproperties_dialog (ProcData *procdata);
+
+#endif
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/16.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/16.html new file mode 100644 index 00000000..553dbda6 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/16.html @@ -0,0 +1,489 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
#ifndef _PROCMAN_LOAD_GRAPH_H_
+#define _PROCMAN_LOAD_GRAPH_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+enum
+{
+    LOAD_GRAPH_CPU,
+    LOAD_GRAPH_MEM,
+    LOAD_GRAPH_NET
+};
+
+enum {
+    CPU_TOTAL,
+    CPU_USED,
+    N_CPU_STATES
+};
+
+struct LoadGraphLabels
+{
+    GtkWidget *cpu[GLIBTOP_NCPU];
+    GtkWidget *memory;
+    GtkWidget *swap;
+    GtkWidget *net_in;
+    GtkWidget *net_in_total;
+    GtkWidget *net_out;
+    GtkWidget *net_out_total;
+};
+
+struct LoadGraph {
+
+    static const unsigned NUM_POINTS = 60 + 2;
+    static const unsigned GRAPH_MIN_HEIGHT = 40;
+
+    LoadGraph(guint type);
+    ~LoadGraph();
+
+    unsigned num_bars() const;
+    void clear_background();
+
+    double fontsize;
+    double rmargin;
+    double indent;
+
+    guint n;
+    gint type;
+    guint speed;
+    guint draw_width, draw_height;
+    guint render_counter;
+    guint frames_per_unit;
+    guint graph_dely;
+    guint real_draw_height;
+    double graph_delx;
+    guint graph_buffer_offset;
+
+    std::vector<GdkRGBA> colors;
+
+    std::vector<float> data_block;
+    gfloat* data[NUM_POINTS];
+
+    GtkWidget *main_widget;
+    GtkWidget *disp;
+
+    cairo_pattern_t *background;
+
+    guint timer_index;
+
+    gboolean draw;
+
+    LoadGraphLabels labels;
+    GtkWidget *mem_color_picker;
+    GtkWidget *swap_color_picker;
+
+    /* union { */
+        struct {
+            guint now; /* 0 -> current, 1 -> last
+                    now ^ 1 each time */
+            /* times[now], times[now ^ 1] is last */
+            guint64 times[2][GLIBTOP_NCPU][N_CPU_STATES];
+        } cpu;
+
+        struct {
+            guint64 last_in, last_out;
+#if GLIB_CHECK_VERSION(2,61,2)
+            gint64 time;
+#else
+            GTimeVal time;
+#endif
+            guint64 max;
+            unsigned values[NUM_POINTS];
+            size_t cur;
+        } net;
+    /* }; */
+};
+
+/* Force a drawing update */
+void
+load_graph_queue_draw (LoadGraph *g);
+
+/* Start load graph. */
+void
+load_graph_start (LoadGraph *g);
+
+/* Stop load graph. */
+void
+load_graph_stop (LoadGraph *g);
+
+/* Change load graph speed and restart it if it has been previously started */
+void
+load_graph_change_speed (LoadGraph *g,
+                         guint new_speed);
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+#endif /* _PROCMAN_LOAD_GRAPH_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/17.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/17.html new file mode 100644 index 00000000..40d7d2b5 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/17.html @@ -0,0 +1,255 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
1
+2
+3
+4
+5
+6
+7
+8
+9
#ifndef H_PROCMAN_LSOF_1161179202
+#define H_PROCMAN_LSOF_1161179202
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+void procman_lsof(ProcData *data);
+
+#endif /* H_PROCMAN_LSOF_1161179202 */
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/18.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/18.html new file mode 100644 index 00000000..6cfdc63e --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/18.html @@ -0,0 +1,645 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <cstring><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "cgroups.h"
+#include "util.h"
+
+gboolean
+cgroups_enabled(void)
+{
+    static gboolean initialized = FALSE;
+    static gboolean has_cgroups;
+
+    if (!initialized) {
+        initialized = TRUE;
+        has_cgroups = g_file_test("/proc/cgroups", G_FILE_TEST_EXISTS);
+    }
+
+    return has_cgroups;
+}
+
+static void
+append_cgroup_name(char *line, gchar **current_cgroup_name)
+{
+    gchar *controller, *path, *tmp, *path_plus_space;
+    int paren_offset, off, tmp_size;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return;
+
+    *(path - 1) = '\0';
+    g_strdelimit(controller, ",", '/');
+
+    if ((std::strcmp(path, "/") == 0) || (std::strncmp(controller, "name=", 5) == 0))
+        return;
+
+    if (*current_cgroup_name == NULL) {
+        *current_cgroup_name = g_strdup_printf("%s (%s)", path, controller);
+        return;
+    }
+
+    /* add a space to the end of the path string */
+    path_plus_space = g_strdup_printf("%s ", path);
+
+    if ((tmp = g_strstr_len(*current_cgroup_name, -1, path_plus_space))) {
+        tmp_size = strlen(*current_cgroup_name) + strlen(controller) + 1;
+        paren_offset = g_strstr_len(tmp + strlen(path), -1, ")") - *current_cgroup_name;
+        *(*current_cgroup_name + paren_offset) = '\0';
+        tmp = (gchar *)g_strnfill(tmp_size, '\0');
+        off = g_strlcat(tmp, *current_cgroup_name, tmp_size);
+        *(tmp + off) = '/';
+        off++;
+        off += g_strlcat(tmp + off, controller, tmp_size);
+        *(tmp + off) = ')';
+        off++;
+        g_strlcat(tmp + off, *current_cgroup_name + paren_offset + 1, tmp_size);
+    } else
+        tmp = g_strdup_printf("%s, %s(%s)", *current_cgroup_name, path_plus_space, controller);
+
+    g_free(path_plus_space);
+    g_free(*current_cgroup_name);
+    *current_cgroup_name = tmp;
+}
+
+static int
+check_cgroup_changed(gchar *line, gchar *current_cgroup_set)
+{
+    /* check if line is contained in current_cgroup_set */
+    gchar *controller, *path, *tmp, *found, *close_paren, *open_paren;
+    int ret = 0;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return 1;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return 1;
+
+    *(path - 1) = '\0';
+
+    if (std::strncmp(controller, "name=", 5) == 0)
+        goto out;
+
+    /* if there are multiple controllers just report string has changed */
+    if (g_strstr_len(controller, -1, ",")) {
+        ret = 1;
+        goto out;
+    }
+
+    if (!current_cgroup_set) {
+        if (std::strcmp(path, "/") != 0)
+            ret = 1;
+        goto out;
+    }
+
+    /* special case for root cgroup */
+    tmp = current_cgroup_set;
+    if (std::strcmp(path, "/") == 0) {
+        while ((found = g_strstr_len(tmp, -1, controller))) {
+            close_paren = g_strstr_len(found, -1, ")");
+            open_paren = g_strstr_len(found, -1, "(");
+            if (close_paren) {
+                if (!open_paren || (close_paren < open_paren)) {
+                    ret = 1;
+                    goto out;
+                }
+            }
+            tmp = found + strlen(controller);
+        }
+        goto out;
+    }
+
+    tmp = current_cgroup_set;
+    while ((found = g_strstr_len(tmp, -1, path))) {
+            found = found + strlen(path);
+            close_paren = g_strstr_len(found, -1, ")");
+            if (*found == ' ') {
+                if (g_strstr_len(found + 1, close_paren - found, controller))
+                    goto out;
+            }
+            tmp = close_paren + 1;
+    }
+    ret = 1;
+out:
+    *(path - 1) = ':';
+    return ret;
+}
+
+void
+get_process_cgroup_info(ProcInfo *info)
+{
+    gchar *path;
+    gchar *cgroup_name = NULL;
+    int cgroups_changed = 0;
+    gchar *text;
+    char **lines;
+    int i;
+
+    if (!cgroups_enabled())
+        return;
+
+    /* read out of /proc/pid/cgroup */
+    path = g_strdup_printf("/proc/%d/cgroup", info->pid);
+    if (!path)
+        return;
+    if(!g_file_get_contents(path, &text, NULL, NULL))
+        goto out;
+    lines = g_strsplit(text, "\n", -1);
+    g_free(text);
+    if (!lines)
+        goto out;
+
+    for (i = 0; lines[i] != NULL; i++) {
+        if (lines[i][0] == '\0')
+            continue;
+        if (check_cgroup_changed(lines[i], info->cgroup_name)) {
+            cgroups_changed = 1;
+            break;
+        }
+    }
+
+    if (cgroups_changed) {
+        for (i = 0; lines[i] != NULL; i++) {
+            if (lines[i][0] == '\0')
+                continue;
+            append_cgroup_name(lines[i], &cgroup_name);
+        }
+        if (info->cgroup_name)
+            g_free(info->cgroup_name);
+        if (!cgroup_name)
+            info->cgroup_name = g_strdup("");
+        else
+            info->cgroup_name = cgroup_name;
+    }
+
+    g_strfreev(lines);
+out:
+    g_free(path);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/19.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/19.html new file mode 100644 index 00000000..f9dfbcbd --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/19.html @@ -0,0 +1,261 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
#ifndef PROCMAN_CGROUP_H_20111103
+#define PROCMAN_CGROUP_H_20111103
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+void get_process_cgroup_info (ProcInfo *info);
+
+gboolean cgroups_enabled (void);
+
+#endif /* PROCMAN_CGROUP_H_20111103 */
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/2.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/2.html new file mode 100644 index 00000000..ddc7b909 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/2.html @@ -0,0 +1,1289 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
/* Procman - callbacks
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <giomm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "callbacks.h"
+#include "interface.h"
+#include "proctable.h"
+#include "util.h"
+#include "procactions.h"
+#include "procman.h"
+#include "procdialogs.h"
+#include "memmaps.h"
+#include "openfiles.h"
+#include "procproperties.h"
+#include "load-graph.h"
+#include "disks.h"
+#include "lsof.h"
+#include "sysinfo.h"
+
+void
+cb_kill_sigstop(GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    /* no confirmation */
+    kill_process (procdata, SIGSTOP);
+}
+
+
+
+
+void
+cb_kill_sigcont(GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    /* no confirmation */
+    kill_process (procdata, SIGCONT);
+}
+
+
+
+
+static void
+kill_process_helper(ProcData *procdata, int sig)
+{
+    if (procdata->config.show_kill_warning)
+        procdialog_create_kill_dialog (procdata, sig);
+    else
+        kill_process (procdata, sig);
+}
+
+
+void
+cb_edit_preferences (GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdialog_create_preferences_dialog (procdata);
+}
+
+
+void
+cb_renice (GtkAction *action, GtkRadioAction *current, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    gint selected = gtk_radio_action_get_current_value(current);
+
+    if (selected == CUSTOM_PRIORITY)
+    {
+       procdialog_create_renice_dialog (procdata);
+    } else {
+       gint new_nice_value = 0;
+       switch (selected) {
+           case VERY_HIGH_PRIORITY: new_nice_value = -20; break;
+           case HIGH_PRIORITY: new_nice_value = -5; break;
+           case NORMAL_PRIORITY: new_nice_value = 0; break;
+           case LOW_PRIORITY: new_nice_value = 5; break;
+           case VERY_LOW_PRIORITY: new_nice_value = 19; break;
+       }
+       renice(procdata, new_nice_value);
+    }
+}
+
+
+void
+cb_end_process (GtkAction *action, gpointer data)
+{
+    kill_process_helper(static_cast<ProcData*>(data), SIGTERM);
+}
+
+
+void
+cb_kill_process (GtkAction *action, gpointer data)
+{
+    kill_process_helper(static_cast<ProcData*>(data), SIGKILL);
+}
+
+
+void
+cb_show_memory_maps (GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    create_memmaps_dialog (procdata);
+}
+
+void
+cb_show_open_files (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    create_openfiles_dialog (procdata);
+}
+
+void
+cb_show_process_properties (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    create_procproperties_dialog (procdata);
+}
+
+void
+cb_show_lsof(GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    procman_lsof(procdata);
+}
+
+
+void
+cb_about (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    const gchar * const authors[] = {
+        "Adam Erdman <hekel@archlinux.info>",
+        "Alexander Pyhalov <apyhalov@gmail.com>",
+        "Andreas Nilsson <nisses.mail@home.se>",
+        "Benoît Dejean <bdejean@gmail.com>",
+        "Chris Kühl <chrisk@openismus.com>",
+        "Clement Lefebvre <clement.lefebvre@linuxmint.com>",
+        "Elias Aebi <user142@hotmail.com>",
+        "Erik Johnsson",
+        "Jorgen Scheibengruber",
+        "Karl Lattimer",
+        "Kevin Vandersloot",
+        "Laurent Napias <tamplan@free.fr>",
+        "Marcel Dijkstra <marcel.dykstra@gmail.com>",
+        "Martin Wimpress <martin@mate-desktop.org>",
+        "Matias De lellis <mati86dl@gmail.com>",
+        "Mike Gabriel <mike.gabriel@das-netzwerkteam.de>",
+        "Nelson Marques <nmo.marques@gmail.com>",
+        "Obata Akio https://github.com/obache",
+        "Pablo Barciela <scow@riseup.net>",
+        "Paolo Borelli",
+        "Perberos <perberos@gmail.com>",
+        "Piotr DrÄ…g <piotrdrag@gmail.com>",
+        "Robert Buj <robert.buj@gmail.com>",
+        "Sander Sweers <infirit@gmail.com>",
+        "Scott Balneaves <sbalneav@alburg.net>",
+        "Soong Noonien https://github.com/SoongNoonien",
+        "Stefano Karapetsas <stefano@karapetsas.com>",
+        "Steve Zesch <stevezesch2@gmail.com>",
+        "Victor Kareh <vkareh@redhat.com>",
+        "Vlad Orlov <monsta@inbox.ru>",
+        "Wolfgang Ulbrich <mate@raveit.de>",
+        "Wu Xiaotian <yetist@gmail.com>",
+        "Yaakov Selkowitz <yselkowitz@users.sourceforge.net>",
+        "Youri Mouton <youri@NetBSD.org>",
+        NULL
+    };
+
+    const gchar * const documenters[] = {
+        "Bill Day",
+        "Sun Microsystems",
+        NULL
+    };
+
+    const gchar * const artists[] = {
+        "Baptiste Mille-Mathias",
+        NULL
+    };
+
+    const gchar * license[] = {
+        N_("System Monitor is free software; you can redistribute it and/or modify "
+        "it under the terms of the GNU General Public License as published by "
+        "the Free Software Foundation; either version 2 of the License, or "
+        "(at your option) any later version."),
+        N_("System Monitor is distributed in the hope that it will be useful, "
+        "but WITHOUT ANY WARRANTY; without even the implied warranty of "
+        "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the "
+        "GNU General Public License for more details."),
+        N_("You should have received a copy of the GNU General Public License "
+        "along with System Monitor; if not, write to the Free Software Foundation, Inc., "
+        "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA")
+    };
+
+    gchar *license_trans;
+    license_trans = g_strjoin ("\n\n", _(license[0]), _(license[1]), _(license[2]), NULL);
+
+    gtk_show_about_dialog (
+        GTK_WINDOW (procdata->app),
+        "program-name",       _("System Monitor"),
+        "version",            VERSION,
+        "title",              _("About System Monitor"),
+        "comments",           _("View current processes and monitor system state"),
+        "copyright",          _("Copyright \xc2\xa9 2001-2004 Kevin Vandersloot\n"
+                                "Copyright \xc2\xa9 2005-2007 Benoît Dejean\n"
+                                "Copyright \xc2\xa9 2011-2020 MATE developers"),
+        "logo-icon-name",     "utilities-system-monitor",
+        "authors",            authors,
+        "artists",            artists,
+        "documenters",        documenters,
+        "translator-credits", _("translator-credits"),
+        "license",            license_trans,
+        "wrap-license",       TRUE,
+        "website",            PACKAGE_URL,
+        NULL
+        );
+
+    g_free (license_trans);
+}
+
+
+void
+cb_help_contents (GtkAction *action, gpointer data)
+{
+    GError* error = 0;
+    if (!g_app_info_launch_default_for_uri("help:mate-system-monitor", NULL, &error)) {
+        g_warning("Could not display help : %s", error->message);
+        g_error_free(error);
+    }
+}
+
+
+void
+cb_app_exit (GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    cb_app_delete (NULL, NULL, procdata);
+    gtk_widget_destroy (procdata->app);
+}
+
+
+gboolean
+cb_app_delete (GtkWidget *window, GdkEventAny *event, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procman_save_config (procdata);
+    if (procdata->timeout)
+        g_source_remove (procdata->timeout);
+    if (procdata->disk_timeout)
+        g_source_remove (procdata->disk_timeout);
+
+    procdata->terminating = TRUE;
+
+    return FALSE;
+}
+
+
+
+void
+cb_end_process_button_pressed (GtkButton *button, gpointer data)
+{
+    kill_process_helper(static_cast<ProcData*>(data), SIGTERM);
+}
+
+
+static void change_settings_color(GSettings *settings, const char *key,
+                   GSMColorButton *cp)
+{
+    GdkRGBA c;
+    char *color;
+
+    gsm_color_button_get_color(cp, &c);
+    color = gdk_rgba_to_string (&c);
+    g_settings_set_string (settings, key, color);
+    g_free (color);
+}
+
+
+void
+cb_cpu_color_changed (GSMColorButton *cp, gpointer data)
+{
+    char key[80];
+    gint i = GPOINTER_TO_INT (data);
+    GSettings *settings = g_settings_new (GSM_GSETTINGS_SCHEMA);
+
+    g_snprintf(key, sizeof key, "cpu-color%d", i);
+
+    change_settings_color(settings, key, cp);
+}
+
+void
+cb_mem_color_changed (GSMColorButton *cp, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    change_settings_color(procdata->settings, "mem-color", cp);
+}
+
+
+void
+cb_swap_color_changed (GSMColorButton *cp, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    change_settings_color(procdata->settings, "swap-color", cp);
+}
+
+void
+cb_net_in_color_changed (GSMColorButton *cp, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    change_settings_color(procdata->settings, "net-in-color", cp);
+}
+
+void
+cb_net_out_color_changed (GSMColorButton *cp, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    change_settings_color(procdata->settings, "net-out-color", cp);
+}
+
+void
+cb_row_selected (GtkTreeSelection *selection, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->selection = selection;
+
+    procdata->selected_process = NULL;
+
+    /* get the most recent selected process and determine if there are
+    ** no selected processes
+    */
+    gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                         &procdata->selected_process);
+    if (procdata->selected_process) {
+        gint value;
+        gint nice = procdata->selected_process->nice;
+        if (nice < -7)
+            value = VERY_HIGH_PRIORITY;
+        else if (nice < -2)
+            value = HIGH_PRIORITY;
+        else if (nice < 3)
+            value = NORMAL_PRIORITY;
+        else if (nice < 7)
+            value = LOW_PRIORITY;
+        else
+            value = VERY_LOW_PRIORITY;
+
+        GtkRadioAction* normal = GTK_RADIO_ACTION(gtk_action_group_get_action(procdata->action_group, "Normal"));
+        block_priority_changed_handlers(procdata, TRUE);
+        gtk_radio_action_set_current_value(normal, value);
+        block_priority_changed_handlers(procdata, FALSE);
+
+    }
+    update_sensitivity(procdata);
+}
+
+
+gboolean
+cb_tree_button_pressed (GtkWidget *widget,
+            GdkEventButton *event,
+            gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
+        do_popup_menu (procdata, event);
+
+    return FALSE;
+}
+
+
+gboolean
+cb_tree_popup_menu (GtkWidget *widget, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    do_popup_menu (procdata, NULL);
+
+    return TRUE;
+}
+
+
+void
+cb_switch_page (GtkNotebook *nb, GtkWidget *page,
+        gint num, gpointer data)
+{
+    cb_change_current_page (nb, num, data);
+}
+
+void
+cb_change_current_page (GtkNotebook *nb, gint num, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->config.current_tab = num;
+
+
+    if (num == PROCMAN_TAB_PROCESSES) {
+
+        cb_timeout (procdata);
+
+        if (!procdata->timeout)
+            procdata->timeout = g_timeout_add (
+                procdata->config.update_interval,
+                cb_timeout, procdata);
+
+        update_sensitivity(procdata);
+    }
+    else {
+        if (procdata->timeout) {
+            g_source_remove (procdata->timeout);
+            procdata->timeout = 0;
+        }
+
+        update_sensitivity(procdata);
+    }
+
+
+    if (num == PROCMAN_TAB_RESOURCES) {
+        load_graph_start (procdata->cpu_graph);
+        load_graph_start (procdata->mem_graph);
+        load_graph_start (procdata->net_graph);
+    }
+    else {
+        load_graph_stop (procdata->cpu_graph);
+        load_graph_stop (procdata->mem_graph);
+        load_graph_stop (procdata->net_graph);
+    }
+
+
+    if (num == PROCMAN_TAB_DISKS) {
+
+        cb_update_disks (procdata);
+
+        if(!procdata->disk_timeout) {
+            procdata->disk_timeout =
+                g_timeout_add (procdata->config.disks_update_interval,
+                           cb_update_disks,
+                           procdata);
+        }
+    }
+    else {
+        if(procdata->disk_timeout) {
+            g_source_remove (procdata->disk_timeout);
+            procdata->disk_timeout = 0;
+        }
+    }
+
+    if (num == PROCMAN_TAB_SYSINFO) {
+        procman::build_sysinfo_ui();
+    }
+}
+
+
+
+gint
+cb_user_refresh (GtkAction*, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    proctable_update (procdata);
+    return FALSE;
+}
+
+
+gint
+cb_timeout (gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    guint new_interval;
+
+    if (!procdata->terminating) {
+        proctable_update (procdata);
+
+        if (procdata->smooth_refresh->get(new_interval))
+        {
+            procdata->timeout = g_timeout_add(new_interval,
+                                              cb_timeout,
+                                              procdata);
+            return FALSE;
+        }
+    }
+    return TRUE;
+}
+
+
+void
+cb_radio_processes(GtkAction *action, GtkRadioAction *current, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->config.whose_process = gtk_radio_action_get_current_value(current);
+
+    g_settings_set_int (procdata->settings, "view-as",
+                  procdata->config.whose_process);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/20.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/20.html new file mode 100644 index 00000000..14abdda6 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/20.html @@ -0,0 +1,1277 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __linux__
+#include <mntent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif // __linux__
+
+#include <giomm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/themedicon.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mountlist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/fsusage.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "disks.h"
+#include "util.h"
+#include "interface.h"
+#include "iconthemewrapper.h"
+
+namespace
+{
+  const unsigned DISK_ICON_SIZE = 24;
+}
+
+enum DiskColumns
+{
+    /* string columns* */
+    DISK_DEVICE,
+    DISK_DIR,
+    DISK_TYPE,
+    DISK_SUBVOLUME,
+    DISK_TOTAL,
+    DISK_FREE,
+    DISK_AVAIL,
+    /* USED has to be the last column */
+    DISK_USED,
+    // then unvisible columns
+    /* Surface column */
+    DISK_ICON,
+    /* numeric columns */
+    DISK_USED_PERCENTAGE,
+    DISK_N_COLUMNS
+};
+
+
+
+static void
+fsusage_stats(const glibtop_fsusage *buf,
+              guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
+              gint *percentage)
+{
+    guint64 total = buf->blocks * buf->block_size;
+
+    if (!total) {
+        /* not a real device */
+        *btotal = *bfree = *bavail = *bused = 0ULL;
+        *percentage = 0;
+    } else {
+        int percent;
+        *btotal = total;
+        *bfree = buf->bfree * buf->block_size;
+        *bavail = buf->bavail * buf->block_size;
+        *bused = *btotal - *bfree;
+        /* percent = 100.0f * *bused / *btotal; */
+        percent = 100 * *bused / (*bused + *bavail);
+        *percentage = CLAMP(percent, 0, 100);
+    }
+}
+
+
+namespace
+{
+    string get_icon_for_path(const std::string& path)
+    {
+        using namespace Glib;
+        using namespace Gio;
+
+        // FIXME: I don't know whether i should use Volume or Mount or UnixMount
+        // all i need an icon name.
+        RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+        std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
+
+        for (size_t i = 0; i != mounts.size(); ++i) {
+            if (mounts[i]->get_name() != path)
+                continue;
+
+            RefPtr<Icon> icon = mounts[i]->get_icon();
+            RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
+
+            if (themed_icon) {
+                char* name = 0;
+                // FIXME: not wrapped yet
+                g_object_get(G_OBJECT(themed_icon->gobj()), "name", &name, NULL);
+                return make_string(name);
+            }
+        }
+
+        return "";
+    }
+}
+
+
+static Glib::RefPtr<Gdk::Pixbuf>
+get_icon_for_device(const char *mountpoint)
+{
+    procman::IconThemeWrapper icon_theme;
+    string icon_name = get_icon_for_path(mountpoint);
+    if (icon_name == "")
+        // FIXME: defaults to a safe value
+        icon_name = "drive-harddisk"; // get_icon_for_path("/");
+    return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
+}
+
+
+static gboolean
+find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
+                   GtkTreeIter *result)
+{
+    GtkTreeIter iter;
+    gboolean found = FALSE;
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        do {
+            char *dir;
+
+            gtk_tree_model_get(model, &iter,
+                               DISK_DIR, &dir,
+                               -1);
+
+            if (dir && !strcmp(dir, mountpoint)) {
+                *result = iter;
+                found = TRUE;
+            }
+
+            g_free(dir);
+
+        } while (!found && gtk_tree_model_iter_next(model, &iter));
+    }
+
+    return found;
+}
+
+
+
+static void
+remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
+{
+    GtkTreeIter iter;
+
+    if (!gtk_tree_model_get_iter_first(model, &iter))
+        return;
+
+    while (true) {
+        char *dir;
+        guint i;
+        gboolean found = FALSE;
+
+        gtk_tree_model_get(model, &iter,
+                           DISK_DIR, &dir,
+                           -1);
+
+        for (i = 0; i != n; ++i) {
+            if (!strcmp(dir, entries[i].mountdir)) {
+                found = TRUE;
+                break;
+            }
+        }
+
+        g_free(dir);
+
+        if (!found) {
+            if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                break;
+            else
+                continue;
+        }
+
+        if (!gtk_tree_model_iter_next(model, &iter))
+            break;
+    }
+}
+
+#ifdef __linux__
+static char *
+get_mount_opt(const glibtop_mountentry *entry, const char* opt)
+{
+    char *opt_value = NULL;
+    const struct mntent *mnt;
+    FILE *fp;
+
+    if (!(fp = setmntent(MOUNTED, "r"))) {
+        goto out;
+    }
+
+    while ((mnt = getmntent(fp))) {
+        if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
+            (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
+            char *res;
+
+            res = hasmntopt(mnt, "subvol");<--- res is assigned
+            if ((res = hasmntopt(mnt, "subvol")) != NULL) {<--- res is overwritten
+                char **strs = g_strsplit_set(res, "=", 2);
+
+                if (g_strv_length(strs) == 2) {
+                    char *value = strs[1];
+                    if (g_strcmp0 (value,"/root") == 0)
+                       opt_value = g_strdup("/");
+                    else
+                        opt_value = g_strdup(strs[1]);
+                    g_strfreev(strs);
+                }
+            }
+            break;
+        }
+    }
+
+    endmntent(fp);
+
+  out:
+     return opt_value;
+}
+#endif // __linux__
+
+
+static void
+add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
+{
+    Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+    cairo_surface_t *surface;
+    GtkTreeIter iter;
+    glibtop_fsusage usage;
+    guint64 bused, bfree, bavail, btotal;
+    gint percentage;
+#ifdef __linux__
+    char *subvol = NULL;
+#endif // __linux__
+
+    glibtop_get_fsusage(&usage, entry->mountdir);
+
+    if (not show_all_fs and usage.blocks == 0) {
+        if (find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+            gtk_list_store_remove(list, &iter);
+        return;
+    }
+
+    fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
+#ifdef __linux__
+    subvol = get_mount_opt(entry, "subvol");
+#endif // __linux__
+    pixbuf = get_icon_for_device(entry->mountdir);
+    surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL);
+
+    /* if we can find a row with the same mountpoint, we get it but we
+       still need to update all the fields.
+       This makes selection persistent.
+    */
+    if (!find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+        gtk_list_store_append(list, &iter);
+
+    gtk_list_store_set(list, &iter,
+                       DISK_ICON, surface,
+                       DISK_DEVICE, entry->devname,
+                       DISK_DIR, entry->mountdir,
+                       DISK_TYPE, entry->type,
+#ifdef __linux__
+
+                       DISK_SUBVOLUME, subvol != NULL ? subvol : "",
+#else
+                       DISK_SUBVOLUME, "",
+#endif // __linux__
+                       DISK_USED_PERCENTAGE, percentage,
+                       DISK_TOTAL, btotal,
+                       DISK_FREE, bfree,
+                       DISK_AVAIL, bavail,
+                       DISK_USED, bused,
+                       -1);
+#ifdef __linux__
+    g_free (subvol);
+#endif // __linux__
+}
+
+
+
+int
+cb_update_disks(gpointer data)
+{
+    ProcData *const procdata = static_cast<ProcData*>(data);
+
+    GtkListStore *list;
+    glibtop_mountentry * entries;
+    glibtop_mountlist mountlist;
+    guint i;
+
+    list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)));
+
+    entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
+
+    remove_old_disks(GTK_TREE_MODEL(list), entries, mountlist.number);
+
+    for (i = 0; i < mountlist.number; i++)
+        add_disk(list, &entries[i], procdata->config.show_all_fs);
+
+    g_free(entries);
+
+    return TRUE;
+}
+
+
+static void
+cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "disktreenew");
+}
+
+
+static void
+open_dir(GtkTreeView       *tree_view,
+         GtkTreePath       *path,
+         GtkTreeViewColumn *column,
+         gpointer           user_data)
+{
+    GtkTreeIter iter;
+    GtkTreeModel *model;
+    char *dir, *url;
+
+    model = gtk_tree_view_get_model(tree_view);
+
+    if (!gtk_tree_model_get_iter(model, &iter, path)) {
+        char *p;
+        p = gtk_tree_path_to_string(path);
+        g_warning("Cannot get iter for path '%s'\n", p);
+        g_free(p);
+        return;
+    }
+
+    gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
+
+    url = g_strdup_printf("file://%s", dir);
+
+    GError* error = 0;
+    if (!g_app_info_launch_default_for_uri(url, NULL, &error)) {
+        g_warning("Cannot open '%s' : %s\n", url, error->message);
+        g_error_free(error);
+    }
+
+    g_free(url);
+    g_free(dir);
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "disktreenew");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+void
+create_disk_view(ProcData *procdata, GtkBuilder *builder)
+{
+    GtkWidget *scrolled;
+    GtkWidget *disk_tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *col;
+    GtkCellRenderer *cell;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Device"),
+        N_("Directory"),
+        N_("Type"),
+        N_("SubVolume"),
+        N_("Total"),
+        N_("Free"),
+        N_("Available"),
+        N_("Used")
+    };
+
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"));
+
+    model = gtk_list_store_new(DISK_N_COLUMNS,             /* n columns */
+                               G_TYPE_STRING,              /* DISK_DEVICE */
+                               G_TYPE_STRING,              /* DISK_DIR */
+                               G_TYPE_STRING,              /* DISK_TYPE */
+                               G_TYPE_STRING,              /* DISK_SUBVOLUME */
+                               G_TYPE_UINT64,              /* DISK_TOTAL */
+                               G_TYPE_UINT64,              /* DISK_FREE */
+                               G_TYPE_UINT64,              /* DISK_AVAIL */
+                               G_TYPE_UINT64,              /* DISK_USED */
+                               CAIRO_GOBJECT_TYPE_SURFACE, /* DISK_ICON */
+                               G_TYPE_INT);                /* DISK_USED_PERCENTAGE */
+
+    disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL);
+    procdata->disk_list = disk_tree;
+    gtk_container_add(GTK_CONTAINER(scrolled), disk_tree);
+    g_object_unref(G_OBJECT(model));
+
+    /* icon + device */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
+                                        NULL);
+
+    cell = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
+                                        NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 30);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* sizes - used */
+
+    for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_min_width (col, 30);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+        switch (i) {
+            case DISK_TOTAL:
+            case DISK_FREE:
+            case DISK_AVAIL:
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+        default:
+            gtk_tree_view_column_set_attributes(col, cell,
+                                                "text", i,
+                                                NULL);
+            break;
+        }
+    }
+
+    /* used + percentage */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_text_new();
+    g_object_set(cell, "xalign", 1.0f, NULL);
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_cell_data_func(col, cell,
+                                            &procman::storage_size_cell_data_func,
+                                            GUINT_TO_POINTER(DISK_USED),
+                                            NULL);
+
+    cell = gtk_cell_renderer_progress_new();
+    gtk_tree_view_column_pack_start(col, cell, TRUE);
+    gtk_tree_view_column_set_attributes(col, cell, "value",
+                                        DISK_USED_PERCENTAGE, NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_USED]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 150);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* numeric sort */
+
+    procman_get_tree_state(procdata->settings, disk_tree,
+                   "disktreenew");
+
+    g_signal_connect (G_OBJECT(disk_tree), "columns-changed",
+                      G_CALLBACK(cb_disk_columns_changed), procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/21.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/21.html new file mode 100644 index 00000000..36328855 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/21.html @@ -0,0 +1,2141 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
+852
+853
+854
+855
+856
+857
+858
+859
+860
+861
+862
+863
+864
+865
+866
+867
+868
+869
+870
+871
+872
+873
+874
+875
+876
+877
+878
+879
+880
+881
+882
+883
+884
+885
+886
+887
+888
+889
+890
+891
+892
+893
+894
+895
+896
+897
+898
+899
+900
+901
+902
+903
+904
+905
+906
+907
+908
+909
+910
+911
+912
+913
+914
+915
+916
+917
+918
+919
+920
+921
+922
+923
+924
+925
+926
+927
+928
+929
+930
+931
+932
+933
+934
+935
+936
+937
+938
+939
+940
+941
+942
+943
+944
+945
+946
/*
+ * Mate system monitor color pickers
+ * Copyright (C) 2007 Karl Lattimer <karl@qdh.org.uk>
+ * Copyright (C) 2012-2021 MATE Developers
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with the software; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkkeysyms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <cairo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <librsvg/rsvg.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm_color_button.h"
+
+typedef struct {
+    GtkWidget *cc_dialog;		/* Color chooser dialog */
+
+    gchar *title;            /* Title for the color selection window */
+
+    GdkRGBA color;
+
+    gdouble fraction;        /* Only used by GSMCP_TYPE_PIE */
+    guint type;
+    cairo_surface_t *image_buffer;
+    gdouble highlight;
+    gboolean button_down;
+    gboolean in_button;
+} GSMColorButtonPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GSMColorButton, gsm_color_button, GTK_TYPE_DRAWING_AREA)
+
+/* Properties */
+enum
+{
+    PROP_0,
+    PROP_PERCENTAGE,
+    PROP_TITLE,
+    PROP_COLOR,
+    PROP_TYPE
+};
+
+/* Signals */
+enum
+{
+    COLOR_SET,
+    LAST_SIGNAL
+};
+
+#define GSMCP_MIN_WIDTH 15
+#define GSMCP_MIN_HEIGHT 15
+
+static void gsm_color_button_finalize (GObject * object);
+static void gsm_color_button_set_property (GObject * object, guint param_id,
+                                           const GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_get_property (GObject * object, guint param_id,
+                                           GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_realize (GtkWidget * widget);
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width);
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height);
+static void gsm_color_button_size_allocate (GtkWidget * widget,
+                                            GtkAllocation * allocation);
+static void gsm_color_button_unrealize (GtkWidget * widget);
+static void gsm_color_button_state_changed (GtkWidget * widget,
+                                            GtkStateType previous_state);
+static void gsm_color_button_style_set (GtkWidget * widget,
+                                        GtkStyle * previous_style);
+static gint gsm_color_button_pressed (GtkWidget * widget,
+                                      GdkEventButton * event);
+static gint gsm_color_button_released (GtkWidget * widget,
+                                       GdkEventButton * event);
+static gboolean gsm_color_button_enter_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+static gboolean gsm_color_button_leave_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+/* source side drag signals */
+static void gsm_color_button_drag_begin (GtkWidget * widget,
+                                         GdkDragContext * context,
+                                         gpointer data);
+static void gsm_color_button_drag_data_get (GtkWidget * widget,
+                                            GdkDragContext * context,
+                                            GtkSelectionData * selection_data,
+                                            guint info, guint time,
+                                            GSMColorButton * color_button);
+
+/* target side drag signals */
+static void gsm_color_button_drag_data_received (GtkWidget * widget,
+                                                 GdkDragContext * context,
+                                                 gint x,
+                                                 gint y,
+                                                 GtkSelectionData *
+                                                 selection_data, guint info,
+                                                 guint32 time,
+                                                 GSMColorButton *
+                                                 color_button);
+
+static guint color_button_signals[LAST_SIGNAL] = { 0 };
+
+static const GtkTargetEntry drop_types[] = { {"application/x-color", 0, 0} };
+
+static void
+gsm_color_button_class_init (GSMColorButtonClass * klass)
+{
+    GObjectClass *gobject_class;
+    GtkWidgetClass *widget_class;
+
+    gobject_class = G_OBJECT_CLASS (klass);
+    widget_class = GTK_WIDGET_CLASS (klass);
+
+    gobject_class->get_property = gsm_color_button_get_property;
+    gobject_class->set_property = gsm_color_button_set_property;
+    gobject_class->finalize = gsm_color_button_finalize;
+    widget_class->state_changed = gsm_color_button_state_changed;
+    widget_class->get_preferred_width = gsm_color_button_get_preferred_width;
+    widget_class->get_preferred_height = gsm_color_button_get_preferred_height;
+    widget_class->size_allocate = gsm_color_button_size_allocate;
+    widget_class->realize = gsm_color_button_realize;
+    widget_class->unrealize = gsm_color_button_unrealize;
+    widget_class->style_set = gsm_color_button_style_set;
+    widget_class->button_release_event = gsm_color_button_released;
+    widget_class->button_press_event = gsm_color_button_pressed;<--- You might need to cast the function pointer here
+    widget_class->enter_notify_event = gsm_color_button_enter_notify;
+    widget_class->leave_notify_event = gsm_color_button_leave_notify;
+
+    klass->color_set = NULL;
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_PERCENTAGE,
+                                     g_param_spec_double ("fraction",
+                                                          _("Fraction"),
+                                     // TRANSLATORS: description of the pie color picker's (mem, swap) filled percentage property
+                                                          _("Percentage full for pie color pickers"),
+                                                          0, 1, 0.5,
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TITLE,
+                                     g_param_spec_string ("title",
+                                                          _("Title"),
+                                                          _("The title of the color selection dialog"),
+                                                          _("Pick a Color"),
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_COLOR,
+                                     g_param_spec_boxed ("color",
+                                                         _("Current Color"),
+                                                         _("The selected color"),
+                                                         GDK_TYPE_RGBA,
+                                                         G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TYPE,
+                                     g_param_spec_uint ("type", _("Type"),
+                                                        _("Type of color picker"),
+                                                        0, 4, 0,
+                                                        G_PARAM_READWRITE));
+
+    color_button_signals[COLOR_SET] = g_signal_new ("color_set",
+                                                    G_TYPE_FROM_CLASS
+                                                    (gobject_class),
+                                                    G_SIGNAL_RUN_FIRST,
+                                                    G_STRUCT_OFFSET
+                                                    (GSMColorButtonClass,
+                                                    color_set), NULL, NULL,
+                                                    g_cclosure_marshal_VOID__VOID,
+                                                    G_TYPE_NONE, 0);
+
+}
+
+static cairo_surface_t *
+fill_image_buffer_from_file (cairo_t *cr, const char *filePath)
+{
+    GError *error = NULL;
+    RsvgHandle *handle;
+    cairo_surface_t *tmp_surface;
+    cairo_t *tmp_cr;
+
+    handle = rsvg_handle_new_from_file (filePath, &error);
+
+    if (handle == NULL) {
+        g_warning("rsvg_handle_new_from_file(\"%s\") failed: %s",
+              filePath, (error ? error->message : "unknown error"));
+    if (error)
+          g_error_free(error);
+    return NULL;
+    }
+
+    tmp_surface = cairo_surface_create_similar (cairo_get_target (cr),
+                                                CAIRO_CONTENT_COLOR_ALPHA,
+                                                32, 32);
+    tmp_cr = cairo_create (tmp_surface);
+    rsvg_handle_render_cairo (handle, tmp_cr);
+    cairo_destroy (tmp_cr);
+    g_object_unref (handle);
+    return tmp_surface;
+}
+
+static void
+render (GtkWidget * widget)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GdkRGBA *color;
+    GdkRGBA tmp_color = priv->color;
+    color = &tmp_color;
+    cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
+    cairo_path_t *path = NULL;
+    gint width, height;
+    gdouble radius, arc_start, arc_end;
+    gdouble highlight_factor;
+
+    if (priv->highlight > 0) {
+        highlight_factor = 0.125 * priv->highlight;
+
+    if (color->red + highlight_factor > 1.0)
+        color->red = 1.0;
+    else
+        color->red = color->red + highlight_factor;
+
+    if (color->blue + highlight_factor > 1.0)
+        color->blue = 1.0;
+    else
+      color->blue = color->blue + highlight_factor;
+
+    if (color->green + highlight_factor > 1.0)
+        color->green = 1.0;
+    else
+        color->green = color->green + highlight_factor;
+    }
+    gdk_cairo_set_source_rgba (cr, color);
+
+    width = gdk_window_get_width(gtk_widget_get_window(widget));
+    height = gdk_window_get_height(gtk_widget_get_window(widget));
+
+    switch (priv->type)
+        {
+        case GSMCP_TYPE_CPU:
+            //gtk_widget_set_size_request (widget, GSMCP_MIN_WIDTH, GSMCP_MIN_HEIGHT);
+            cairo_paint (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1);
+            cairo_stroke (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.4);
+            cairo_rectangle (cr, 1.5, 1.5, width - 3, height - 3);
+            cairo_stroke (cr);
+            break;
+        case GSMCP_TYPE_PIE:
+            if (width < 32)        // 32px minimum size
+                gtk_widget_set_size_request (widget, 32, 32);
+            if (width < height)
+                radius = width / 2;
+            else
+                radius = height / 2;
+
+            arc_start = -G_PI_2 + 2 * G_PI * priv->fraction;
+            arc_end = -G_PI_2;
+
+            cairo_set_line_width (cr, 1);
+
+            // Draw external stroke and fill
+            if (priv->fraction < 0.01) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_end);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    arc_end, arc_start);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_start);
+            }
+            cairo_fill_preserve (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.7);
+            cairo_stroke (cr);
+
+            // Draw internal highlight
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.45);
+            cairo_set_line_width (cr, 1);
+
+            if (priv->fraction < 0.03) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_end - (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    arc_end - (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+            }
+            cairo_stroke (cr);
+
+            // Draw external shape
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.2);
+            cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 1.25, 0,
+                G_PI * 2);
+            cairo_stroke (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_IN:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                    fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/download.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 8.5, 1.5);
+            cairo_line_to (cr, 23.5, 1.5);
+            cairo_line_to (cr, 23.5, 11.5);
+            cairo_line_to (cr, 29.5, 11.5);
+            cairo_line_to (cr, 16.5, 27.5);
+            cairo_line_to (cr, 15.5, 27.5);
+            cairo_line_to (cr, 2.5, 11.5);
+            cairo_line_to (cr, 8.5, 11.5);
+            cairo_line_to (cr, 8.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_OUT:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/upload.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 16.5, 1.5);
+            cairo_line_to (cr, 29.5, 17.5);
+            cairo_line_to (cr, 23.5, 17.5);
+            cairo_line_to (cr, 23.5, 27.5);
+            cairo_line_to (cr, 8.5, 27.5);
+            cairo_line_to (cr, 8.5, 17.5);
+            cairo_line_to (cr, 2.5, 17.5);
+            cairo_line_to (cr, 15.5, 1.5);
+            cairo_line_to (cr, 16.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        }
+    cairo_destroy (cr);
+}
+
+/* Handle exposure events for the color picker's drawing area */
+static gboolean draw (GtkWidget * widget, cairo_t * cr, gpointer data)
+{
+    render (GTK_WIDGET (data));
+
+    return FALSE;
+}
+
+static void
+gsm_color_button_realize (GtkWidget * widget)
+{
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->realize (widget);
+    render (widget);
+}
+
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width)
+{
+    g_return_if_fail (widget != NULL && minimum_width != NULL && natural_width != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_width = GSMCP_MIN_WIDTH;
+    *natural_width = GSMCP_MIN_WIDTH;
+}
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height)
+{
+    g_return_if_fail (widget != NULL && minimum_height != NULL && natural_height != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_height = GSMCP_MIN_HEIGHT;
+    *natural_height = GSMCP_MIN_HEIGHT;
+}
+
+static void
+gsm_color_button_size_allocate (GtkWidget * widget,
+                                GtkAllocation * allocation)
+{
+    g_return_if_fail (widget != NULL || allocation != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    gtk_widget_set_allocation (widget, allocation);
+
+    if (gtk_widget_get_realized (widget))
+    {
+        gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y,
+                                allocation->width, allocation->height);
+    }
+}
+
+static void
+gsm_color_button_unrealize (GtkWidget * widget)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->unrealize (widget);
+}
+
+static void
+gsm_color_button_style_set (GtkWidget * widget, GtkStyle * previous_style)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->style_set (widget,
+                                                                 previous_style);
+
+}
+
+static void
+gsm_color_button_state_changed (GtkWidget * widget,
+                                GtkStateType previous_state)
+{
+}
+
+static void
+gsm_color_button_drag_data_received (GtkWidget * widget,
+                                     GdkDragContext * context,
+                                     gint x,
+                                     gint y,
+                                     GtkSelectionData * selection_data,
+                                     guint info,
+                                     guint32 time,
+                                     GSMColorButton * color_button)
+{
+    gint length;
+    guint16 *dropped;
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    length = gtk_selection_data_get_length (selection_data);
+
+    if (length < 0)
+        return;
+
+    /* We accept drops with the wrong format, since the KDE color
+     * chooser incorrectly drops application/x-color with format 8.
+     */
+    if (length != 8)
+    {
+        g_warning (_("Received invalid color data\n"));
+        return;
+    }
+
+    dropped = (guint16 *) gtk_selection_data_get_data (selection_data);
+
+    priv->color.red =   ((double) dropped[0]) / 65535.0;
+    priv->color.green = ((double) dropped[1]) / 65535.0;
+    priv->color.blue =  ((double) dropped[2]) / 65535.0;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+    g_object_freeze_notify (G_OBJECT (color_button));
+    g_object_notify (G_OBJECT (color_button), "color");
+    g_object_thaw_notify (G_OBJECT (color_button));
+}
+
+static void
+set_color_icon (GdkDragContext * context, GdkRGBA * color)<--- Parameter 'color' can be declared as pointer to const
+{
+    GdkPixbuf *pixbuf;
+    guint32 pixel;
+
+    pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 48, 32);
+
+    pixel = ((guint32)(color->red * 0xff) << 24) |
+            ((guint32)(color->green * 0xff) << 16) |
+            ((guint32)(color->blue * 0xff) << 8);
+
+    gdk_pixbuf_fill (pixbuf, pixel);
+
+    gtk_drag_set_icon_pixbuf (context, pixbuf, -2, -2);
+    g_object_unref (pixbuf);
+}
+
+static void
+gsm_color_button_drag_begin (GtkWidget * widget,
+                             GdkDragContext * context, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = data;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    set_color_icon (context, &priv->color);
+}
+
+static void
+gsm_color_button_drag_data_get (GtkWidget * widget,
+                                GdkDragContext * context,
+                                GtkSelectionData * selection_data,
+                                guint info,
+                                guint time, GSMColorButton * color_button)
+{
+    guint16 dropped[4];
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    dropped[0] = (guint16) (65535.0 * priv->color.red);
+    dropped[1] = (guint16) (65535.0 * priv->color.green);
+    dropped[2] = (guint16) (65535.0 * priv->color.blue);
+    dropped[3] = 65535;        // This widget doesn't care about alpha
+
+    gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data),
+                            16, (guchar *) dropped, 8);
+}
+
+static void
+gsm_color_button_init (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = 0;
+    priv->color.green = 0;
+    priv->color.blue = 0;
+    priv->fraction = 0.5;
+    priv->type = GSMCP_TYPE_CPU;
+    priv->image_buffer = NULL;
+    priv->title = g_strdup (_("Pick a Color"));     /* default title */
+    priv->in_button = FALSE;
+    priv->button_down = FALSE;
+
+    gtk_drag_dest_set (GTK_WIDGET (color_button),
+                       GTK_DEST_DEFAULT_MOTION |
+                       GTK_DEST_DEFAULT_HIGHLIGHT |
+                       GTK_DEST_DEFAULT_DROP, drop_types, 1, GDK_ACTION_COPY);
+    gtk_drag_source_set (GTK_WIDGET (color_button),
+                         GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
+                         drop_types, 1, GDK_ACTION_COPY);
+    g_signal_connect (color_button, "drag_begin",
+                      G_CALLBACK (gsm_color_button_drag_begin), color_button);
+    g_signal_connect (color_button, "drag_data_received",
+                      G_CALLBACK (gsm_color_button_drag_data_received),
+                      color_button);
+    g_signal_connect (color_button, "drag_data_get",
+                      G_CALLBACK (gsm_color_button_drag_data_get),
+                      color_button);
+
+    gtk_widget_add_events (GTK_WIDGET(color_button), GDK_ENTER_NOTIFY_MASK
+                              | GDK_LEAVE_NOTIFY_MASK);
+
+    gtk_widget_set_tooltip_text (GTK_WIDGET(color_button), _("Click to set graph colors"));
+
+    g_signal_connect (color_button, "draw", G_CALLBACK (draw), color_button);
+}
+
+static void
+gsm_color_button_finalize (GObject * object)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    if (priv->cc_dialog != NULL)
+        gtk_widget_destroy (priv->cc_dialog);
+    priv->cc_dialog = NULL;
+
+    g_free (priv->title);
+    priv->title = NULL;
+
+    cairo_surface_destroy (priv->image_buffer);
+    priv->image_buffer = NULL;
+
+    G_OBJECT_CLASS (gsm_color_button_parent_class)->finalize (object);
+}
+
+GtkWidget *
+gsm_color_button_new (const GdkRGBA * color, guint type)
+{
+    return g_object_new (GSM_TYPE_COLOR_BUTTON, "color", color, "type", type,
+                         NULL);
+}
+
+static void
+dialog_response (GtkWidget * widget, GtkResponseType response, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GtkColorChooser *color_chooser;
+
+    if (response == GTK_RESPONSE_OK) {
+        color_chooser = GTK_COLOR_CHOOSER (priv->cc_dialog);
+
+        gtk_color_chooser_get_rgba (color_chooser, &priv->color);
+
+        gtk_widget_hide (priv->cc_dialog);
+
+        gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+        g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+        g_object_freeze_notify (G_OBJECT (color_button));
+        g_object_notify (G_OBJECT (color_button), "color");
+        g_object_thaw_notify (G_OBJECT (color_button));
+    }
+    else  /* (response == GTK_RESPONSE_CANCEL) */
+        gtk_widget_hide (priv->cc_dialog);
+}
+
+static gboolean
+dialog_destroy (GtkWidget * widget, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->cc_dialog = NULL;
+
+    return FALSE;
+}
+
+static gint
+gsm_color_button_clicked (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    /* if dialog already exists, make sure it's shown and raised */
+    if (!priv->cc_dialog)
+    {
+        /* Create the dialog and connects its buttons */
+        GtkWidget *cc_dialog;
+        GtkWidget *parent;
+
+        parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));
+        if (!gtk_widget_is_toplevel (parent))
+            parent = NULL;
+
+        cc_dialog = gtk_color_chooser_dialog_new (priv->title, GTK_WINDOW (parent));
+
+        gtk_window_set_modal (GTK_WINDOW (cc_dialog), TRUE);
+
+        g_signal_connect (cc_dialog, "response",
+                          G_CALLBACK (dialog_response), color_button);
+
+        g_signal_connect (cc_dialog, "destroy",
+                          G_CALLBACK (dialog_destroy), color_button);
+
+        priv->cc_dialog = cc_dialog;
+    }
+
+    gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (priv->cc_dialog),
+                                &priv->color);
+
+    gtk_window_present (GTK_WINDOW (priv->cc_dialog));
+
+    return 0;
+}
+
+static gint
+gsm_color_button_pressed (GtkWidget * widget, GdkEventButton * event)<--- Parameter 'event' can be declared as pointer to const
+{
+    if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) )
+    {
+	GSMColorButtonPrivate *priv;
+        GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+	priv = gsm_color_button_get_instance_private (color_button);
+	priv->button_down = TRUE;
+    }
+  return 0;
+}
+
+static gint
+gsm_color_button_released (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    if (priv->button_down && priv->in_button)
+        gsm_color_button_clicked (widget, event);
+    priv->button_down = FALSE;
+    return 0;
+}
+
+static gboolean
+gsm_color_button_enter_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 1.0;
+    priv->in_button = TRUE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+static gboolean
+gsm_color_button_leave_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 0;
+    priv->in_button = FALSE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+guint
+gsm_color_button_get_cbtype (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->type;
+}
+
+void
+gsm_color_button_set_cbtype (GSMColorButton * color_button, guint type)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->type = type;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "type");
+}
+
+gdouble
+gsm_color_button_get_fraction (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->fraction;
+}
+
+void
+gsm_color_button_set_fraction (GSMColorButton * color_button,
+                               gdouble fraction)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->fraction = fraction;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "fraction");
+}
+
+void
+gsm_color_button_get_color (GSMColorButton * color_button, GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    color->red = priv->color.red;
+    color->green = priv->color.green;
+    color->blue = priv->color.blue;
+    color->alpha = priv->color.alpha;
+}
+
+void
+gsm_color_button_set_color (GSMColorButton * color_button,
+                            const GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    g_return_if_fail (color != NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = color->red;
+    priv->color.green = color->green;
+    priv->color.blue = color->blue;
+    priv->color.alpha = color->alpha;
+
+    gtk_widget_queue_draw (GTK_WIDGET (color_button));
+
+    g_object_notify (G_OBJECT (color_button), "color");
+}
+
+void
+gsm_color_button_set_title (GSMColorButton * color_button,
+                            const gchar * title)
+{
+    gchar *old_title;
+    GSMColorButtonPrivate *priv;
+
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    old_title = priv->title;
+    priv->title = g_strdup (title);
+    g_free (old_title);
+
+    if (priv->cc_dialog)
+        gtk_window_set_title (GTK_WINDOW (priv->cc_dialog),
+                              priv->title);
+
+    g_object_notify (G_OBJECT (color_button), "title");
+}
+
+const gchar* gsm_color_button_get_title(GSMColorButton* color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail(GSM_IS_COLOR_BUTTON(color_button), NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->title;
+}
+
+static void
+gsm_color_button_set_property (GObject * object,
+                               guint param_id,
+                               const GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            gsm_color_button_set_fraction (color_button,
+                                           g_value_get_double (value));
+            break;
+        case PROP_TITLE:
+            gsm_color_button_set_title (color_button, g_value_get_string (value));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_set_color (color_button, g_value_get_boxed (value));
+            break;
+        case PROP_TYPE:
+            gsm_color_button_set_cbtype (color_button, g_value_get_uint (value));
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+static void
+gsm_color_button_get_property (GObject * object,
+                               guint param_id,
+                               GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+    GdkRGBA color;
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            g_value_set_double (value,
+                                gsm_color_button_get_fraction (color_button));
+            break;
+        case PROP_TITLE:
+            g_value_set_string (value, gsm_color_button_get_title (color_button));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_get_color (color_button, &color);
+                                        g_value_set_boxed (value, &color);
+            break;
+        case PROP_TYPE:
+            g_value_set_uint (value, gsm_color_button_get_cbtype (color_button));
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/22.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/22.html new file mode 100644 index 00000000..9c8cf9ea --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/22.html @@ -0,0 +1,351 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtkmm/icontheme.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/error.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "iconthemewrapper.h"
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
+{
+    gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
+    try
+    {
+      return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
+    }
+    catch (Gtk::IconThemeError &error)
+    {
+        if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
+            g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+    catch (Gio::Error &error)
+    {
+        g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+}
+
+Glib::RefPtr<Gdk::Pixbuf>
+procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
+                                      int size, Gtk::IconLookupFlags flags) const
+{
+    Gtk::IconInfo icon_info;
+    gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
+    icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
+
+    if (!icon_info) {
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+
+    try
+    {
+        return icon_info.load_icon();
+    }
+    catch (Gtk::IconThemeError &error)
+    {
+        if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
+            g_error("Cannot load gicon from theme: %s", error.what().c_str());
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+    catch (Gio::Error &error)
+    {
+        g_debug("Could not load gicon: %s", error.what().c_str());
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/23.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/23.html new file mode 100644 index 00000000..3f522db0 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/23.html @@ -0,0 +1,1599 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
/* Procman - main window
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkkeysyms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "callbacks.h"
+#include "interface.h"
+#include "proctable.h"
+#include "procactions.h"
+#include "load-graph.h"
+#include "util.h"
+#include "disks.h"
+#include "sysinfo.h"
+#include "gsm_color_button.h"
+
+static void    cb_toggle_tree (GtkAction *action, gpointer data);
+static void    cb_proc_goto_tab (gint tab);
+
+static const GtkActionEntry menu_entries[] =
+{
+    // xgettext: noun, top level menu.
+    // "File" did not make sense for system-monitor
+    { "Monitor", NULL, N_("_Monitor") },
+    { "Edit", NULL, N_("_Edit") },
+    { "View", NULL, N_("_View") },
+    { "Help", NULL, N_("_Help") },
+
+    { "Lsof", "edit-find", N_("Search for _Open Files"), "<control>O",
+      N_("Search for open files"), G_CALLBACK(cb_show_lsof) },
+    { "Quit", "application-exit", N_("_Quit"), "<control>Q",
+      N_("Quit the program"), G_CALLBACK (cb_app_exit) },
+
+
+    { "StopProcess", NULL, N_("_Stop Process"), "<control>S",
+      N_("Stop process"), G_CALLBACK(cb_kill_sigstop) },
+    { "ContProcess", NULL, N_("_Continue Process"), "<control>C",
+      N_("Continue process if stopped"), G_CALLBACK(cb_kill_sigcont) },
+
+    { "EndProcess", NULL, N_("_End Process"), "<control>E",
+      N_("Force process to finish normally"), G_CALLBACK (cb_end_process) },
+    { "KillProcess", NULL, N_("_Kill Process"), "<control>K",
+      N_("Force process to finish immediately"), G_CALLBACK (cb_kill_process) },
+    { "ChangePriority", NULL, N_("_Change Priority"), NULL,
+      N_("Change the order of priority of process"), NULL },
+    { "Preferences", "preferences-desktop", N_("_Preferences"), NULL,
+      N_("Configure the application"), G_CALLBACK (cb_edit_preferences) },
+
+    { "Refresh", "view-refresh", N_("_Refresh"), "<control>R",
+      N_("Refresh the process list"), G_CALLBACK(cb_user_refresh) },
+
+    { "MemoryMaps", NULL, N_("_Memory Maps"), "<control>M",
+      N_("Open the memory maps associated with a process"), G_CALLBACK (cb_show_memory_maps) },
+    // Translators: this means 'Files that are open' (open is no verb here
+    { "OpenFiles", NULL, N_("Open _Files"), "<control>F",
+      N_("View the files opened by a process"), G_CALLBACK (cb_show_open_files) },
+    { "ProcessProperties", NULL, N_("_Properties"), NULL,
+      N_("View additional information about a process"), G_CALLBACK (cb_show_process_properties) },
+
+
+    { "HelpContents", "help-browser", N_("_Contents"), "F1",
+      N_("Open the manual"), G_CALLBACK (cb_help_contents) },
+    { "About", "help-about", N_("_About"), NULL,
+      N_("About this application"), G_CALLBACK (cb_about) }
+};
+
+static const GtkToggleActionEntry toggle_menu_entries[] =
+{
+    { "ShowDependencies", NULL, N_("_Dependencies"), "<control>D",
+      N_("Show parent/child relationship between processes"),
+      G_CALLBACK (cb_toggle_tree), TRUE },
+};
+
+
+static const GtkRadioActionEntry radio_menu_entries[] =
+{
+  { "ShowActiveProcesses", NULL, N_("_Active Processes"), NULL,
+    N_("Show active processes"), ACTIVE_PROCESSES },
+  { "ShowAllProcesses", NULL, N_("A_ll Processes"), NULL,
+    N_("Show all processes"), ALL_PROCESSES },
+  { "ShowMyProcesses", NULL, N_("M_y Processes"), NULL,
+    N_("Show only user-owned processes"), MY_PROCESSES }
+};
+
+static const GtkRadioActionEntry priority_menu_entries[] =
+{
+    { "VeryHigh", NULL, N_("Very High"), NULL,
+      N_("Set process priority to very high"), VERY_HIGH_PRIORITY },
+    { "High", NULL, N_("High"), NULL,
+      N_("Set process priority to high"), HIGH_PRIORITY },
+    { "Normal", NULL, N_("Normal"), NULL,
+      N_("Set process priority to normal"), NORMAL_PRIORITY },
+    { "Low", NULL, N_("Low"), NULL,
+      N_("Set process priority to low"), LOW_PRIORITY },
+    { "VeryLow", NULL, N_("Very Low"), NULL,
+      N_("Set process priority to very low"), VERY_LOW_PRIORITY },
+    { "Custom", NULL, N_("Custom"), NULL,
+      N_("Set process priority manually"), CUSTOM_PRIORITY }
+};
+
+
+static const char ui_info[] =
+    "  <menubar name=\"MenuBar\">"
+    "    <menu name=\"MonitorMenu\" action=\"Monitor\">"
+    "      <menuitem name=\"MonitorLsofMenu\" action=\"Lsof\" />"
+    "      <menuitem name=\"MonitorQuitMenu\" action=\"Quit\" />"
+    "    </menu>"
+    "    <menu name=\"EditMenu\" action=\"Edit\">"
+    "      <menuitem name=\"EditStopProcessMenu\" action=\"StopProcess\" />"
+    "      <menuitem name=\"EditContProcessMenu\" action=\"ContProcess\" />"
+    "      <separator />"
+    "      <menuitem name=\"EditEndProcessMenu\" action=\"EndProcess\" />"
+    "      <menuitem name=\"EditKillProcessMenu\" action=\"KillProcess\" />"
+    "      <separator />"
+    "      <menu name=\"EditChangePriorityMenu\" action=\"ChangePriority\" >"
+    "        <menuitem action=\"VeryHigh\" />"
+    "        <menuitem action=\"High\" />"
+    "        <menuitem action=\"Normal\" />"
+    "        <menuitem action=\"Low\" />"
+    "        <menuitem action=\"VeryLow\" />"
+    "        <separator />"
+    "        <menuitem action=\"Custom\"/>"
+    "      </menu>"
+    "      <separator />"
+    "      <menuitem name=\"EditPreferencesMenu\" action=\"Preferences\" />"
+    "    </menu>"
+    "    <menu name=\"ViewMenu\" action=\"View\">"
+    "      <menuitem name=\"ViewActiveProcesses\" action=\"ShowActiveProcesses\" />"
+    "      <menuitem name=\"ViewAllProcesses\" action=\"ShowAllProcesses\" />"
+    "      <menuitem name=\"ViewMyProcesses\" action=\"ShowMyProcesses\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewDependenciesMenu\" action=\"ShowDependencies\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewMemoryMapsMenu\" action=\"MemoryMaps\" />"
+    "      <menuitem name=\"ViewOpenFilesMenu\" action=\"OpenFiles\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewProcessPropertiesMenu\" action=\"ProcessProperties\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewRefresh\" action=\"Refresh\" />"
+    "    </menu>"
+    "    <menu name=\"HelpMenu\" action=\"Help\">"
+    "      <menuitem name=\"HelpContentsMenu\" action=\"HelpContents\" />"
+    "      <menuitem name=\"HelpAboutMenu\" action=\"About\" />"
+    "    </menu>"
+    "  </menubar>"
+    "  <popup name=\"PopupMenu\" action=\"Popup\">"
+    "    <menuitem action=\"StopProcess\" />"
+    "    <menuitem action=\"ContProcess\" />"
+    "    <separator />"
+    "    <menuitem action=\"EndProcess\" />"
+    "    <menuitem action=\"KillProcess\" />"
+    "    <separator />"
+    "    <menu name=\"ChangePriorityMenu\" action=\"ChangePriority\" >"
+    "      <menuitem action=\"VeryHigh\" />"
+    "      <menuitem action=\"High\" />"
+    "      <menuitem action=\"Normal\" />"
+    "      <menuitem action=\"Low\" />"
+    "      <menuitem action=\"VeryLow\" />"
+    "      <separator />"
+    "      <menuitem action=\"Custom\"/>"
+    "    </menu>"
+    "    <separator />"
+    "    <menuitem action=\"MemoryMaps\" />"
+    "    <menuitem action=\"OpenFiles\" />"
+    "    <separator />"
+    "    <menuitem action=\"ProcessProperties\" />"
+
+    "  </popup>";
+
+
+static void
+create_proc_view(ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *proctree;
+    GtkWidget *scrolled;
+    char* string;
+
+    /* create the processes tab */
+    string = make_loadavg_string ();
+    procdata->loadavg = GTK_WIDGET (gtk_builder_get_object (builder, "load_avg_label"));
+    gtk_label_set_text (GTK_LABEL (procdata->loadavg), string);
+    g_free (string);
+
+    proctree = proctable_new (procdata);
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "processes_scrolled"));
+
+    gtk_container_add (GTK_CONTAINER (scrolled), proctree);
+
+    procdata->endprocessbutton = GTK_WIDGET (gtk_builder_get_object (builder, "endprocessbutton"));
+    g_signal_connect (G_OBJECT (procdata->endprocessbutton), "clicked",
+                      G_CALLBACK (cb_end_process_button_pressed), procdata);
+
+    /* create popup_menu for the processes tab */
+    procdata->popup_menu = gtk_ui_manager_get_widget (procdata->uimanager, "/PopupMenu");
+}
+
+
+GtkWidget *
+make_title_label (const char *text)
+{
+    GtkWidget *label;
+    char *full;
+
+    full = g_strdup_printf ("<span weight=\"bold\">%s</span>", text);
+    label = gtk_label_new (full);
+    g_free (full);
+
+    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+
+    return label;
+}
+
+
+static void
+create_sys_view (ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *cpu_graph_box, *mem_graph_box, *net_graph_box;
+    GtkWidget *label,*cpu_label;
+    GtkWidget *table;
+    GtkWidget *color_picker;
+    GtkWidget *picker_alignment;
+    LoadGraph *cpu_graph, *mem_graph, *net_graph;
+
+    gint i;
+    gchar *title_text;
+    gchar *label_text;
+    gchar *title_template;
+
+    // Translators: color picker title, %s is CPU, Memory, Swap, Receiving, Sending
+    title_template = g_strdup(_("Pick a Color for '%s'"));
+
+    /* The CPU BOX */
+
+    cpu_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_graph_box"));
+
+    cpu_graph = new LoadGraph(LOAD_GRAPH_CPU);
+    gtk_box_pack_start (GTK_BOX (cpu_graph_box),
+                        load_graph_get_widget(cpu_graph),
+                        TRUE,
+                        TRUE,
+                         0);
+
+    GtkWidget* flowbox = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_flow_box"));
+    gtk_box_reorder_child (GTK_BOX (cpu_graph_box), flowbox, 1);
+    for (i=0;i<procdata->config.num_cpus; i++) {
+        GtkWidget *temp_hbox;
+
+        temp_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
+        gtk_container_add (GTK_CONTAINER (flowbox), temp_hbox);
+
+        color_picker = gsm_color_button_new (&cpu_graph->colors.at(i), GSMCP_TYPE_CPU);
+        g_signal_connect (G_OBJECT (color_picker), "color_set",
+                          G_CALLBACK (cb_cpu_color_changed), GINT_TO_POINTER (i));
+        gtk_box_pack_start (GTK_BOX (temp_hbox), color_picker, FALSE, TRUE, 0);
+        gtk_widget_set_size_request(GTK_WIDGET(color_picker), 32, -1);
+        if(procdata->config.num_cpus == 1) {
+            label_text = g_strdup (_("CPU"));
+        } else {
+            label_text = g_strdup_printf (_("CPU%d"), i+1);
+        }
+        title_text = g_strdup_printf(title_template, label_text);
+        label = gtk_label_new (label_text);
+        gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+        g_free(title_text);
+        gtk_box_pack_start (GTK_BOX (temp_hbox), label, FALSE, FALSE, 6);
+        g_free (label_text);
+
+        cpu_label = gtk_label_new (NULL);
+        gtk_label_set_width_chars (GTK_LABEL (cpu_label), 7);
+        gtk_label_set_xalign (GTK_LABEL (cpu_label), 0.0);
+
+        gtk_box_pack_start (GTK_BOX (temp_hbox), cpu_label, TRUE, TRUE, 0);
+        load_graph_get_labels(cpu_graph)->cpu[i] = cpu_label;
+
+    }
+
+    procdata->cpu_graph = cpu_graph;
+
+    /** The memory box */
+    mem_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "mem_graph_box"));
+
+    mem_graph = new LoadGraph(LOAD_GRAPH_MEM);
+    gtk_box_pack_start (GTK_BOX (mem_graph_box),
+                        load_graph_get_widget(mem_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "mem_table"));
+
+    color_picker = load_graph_get_mem_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_mem_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Memory"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 0, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->memory;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 1, 1, 1, 1);
+
+    color_picker = load_graph_get_swap_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_swap_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Swap"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 2, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->swap;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 3, 1, 1, 1);
+
+    procdata->mem_graph = mem_graph;
+
+    /* The net box */
+    net_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "net_graph_box"));
+
+    net_graph = new LoadGraph(LOAD_GRAPH_NET);
+    gtk_box_pack_start (GTK_BOX (net_graph_box),
+                        load_graph_get_widget(net_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "net_table"));
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(0), GSMCP_TYPE_NETWORK_IN);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_in_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Receiving"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "receiving_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_in;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_in_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 1, 1, 1);
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(1), GSMCP_TYPE_NETWORK_OUT);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_out_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Sending"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "sending_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_out;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_out_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 1, 1, 1);
+
+    procdata->net_graph = net_graph;
+    g_free(title_template);
+}
+
+static void
+menu_item_select_cb (GtkMenuItem *proxy,
+                     ProcData *procdata)
+{
+    GtkAction *action;
+    char *message;
+
+    action = gtk_activatable_get_related_action (GTK_ACTIVATABLE(proxy));
+    g_assert(action);
+
+    g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
+    if (message)
+    {
+        gtk_statusbar_push (GTK_STATUSBAR (procdata->statusbar),
+                    procdata->tip_message_cid, message);
+        g_free (message);
+    }
+}
+
+static void
+menu_item_deselect_cb (GtkMenuItem *proxy,
+                       ProcData *procdata)
+{
+    gtk_statusbar_pop (GTK_STATUSBAR (procdata->statusbar),
+               procdata->tip_message_cid);
+}
+
+static void
+connect_proxy_cb (GtkUIManager *manager,
+                  GtkAction *action,
+                  GtkWidget *proxy,
+                  ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_connect (proxy, "select",
+                          G_CALLBACK (menu_item_select_cb), procdata);
+        g_signal_connect (proxy, "deselect",
+                          G_CALLBACK (menu_item_deselect_cb), procdata);
+    }
+}
+
+static void
+disconnect_proxy_cb (GtkUIManager *manager,
+                     GtkAction *action,
+                     GtkWidget *proxy,
+                     ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_select_cb)), procdata);
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_deselect_cb)), procdata);
+    }
+}
+
+void
+create_main_window (ProcData *procdata)
+{
+    gint i;
+    gint width, height, xpos, ypos;
+    GtkWidget *app;
+    GtkAction *action;
+    GtkWidget *menubar;
+    GtkWidget *main_box;
+    GtkWidget *notebook;
+    GtkBuilder *builder;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/interface.ui");
+
+    app = GTK_WIDGET (gtk_builder_get_object (builder, "main_window"));
+    main_box = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
+
+    GdkScreen* screen = gtk_widget_get_screen(app);
+    /* use visual, if available */
+    GdkVisual* visual = gdk_screen_get_rgba_visual(screen);
+    if (visual)
+        gtk_widget_set_visual(app, visual);
+
+    width = procdata->config.width;
+    height = procdata->config.height;
+    xpos = procdata->config.xpos;
+    ypos = procdata->config.ypos;
+    gtk_window_set_default_size (GTK_WINDOW (app), width, height);
+    gtk_window_move(GTK_WINDOW (app), xpos, ypos);
+
+    if (procdata->config.maximized) {
+        gtk_window_maximize(GTK_WINDOW(app));
+    }
+
+    /* create the menubar */
+    procdata->uimanager = gtk_ui_manager_new ();
+
+    /* show tooltips in the statusbar */
+    g_signal_connect (procdata->uimanager, "connect_proxy",
+                      G_CALLBACK (connect_proxy_cb), procdata);
+    g_signal_connect (procdata->uimanager, "disconnect_proxy",
+                      G_CALLBACK (disconnect_proxy_cb), procdata);
+
+    gtk_window_add_accel_group (GTK_WINDOW (app),
+                                gtk_ui_manager_get_accel_group (procdata->uimanager));
+
+    if (!gtk_ui_manager_add_ui_from_string (procdata->uimanager,
+                                            ui_info,
+                                            -1,
+                                            NULL)) {
+        g_error("building menus failed");
+    }
+
+    procdata->action_group = gtk_action_group_new ("ProcmanActions");
+    gtk_action_group_set_translation_domain (procdata->action_group, NULL);
+    gtk_action_group_add_actions (procdata->action_group,
+                                  menu_entries,
+                                  G_N_ELEMENTS (menu_entries),
+                                  procdata);
+    gtk_action_group_add_toggle_actions (procdata->action_group,
+                                         toggle_menu_entries,
+                                         G_N_ELEMENTS (toggle_menu_entries),
+                                         procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                        radio_menu_entries,
+                        G_N_ELEMENTS (radio_menu_entries),
+                        procdata->config.whose_process,
+                        G_CALLBACK(cb_radio_processes),
+                        procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                                        priority_menu_entries,
+                                        G_N_ELEMENTS (priority_menu_entries),
+                                        NORMAL_PRIORITY,
+                                        G_CALLBACK(cb_renice),
+                                        procdata);
+
+    gtk_ui_manager_insert_action_group (procdata->uimanager,
+                                        procdata->action_group,
+                                        0);
+
+    menubar = gtk_ui_manager_get_widget (procdata->uimanager, "/MenuBar");
+    gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0);
+    gtk_box_reorder_child (GTK_BOX (main_box), menubar, 0);
+
+    /* create the main notebook */
+    procdata->notebook = notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
+
+    create_proc_view(procdata, builder);
+    create_sys_view (procdata, builder);
+    create_disk_view (procdata, builder);
+
+    g_signal_connect (G_OBJECT (notebook), "switch-page",
+              G_CALLBACK (cb_switch_page), procdata);
+    g_signal_connect (G_OBJECT (notebook), "change-current-page",
+              G_CALLBACK (cb_change_current_page), procdata);
+
+    gtk_widget_show_all(notebook); // need to make page switch work
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab);
+    cb_change_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab, procdata);
+    g_signal_connect (G_OBJECT (app), "delete_event",
+                      G_CALLBACK (cb_app_delete),
+                      procdata);
+
+    GtkAccelGroup *accel_group;
+    GClosure *goto_tab_closure[4];
+    accel_group = gtk_accel_group_new ();
+    gtk_window_add_accel_group (GTK_WINDOW(app), accel_group);
+    for (i = 0; i < 4; ++i) {
+        goto_tab_closure[i] = g_cclosure_new_swap (G_CALLBACK (cb_proc_goto_tab),
+                                                   GINT_TO_POINTER (i), NULL);
+        gtk_accel_group_connect (accel_group, '0'+(i+1),
+                                 GDK_MOD1_MASK, GTK_ACCEL_VISIBLE,
+                                 goto_tab_closure[i]);
+    }
+
+    /* create the statusbar */
+    procdata->statusbar = GTK_WIDGET (gtk_builder_get_object (builder, "statusbar"));
+    procdata->tip_message_cid = gtk_statusbar_get_context_id
+        (GTK_STATUSBAR (procdata->statusbar), "tip_message");
+
+    action = gtk_action_group_get_action (procdata->action_group, "ShowDependencies");
+    gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+                      procdata->config.show_tree);
+
+    gtk_builder_connect_signals (builder, NULL);
+
+    gtk_widget_show_all(app);
+    procdata->app = app;
+
+    g_object_unref (G_OBJECT (builder));
+}
+
+void
+do_popup_menu (ProcData *procdata, GdkEventButton *event)
+{
+    gtk_menu_popup_at_pointer (GTK_MENU (procdata->popup_menu), NULL);
+}
+
+void
+update_sensitivity(ProcData *data)
+{
+    const char * const selected_actions[] = { "StopProcess",
+                                              "ContProcess",
+                                              "EndProcess",
+                                              "KillProcess",
+                                              "ChangePriority",
+                                              "MemoryMaps",
+                                              "OpenFiles",
+                                              "ProcessProperties" };
+
+    const char * const processes_actions[] = { "ShowActiveProcesses",
+                                               "ShowAllProcesses",
+                                               "ShowMyProcesses",
+                                               "ShowDependencies",
+                                               "Refresh"
+    };
+
+    size_t i;
+    gboolean processes_sensitivity, selected_sensitivity;
+    GtkAction *action;
+
+    processes_sensitivity = (data->config.current_tab == PROCMAN_TAB_PROCESSES);
+    selected_sensitivity = (processes_sensitivity && data->selection && gtk_tree_selection_count_selected_rows (data->selection) > 0);
+
+    if(data->endprocessbutton) {
+        /* avoid error on startup if endprocessbutton
+           has not been built yet */
+        gtk_widget_set_sensitive(data->endprocessbutton, selected_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(processes_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             processes_actions[i]);
+        gtk_action_set_sensitive(action, processes_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(selected_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             selected_actions[i]);
+        gtk_action_set_sensitive(action, selected_sensitivity);
+    }
+}
+
+void
+block_priority_changed_handlers(ProcData *data, bool block)
+{
+    gint i;
+    if (block) {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_block_by_func(action, (gpointer)cb_renice, data);
+        }
+    } else {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_unblock_by_func(action, (gpointer)cb_renice, data);
+        }
+    }
+}
+
+static void
+cb_toggle_tree (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GSettings *settings = procdata->settings;
+    gboolean show;
+
+    show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+    if (show == procdata->config.show_tree)
+        return;
+
+    g_settings_set_boolean (settings, "show-tree", show);
+}
+
+static void
+cb_proc_goto_tab (gint tab)
+{
+    ProcData *data = ProcData::get_instance ();
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (data->notebook), tab);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/24.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/24.html new file mode 100644 index 00000000..382ee6f5 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/24.html @@ -0,0 +1,1939 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gdkmm/pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dirent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibtop.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/swap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/netload.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/netlist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <algorithm><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "load-graph.h"
+#include "util.h"
+#include "gsm_color_button.h"
+
+void LoadGraph::clear_background()
+{
+    if (background) {
+        cairo_pattern_destroy (background);
+        this->background = NULL;
+    }
+}
+
+
+unsigned LoadGraph::num_bars() const
+{
+    unsigned n;<--- Shadow variable
+
+    // keep 100 % num_bars == 0
+    switch (static_cast<int>(this->draw_height / (fontsize + 14)))
+    {
+    case 0:
+    case 1:
+        n = 1;
+        break;
+    case 2:
+    case 3:
+        n = 2;
+        break;
+    case 4:
+        n = 4;
+        break;
+    default:
+        n = 5;
+    }
+
+    return n;
+}
+
+
+
+#define FRAME_WIDTH 4
+static void draw_background(LoadGraph *graph) {
+    GtkAllocation allocation;
+    cairo_t *cr;
+    guint i;<--- Shadowed declaration
+    unsigned num_bars;
+    g_autofree gchar *caption;
+    PangoLayout* layout;
+    PangoFontDescription* font_desc;
+    PangoRectangle extents;
+    cairo_surface_t *surface;
+    GdkRGBA fg, bg;
+
+    num_bars = graph->num_bars();
+    graph->graph_dely = (graph->draw_height - 15) / num_bars; /* round to int to avoid AA blur */
+    graph->real_draw_height = graph->graph_dely * num_bars;
+    graph->graph_delx = (graph->draw_width - 2.0 - graph->rmargin - graph->indent) / (LoadGraph::NUM_POINTS - 3);
+    graph->graph_buffer_offset = (int) (1.5 * graph->graph_delx) + FRAME_WIDTH ;
+
+    gtk_widget_get_allocation (graph->disp, &allocation);
+    surface = gdk_window_create_similar_surface (gtk_widget_get_window (graph->disp), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height);
+    cr = cairo_create (surface);
+
+    GtkStyleContext *context = gtk_widget_get_style_context (ProcData::get_instance()->notebook);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get_background_color (context, gtk_style_context_get_state (context), &bg);
+    gtk_style_context_get_color (context, gtk_style_context_get_state (context), &fg);
+    gtk_style_context_restore (context);
+
+    // set the background color
+    gdk_cairo_set_source_rgba (cr, &bg);
+    cairo_paint (cr);
+
+    layout = pango_cairo_create_layout (cr);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get (context,
+                           gtk_style_context_get_state (context),
+                           GTK_STYLE_PROPERTY_FONT,
+                           &font_desc, NULL);
+    gtk_style_context_restore (context);
+    pango_font_description_set_size (font_desc, 0.8 * graph->fontsize * PANGO_SCALE);
+    pango_layout_set_font_description (layout, font_desc);
+    pango_font_description_free (font_desc);
+
+    /* draw frame */
+    cairo_translate (cr, FRAME_WIDTH, FRAME_WIDTH);
+
+    /* Draw background rectangle */
+    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+    cairo_rectangle (cr, graph->rmargin + graph->indent, 0,
+                     graph->draw_width - graph->rmargin - graph->indent, graph->real_draw_height);
+    cairo_fill(cr);
+
+    cairo_set_line_width (cr, 1.0);
+    cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    for (i = 0; i <= num_bars; ++i) {
+        double y;
+
+        if (i == 0)
+            y = 0.5 + graph->fontsize / 2.0;
+        else if (i == num_bars)
+            y = i * graph->graph_dely + 0.5;
+        else
+            y = i * graph->graph_dely + graph->fontsize / 2.0;
+
+        gdk_cairo_set_source_rgba (cr, &fg);
+        if (graph->type == LOAD_GRAPH_NET) {
+            // operation orders matters so it's 0 if i == num_bars
+            guint64 rate = graph->net.max - (i * graph->net.max / num_bars);
+            caption = g_format_size_full (network_in_bits ? rate*8 : rate, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        } else {
+            // operation orders matters so it's 0 if i == num_bars
+            caption = g_strdup_printf("%d%%", 100 - i * (100 / num_bars));
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        }
+
+        if (i==0 || i==num_bars)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, graph->rmargin + graph->indent - 3, i * graph->graph_dely + 0.5);
+        cairo_line_to (cr, graph->draw_width - 0.5, i * graph->graph_dely + 0.5);
+        cairo_stroke (cr);
+    }
+
+    const unsigned total_seconds = graph->speed * (LoadGraph::NUM_POINTS - 2) / 1000;
+
+    for (unsigned int i = 0; i < 7; i++) {<--- Shadow variable
+        double x = (i) * (graph->draw_width - graph->rmargin - graph->indent) / 6;
+        if (i==0 || i==6)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, 0.5);
+        cairo_line_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, graph->real_draw_height + 4.5);
+        cairo_stroke(cr);
+        unsigned seconds = total_seconds - i * total_seconds / 6;
+        const char* format;
+        if (i == 0)
+            format = dngettext(GETTEXT_PACKAGE, "%u second", "%u seconds", seconds);
+        else
+            format = "%u";
+        caption = g_strdup_printf(format, seconds);
+        pango_layout_set_text (layout, caption, -1);
+        pango_layout_get_extents (layout, NULL, &extents);
+        cairo_move_to (cr, ((ceil(x) + 0.5) + graph->rmargin + graph->indent) - (1.0 * extents.width / PANGO_SCALE/2), graph->draw_height - 1.0 * extents.height / PANGO_SCALE);
+        gdk_cairo_set_source_rgba (cr, &fg);
+        pango_cairo_show_layout (cr, layout);
+    }
+    g_object_unref(layout);
+    cairo_stroke (cr);
+    cairo_destroy (cr);
+    graph->background = cairo_pattern_create_for_surface (surface);
+    cairo_surface_destroy (surface);
+}
+
+/* Redraws the backing buffer for the load graph and updates the window */
+void
+load_graph_queue_draw (LoadGraph *graph)
+{
+    /* repaint */
+    gtk_widget_queue_draw (graph->disp);
+}
+
+static int load_graph_update (gpointer user_data); // predeclare load_graph_update so we can compile ;)
+
+static gboolean
+load_graph_configure (GtkWidget *widget,
+                      GdkEventConfigure *event,
+                      gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    gtk_widget_get_allocation (widget, &allocation);
+    graph->draw_width = allocation.width - 2 * FRAME_WIDTH;
+    graph->draw_height = allocation.height - 2 * FRAME_WIDTH;
+
+    graph->clear_background();
+
+    load_graph_queue_draw (graph);
+
+    return TRUE;
+}
+
+static gboolean load_graph_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+    GdkWindow *window;
+
+    guint i, j;
+    gdouble sample_width, x_offset;
+
+    window = gtk_widget_get_window (graph->disp);
+
+    /* Number of pixels wide for one graph point */
+    sample_width = (float)(graph->draw_width - graph->rmargin - graph->indent) / (float)LoadGraph::NUM_POINTS;
+    /* General offset */
+    x_offset = graph->draw_width - graph->rmargin + (sample_width*2);
+
+    /* Subframe offset */
+    x_offset += graph->rmargin - ((sample_width / graph->frames_per_unit) * graph->render_counter);
+
+    /* draw the graph */
+    cairo_t* cr;
+
+    cr = gdk_cairo_create (window);
+
+    if (graph->background == NULL) {
+        draw_background(graph);
+    }
+    cairo_set_source (cr, graph->background);
+    cairo_paint (cr);
+
+    cairo_set_line_width (cr, 1);
+    cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+    cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+    cairo_rectangle (cr, graph->rmargin + graph->indent + FRAME_WIDTH + 1, FRAME_WIDTH - 1,
+             graph->draw_width - graph->rmargin - graph->indent - 1, graph->real_draw_height + FRAME_WIDTH - 1);
+    cairo_clip(cr);
+
+    for (j = 0; j < graph->n; ++j) {
+        cairo_move_to (cr, x_offset, (1.0f - graph->data[0][j]) * graph->real_draw_height);
+        gdk_cairo_set_source_rgba (cr, &(graph->colors [j]));
+
+        for (i = 1; i < LoadGraph::NUM_POINTS; ++i) {
+            if (graph->data[i][j] == -1.0f)
+                continue;
+            cairo_curve_to (cr,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i-1][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - (i * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f);
+        }
+        cairo_stroke (cr);
+
+    }
+
+    cairo_destroy (cr);
+
+    return TRUE;
+}
+
+static void
+get_load (LoadGraph *graph)
+{
+    guint i;
+    glibtop_cpu cpu;
+
+    glibtop_get_cpu (&cpu);
+
+#undef NOW
+#undef LAST
+#define NOW  (graph->cpu.times[graph->cpu.now])
+#define LAST (graph->cpu.times[graph->cpu.now ^ 1])
+
+    if (graph->n == 1) {
+        NOW[0][CPU_TOTAL] = cpu.total;
+        NOW[0][CPU_USED] = cpu.user + cpu.nice + cpu.sys;
+    } else {
+        for (i = 0; i < graph->n; i++) {
+            NOW[i][CPU_TOTAL] = cpu.xcpu_total[i];
+            NOW[i][CPU_USED] = cpu.xcpu_user[i] + cpu.xcpu_nice[i]
+                + cpu.xcpu_sys[i];
+        }
+    }
+
+    // on the first call, LAST is 0
+    // which means data is set to the average load since boot
+    // that value has no meaning, we just want all the
+    // graphs to be aligned, so the CPU graph needs to start
+    // immediately
+
+    for (i = 0; i < graph->n; i++) {
+        float load;
+        float total, used;
+        gchar *text;
+
+        total = NOW[i][CPU_TOTAL] - LAST[i][CPU_TOTAL];
+        used  = NOW[i][CPU_USED]  - LAST[i][CPU_USED];
+
+        load = used / MAX(total, 1.0f);
+        graph->data[0][i] = load;
+
+        /* Update label */
+        text = g_strdup_printf("%.1f%%", load * 100.0f);
+        gtk_label_set_text(GTK_LABEL(graph->labels.cpu[i]), text);
+        g_free(text);
+    }
+
+    graph->cpu.now ^= 1;
+
+#undef NOW
+#undef LAST
+}
+
+
+namespace
+{
+
+    void set_memory_label_and_picker(GtkLabel* label, GSMColorButton* picker,
+                                   guint64 used, guint64 total, double percent)
+    {
+        char* used_text;
+        char* total_text;
+        char* text;
+
+        used_text = g_format_size_full(used, G_FORMAT_SIZE_IEC_UNITS);
+        total_text = g_format_size_full(total, G_FORMAT_SIZE_IEC_UNITS);
+        if (total == 0) {
+            text = g_strdup(_("not available"));
+        } else {
+            // xgettext: 540MiB (53 %) of 1.0 GiB
+            text = g_strdup_printf(_("%s (%.1f%%) of %s"), used_text, 100.0 * percent, total_text);
+        }
+        gtk_label_set_text(label, text);
+        g_free(used_text);
+        g_free(total_text);
+        g_free(text);
+
+        if (picker)
+            gsm_color_button_set_fraction(picker, percent);
+    }
+}
+
+static void
+get_memory (LoadGraph *graph)
+{
+    float mempercent, swappercent;
+
+    glibtop_mem mem;
+    glibtop_swap swap;
+
+    glibtop_get_mem (&mem);
+    glibtop_get_swap (&swap);
+
+    /* There's no swap on LiveCD : 0.0f is better than NaN :) */
+    swappercent = (swap.total ? (float)swap.used / (float)swap.total : 0.0f);
+    mempercent  = (float)mem.user  / (float)mem.total;
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.memory),
+                                GSM_COLOR_BUTTON(graph->mem_color_picker),
+                                mem.user, mem.total, mempercent);
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.swap),
+                                GSM_COLOR_BUTTON(graph->swap_color_picker),
+                                swap.used, swap.total, swappercent);
+
+    graph->data[0][0] = mempercent;
+    graph->data[0][1] = swappercent;
+}
+
+/* Nice Numbers for Graph Labels after Paul Heckbert
+   nicenum: find a "nice" number approximately equal to x.
+   Round the number if round=1, take ceiling if round=0    */
+
+static double
+nicenum (double x, int round)
+{
+    int expv;				/* exponent of x */
+    double f;				/* fractional part of x */
+    double nf;				/* nice, rounded fraction */
+
+    expv = floor( log10(x) );
+    f = x/pow( 10.0, expv );		/* between 1 and 10 */
+    if (round) {
+        if ( f < 1.5 ) nf = 1.0;
+        else if ( f < 3.0 ) nf = 2.0;
+        else if ( f < 7.0 ) nf = 5.0;
+        else nf = 10.0;
+    } else {
+        if ( f <= 1.0 ) nf = 1.0;
+        else if ( f <= 2.0 ) nf = 2.0;
+        else if ( f <= 5.0 ) nf = 5.0;
+        else nf = 10.0;
+    }
+    return nf * pow(10.0, expv);
+}
+
+static void
+net_scale (LoadGraph *graph, guint64 din, guint64 dout)
+{
+    graph->data[0][0] = 1.0f * din / graph->net.max;
+    graph->data[0][1] = 1.0f * dout / graph->net.max;
+
+    guint64 dmax = std::max(din, dout);
+    graph->net.values[graph->net.cur] = dmax;
+    graph->net.cur = (graph->net.cur + 1) % LoadGraph::NUM_POINTS;
+
+    guint64 new_max;
+    // both way, new_max is the greatest value
+    if (dmax >= graph->net.max)
+        new_max = dmax;
+    else
+        new_max = *std::max_element(&graph->net.values[0],
+                                    &graph->net.values[LoadGraph::NUM_POINTS]);
+
+    //
+    // Round network maximum
+    //
+
+    const guint64 bak_max(new_max);
+
+    if (ProcData::get_instance()->config.network_in_bits) {
+        // nice number is for the ticks
+        unsigned ticks = graph->num_bars();
+
+        // gets messy at low values due to division by 8
+        guint64 bit_max = std::max( new_max*8, G_GUINT64_CONSTANT(10000) );
+
+        // our tick size leads to max
+        double d = nicenum(bit_max/ticks, 0);
+        bit_max = ticks * d;
+        new_max = bit_max / 8;
+
+        procman_debug("bak*8 %" G_GUINT64_FORMAT ", ticks %d, d %f"
+                      ", bit_max %" G_GUINT64_FORMAT ", new_max %" G_GUINT64_FORMAT,
+                      bak_max*8, ticks, d, bit_max, new_max );
+    } else {
+        // round up to get some extra space
+        // yes, it can overflow
+        new_max = 1.1 * new_max;
+        // make sure max is not 0 to avoid / 0
+        // default to 1 KiB
+        new_max = std::max(new_max, G_GUINT64_CONSTANT(1024));
+
+        // decompose new_max = coef10 * 2**(base10 * 10)
+        // where coef10 and base10 are integers and coef10 < 2**10
+        //
+        // e.g: ceil(100.5 KiB) = 101 KiB = 101 * 2**(1 * 10)
+        //      where base10 = 1, coef10 = 101, pow2 = 16
+
+        guint64 pow2 = std::floor(log2(new_max));
+        guint64 base10 = pow2 / 10.0;
+        guint64 coef10 = std::ceil(new_max / double(G_GUINT64_CONSTANT(1) << (base10 * 10)));
+        g_assert(new_max <= (coef10 * (G_GUINT64_CONSTANT(1) << (base10 * 10))));
+
+        // then decompose coef10 = x * 10**factor10
+        // where factor10 is integer and x < 10
+        // so we new_max has only 1 significant digit
+
+        guint64 factor10 = std::pow(10.0, std::floor(std::log10(coef10)));
+        coef10 = std::ceil(coef10 / double(factor10)) * factor10;
+
+        // then make coef10 divisible by num_bars
+        if (coef10 % graph->num_bars() != 0)
+            coef10 = coef10 + (graph->num_bars() - coef10 % graph->num_bars());
+        g_assert(coef10 % graph->num_bars() == 0);
+        new_max = coef10 * (G_GUINT64_CONSTANT(1) << guint64(base10 * 10));
+        procman_debug("bak %" G_GUINT64_FORMAT " new_max %" G_GUINT64_FORMAT
+                      "pow2 %" G_GUINT64_FORMAT " coef10 %" G_GUINT64_FORMAT,
+                      bak_max, new_max, pow2, coef10);
+    }
+
+    if (bak_max > new_max) {
+        procman_debug("overflow detected: bak=%" G_GUINT64_FORMAT
+                      " new=%" G_GUINT64_FORMAT,
+                      bak_max, new_max);
+        new_max = bak_max;
+    }
+
+    // if max is the same or has decreased but not so much, don't
+    // do anything to avoid rescaling
+    if ((0.8 * graph->net.max) < new_max && new_max <= graph->net.max)
+        return;
+
+    const double scale = 1.0f * graph->net.max / new_max;
+
+    for (size_t i = 0; i < LoadGraph::NUM_POINTS; i++) {
+        if (graph->data[i][0] >= 0.0f) {
+            graph->data[i][0] *= scale;
+            graph->data[i][1] *= scale;
+        }
+    }
+
+    procman_debug("rescale dmax = %" G_GUINT64_FORMAT
+                  " max = %" G_GUINT64_FORMAT
+                  " new_max = %" G_GUINT64_FORMAT,
+                  dmax, graph->net.max, new_max);
+
+    graph->net.max = new_max;
+
+    // force the graph background to be redrawn now that scale has changed
+    graph->clear_background();
+}
+
+static void
+get_net (LoadGraph *graph)
+{
+    glibtop_netlist netlist;
+    char **ifnames;
+    guint32 i;
+    guint64 in = 0, out = 0;
+#if GLIB_CHECK_VERSION(2,61,2)
+    gint64 time;
+#else
+    GTimeVal time;
+#endif
+    guint64 din, dout;
+
+    ifnames = glibtop_get_netlist(&netlist);
+
+    for (i = 0; i < netlist.number; ++i)
+    {
+        glibtop_netload netload;
+        glibtop_get_netload (&netload, ifnames[i]);
+
+        if (netload.if_flags & (1 << GLIBTOP_IF_FLAGS_LOOPBACK))
+            continue;
+
+        /* Skip interfaces without any IPv4/IPv6 address (or
+         those with only a LINK ipv6 addr) However we need to
+         be able to exclude these while still keeping the
+         value so when they get online (with NetworkManager
+         for example) we don't get a suddent peak.  Once we're
+         able to get this, ignoring down interfaces will be
+         possible too.  */
+        if (not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS6)
+             and netload.scope6 != GLIBTOP_IF_IN6_SCOPE_LINK)
+            and not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS)))
+            continue;
+
+        /* Don't skip interfaces that are down (GLIBTOP_IF_FLAGS_UP)
+           to avoid spikes when they are brought up */
+
+        in  += netload.bytes_in;
+        out += netload.bytes_out;
+    }
+
+    g_strfreev(ifnames);
+
+#if GLIB_CHECK_VERSION(2,61,2)
+    time = g_get_real_time ();
+
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time != 0) {
+        float dtime = (double) (time - graph->net.time) / G_USEC_PER_SEC;
+#else
+    g_get_current_time (&time);
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time.tv_sec != 0) {
+        float dtime;
+        dtime = time.tv_sec - graph->net.time.tv_sec +
+            (double) (time.tv_usec - graph->net.time.tv_usec) / G_USEC_PER_SEC;
+#endif
+        din   = static_cast<guint64>((in  - graph->net.last_in)  / dtime);
+        dout  = static_cast<guint64>((out - graph->net.last_out) / dtime);
+    } else {
+        /* Don't calc anything if new data is less than old (interface
+           removed, counters reset, ...) or if it is the first time */
+        din  = 0;
+        dout = 0;
+    }
+
+    graph->net.last_in  = in;
+    graph->net.last_out = out;
+    graph->net.time     = time;
+
+    net_scale(graph, din, dout);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    g_autofree gchar *str=NULL, *formatted_str=NULL;
+
+    str = g_format_size_full (network_in_bits ? din*8 : din, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? in*8 : in, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in_total), str);
+
+    str = g_format_size_full (network_in_bits ? dout*8 : dout, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? out*8 : out, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out_total), str);
+}
+
+
+/* Updates the load graph when the timeout expires */
+static gboolean
+load_graph_update (gpointer user_data)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(user_data);
+
+    if (graph->render_counter == graph->frames_per_unit - 1) {
+        std::rotate(&graph->data[0], &graph->data[LoadGraph::NUM_POINTS - 1], &graph->data[LoadGraph::NUM_POINTS]);
+
+        switch (graph->type) {
+        case LOAD_GRAPH_CPU:
+            get_load(graph);
+            break;
+        case LOAD_GRAPH_MEM:
+            get_memory(graph);
+            break;
+        case LOAD_GRAPH_NET:
+            get_net(graph);
+            break;
+        default:
+            g_assert_not_reached();
+        }
+    }
+
+    if (graph->draw)
+        load_graph_queue_draw (graph);
+
+    graph->render_counter++;
+
+    if (graph->render_counter >= graph->frames_per_unit)
+        graph->render_counter = 0;
+
+    return TRUE;
+}
+
+
+
+LoadGraph::~LoadGraph()
+{
+  load_graph_stop(this);
+
+  if (timer_index)
+    g_source_remove(timer_index);
+
+  clear_background();
+}
+
+
+
+static gboolean
+load_graph_destroy (GtkWidget *widget, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    delete graph;
+
+    return FALSE;
+}
+
+
+LoadGraph::LoadGraph(guint type)
+  : fontsize(8.0),
+    rmargin(3.5 * fontsize),
+    indent(24.0),
+    n(0),
+    type(type),
+    speed(0),
+    draw_width(0),
+    draw_height(0),
+    render_counter(0),
+    frames_per_unit(10), // this will be changed but needs initialising
+    graph_dely(0),
+    real_draw_height(0),
+    graph_delx(0.0),
+    graph_buffer_offset(0),
+    main_widget(NULL),
+    disp(NULL),
+    background(NULL),
+    timer_index(0),
+    draw(FALSE),
+    mem_color_picker(NULL),
+    swap_color_picker(NULL)
+{
+    LoadGraph * const graph = this;
+
+    // FIXME:
+    // on configure, graph->frames_per_unit = graph->draw_width/(LoadGraph::NUM_POINTS);
+    // knock FRAMES down to 5 until cairo gets faster
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memset(&cpu, 0, sizeof cpu);
+        n = ProcData::get_instance()->config.num_cpus;
+
+        for(guint i = 0; i < G_N_ELEMENTS(labels.cpu); ++i)
+            labels.cpu[i] = gtk_label_new(NULL);
+
+        break;
+
+    case LOAD_GRAPH_MEM:
+        n = 2;
+        labels.memory = gtk_label_new(NULL);
+        labels.swap = gtk_label_new(NULL);
+        break;
+
+    case LOAD_GRAPH_NET:
+        memset(&net, 0, sizeof net);
+        n = 2;
+        net.max = 1;
+        labels.net_in = gtk_label_new(NULL);
+        labels.net_in_total = gtk_label_new(NULL);
+        labels.net_out = gtk_label_new(NULL);
+        labels.net_out_total = gtk_label_new(NULL);
+        break;
+    }
+
+    speed  = ProcData::get_instance()->config.graph_update_interval;
+
+    colors.resize(n);
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memcpy(&colors[0], ProcData::get_instance()->config.cpu_color,
+               n * sizeof colors[0]);
+        break;
+    case LOAD_GRAPH_MEM:
+        colors[0] = ProcData::get_instance()->config.mem_color;
+        colors[1] = ProcData::get_instance()->config.swap_color;
+        mem_color_picker = gsm_color_button_new (&colors[0],
+                                                 GSMCP_TYPE_PIE);
+        swap_color_picker = gsm_color_button_new (&colors[1],
+                                                  GSMCP_TYPE_PIE);
+        break;
+    case LOAD_GRAPH_NET:
+        colors[0] = ProcData::get_instance()->config.net_in_color;
+        colors[1] = ProcData::get_instance()->config.net_out_color;
+        break;
+    }
+
+    timer_index = 0;
+    render_counter = (frames_per_unit - 1);
+    draw = FALSE;
+
+    main_widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+    gtk_widget_set_size_request(main_widget, -1, LoadGraph::GRAPH_MIN_HEIGHT);
+    gtk_widget_show (main_widget);
+
+    disp = gtk_drawing_area_new ();
+    gtk_widget_show (disp);
+    g_signal_connect (G_OBJECT (disp), "draw", G_CALLBACK (load_graph_draw), graph);
+    g_signal_connect (G_OBJECT(disp), "configure_event",
+                      G_CALLBACK (load_graph_configure), graph);
+    g_signal_connect (G_OBJECT(disp), "destroy",
+                      G_CALLBACK (load_graph_destroy), graph);
+
+    gtk_widget_set_events (disp, GDK_EXPOSURE_MASK);
+
+    gtk_box_pack_start (GTK_BOX (main_widget), disp, TRUE, TRUE, 0);
+
+
+    /* Allocate data in a contiguous block */
+    data_block = std::vector<float>(n * LoadGraph::NUM_POINTS, -1.0f);
+
+    for (guint i = 0; i < LoadGraph::NUM_POINTS; ++i)
+        data[i] = &data_block[0] + i * n;
+
+    gtk_widget_show_all (main_widget);
+}
+
+void
+load_graph_start (LoadGraph *graph)
+{
+    if(!graph->timer_index) {
+
+        load_graph_update(graph);
+
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->draw = TRUE;
+}
+
+void
+load_graph_stop (LoadGraph *graph)
+{
+    /* don't draw anymore, but continue to poll */
+    graph->draw = FALSE;
+}
+
+void
+load_graph_change_speed (LoadGraph *graph,
+             guint new_speed)
+{
+    if (graph->speed == new_speed)
+        return;
+
+    graph->speed = new_speed;
+
+    if(graph->timer_index) {
+        g_source_remove (graph->timer_index);
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->clear_background();
+}
+
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *graph)
+{
+    return &graph->labels;
+}
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *graph)<--- Parameter 'graph' can be declared as pointer to const
+{
+    return graph->main_widget;
+}
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *graph)<--- Parameter 'graph' can be declared as pointer to const
+{
+    return graph->mem_color_picker;
+}
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *graph)<--- Parameter 'graph' can be declared as pointer to const
+{
+    return graph->swap_color_picker;
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/25.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/25.html new file mode 100644 index 00000000..cbf052f0 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/25.html @@ -0,0 +1,1075 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtkmm/messagedialog.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/regex.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procopenfiles.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <sys/wait.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <set><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sstream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <iterator><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibmm/regex.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "lsof.h"
+#include "util.h"
+
+
+using std::string;
+
+
+namespace
+{
+
+    class Lsof
+    {
+        Glib::RefPtr<Glib::Regex> re;
+
+        bool matches(const string &filename) const
+        {
+            return this->re->match(filename);
+        }
+
+    public:
+
+        Lsof(const string &pattern, bool caseless)
+        {
+            Glib::RegexCompileFlags flags = static_cast<Glib::RegexCompileFlags>(0);
+
+            if (caseless)
+                flags |= Glib::REGEX_CASELESS;
+
+            this->re = Glib::Regex::create(pattern, flags);
+        }
+
+
+        template<typename OutputIterator>
+        void search(const ProcInfo &info, OutputIterator out) const
+        {
+            glibtop_open_files_entry *entries;
+            glibtop_proc_open_files buf;
+
+            entries = glibtop_get_proc_open_files(&buf, info.pid);
+
+            for (unsigned i = 0; i != buf.number; ++i) {
+                if (entries[i].type & GLIBTOP_FILE_TYPE_FILE) {
+                    const string filename(entries[i].info.file.name);
+                    if (this->matches(filename))
+                        *out++ = filename;
+                }
+            }
+
+            g_free(entries);
+        }
+    };
+
+
+
+    // GUI Stuff
+
+
+    enum ProcmanLsof {
+        PROCMAN_LSOF_COL_SURFACE,
+        PROCMAN_LSOF_COL_PROCESS,
+        PROCMAN_LSOF_COL_PID,
+        PROCMAN_LSOF_COL_FILENAME,
+        PROCMAN_LSOF_NCOLS
+    };
+
+
+    struct GUI {
+
+        GtkListStore *model;
+        GtkEntry *entry;
+        GtkWindow *window;
+        GtkLabel *count;<--- Shadowed declaration
+        ProcData *procdata;
+        bool case_insensitive;
+
+
+        GUI()
+        {
+            procman_debug("New Lsof GUI %p", this);
+        }
+
+
+        ~GUI()
+        {
+            procman_debug("Destroying Lsof GUI %p", this);
+        }
+
+
+        void clear_results()
+        {
+            gtk_list_store_clear(this->model);
+            gtk_label_set_text(this->count, "");
+        }
+
+
+        void clear()
+        {
+            this->clear_results();
+            gtk_entry_set_text(this->entry, "");
+        }
+
+
+        void display_regex_error(const Glib::RegexError& error)
+        {
+            char * msg = g_strdup_printf ("<b>%s</b>\n%s\n%s",
+                                          _("Error"),
+                                          _("'%s' is not a valid Perl regular expression."),
+                                          "%s");
+            std::string message = make_string(g_strdup_printf(msg, this->pattern().c_str(), error.what().c_str()));
+            g_free(msg);
+
+            Gtk::MessageDialog dialog(message,
+                                      true, // use markup
+                                      Gtk::MESSAGE_ERROR,
+                                      Gtk::BUTTONS_OK,
+                                      true); // modal
+            dialog.run();
+        }
+
+
+        void update_count(unsigned count)
+        {
+            std::ostringstream ss;
+            ss << count;
+            string s = ss.str();
+            gtk_label_set_text(this->count, s.c_str());
+        }
+
+
+        string pattern() const
+        {
+            return gtk_entry_get_text(this->entry);
+        }
+
+
+        void search()
+        {
+            typedef std::set<string> MatchSet;
+            typedef MatchSet::const_iterator iterator;
+
+            this->clear_results();
+
+
+            try {
+                Lsof lsof(this->pattern(), this->case_insensitive);
+
+                unsigned count = 0;<--- Shadow variable
+
+                for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it) {
+                    const ProcInfo &info(*it->second);
+
+                    MatchSet matches;
+                    lsof.search(info, std::inserter(matches, matches.begin()));
+                    count += matches.size();
+
+                    for (iterator it(matches.begin()), end(matches.end()); it != end; ++it) {
+                        GtkTreeIter file;
+                        gtk_list_store_append(this->model, &file);
+                        gtk_list_store_set(this->model, &file,
+                                           PROCMAN_LSOF_COL_SURFACE, info.surface,
+                                           PROCMAN_LSOF_COL_PROCESS, info.name,
+                                           PROCMAN_LSOF_COL_PID, info.pid,
+                                           PROCMAN_LSOF_COL_FILENAME, it->c_str(),
+                                           -1);
+                    }
+                }
+
+                this->update_count(count);
+            }
+            catch (Glib::RegexError& error) {
+                this->display_regex_error(error);
+            }
+        }
+
+
+        static void search_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void search_entry_activate(GtkEntry *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void clear_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->clear();
+        }
+
+
+        static void close_button_clicked(GtkButton *, gpointer data)
+        {
+            GUI *gui = static_cast<GUI*>(data);
+            gtk_widget_destroy(GTK_WIDGET(gui->window));
+            delete gui;
+        }
+
+
+        static void case_button_toggled(GtkToggleButton *button, gpointer data)
+        {
+            bool state = gtk_toggle_button_get_active(button);
+            static_cast<GUI*>(data)->case_insensitive = state;
+        }
+
+
+        static gboolean window_delete_event(GtkWidget *, GdkEvent *, gpointer data)
+        {
+            delete static_cast<GUI*>(data);
+            return FALSE;
+        }
+
+    };
+}
+
+
+
+
+void procman_lsof(ProcData *procdata)
+{
+    GtkListStore *model = \
+        gtk_list_store_new(PROCMAN_LSOF_NCOLS,
+                           CAIRO_GOBJECT_TYPE_SURFACE, // PROCMAN_LSOF_COL_SURFACE
+                           G_TYPE_STRING,              // PROCMAN_LSOF_COL_PROCESS
+                           G_TYPE_UINT,                // PROCMAN_LSOF_COL_PID
+                           G_TYPE_STRING               // PROCMAN_LSOF_COL_FILENAME
+        );
+
+    GtkWidget *tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_object_unref(model);
+
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *renderer;
+
+    // SURFACE / PROCESS
+
+    column = gtk_tree_view_column_new();
+
+    renderer = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "surface", PROCMAN_LSOF_COL_SURFACE,
+                                        NULL);
+
+    renderer = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "text", PROCMAN_LSOF_COL_PROCESS,
+                                        NULL);
+
+    gtk_tree_view_column_set_title(column, _("Process"));
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PROCESS);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_column_set_min_width(column, 10);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), PROCMAN_LSOF_COL_PROCESS,
+                                         GTK_SORT_ASCENDING);
+
+
+    // PID
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("PID"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_PID,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PID);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    // FILENAME
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("Filename"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_FILENAME,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_FILENAME);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    GtkWidget *dialog; /* = gtk_dialog_new_with_buttons(_("Search for Open Files"), NULL,
+                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+                                                        NULL); */
+    dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(procdata->app));
+    gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
+    // gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_title(GTK_WINDOW(dialog), _("Search for Open Files"));
+
+    // g_signal_connect(G_OBJECT(dialog), "response",
+    //                           G_CALLBACK(close_dialog), NULL);
+    gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(dialog), 575, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(dialog), 12);
+    GtkWidget *mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_add(GTK_CONTAINER(dialog), mainbox);
+    gtk_box_set_spacing(GTK_BOX(mainbox), 6);
+
+
+    // Label, entry and search button
+
+    GtkWidget *hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), hbox1, FALSE, FALSE, 0);
+
+    GtkWidget *image = gtk_image_new_from_icon_name("edit-find", GTK_ICON_SIZE_DIALOG);
+    gtk_box_pack_start(GTK_BOX(hbox1), image, FALSE, FALSE, 0);
+
+
+    GtkWidget *vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox1), vbox2, TRUE, TRUE, 0);
+
+
+    GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox, TRUE, TRUE, 0);
+    GtkWidget *label = gtk_label_new_with_mnemonic(_("_Name contains:"));
+    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+    GtkWidget *entry = gtk_entry_new();
+
+    gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
+
+    GtkWidget *search_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                         "label", "gtk-find",
+                                                         "use-stock", TRUE,
+                                                         "use-underline", TRUE,
+                                                         NULL));
+
+    gtk_box_pack_start(GTK_BOX(hbox), search_button, FALSE, FALSE, 0);
+
+    GtkWidget *clear_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-clear",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    /* The default accelerator collides with the default close accelerator. */
+    gtk_button_set_label(GTK_BUTTON(clear_button), _("C_lear"));
+    gtk_box_pack_start(GTK_BOX(hbox), clear_button, FALSE, FALSE, 0);
+
+
+    GtkWidget *case_button = gtk_check_button_new_with_mnemonic(_("Case insensitive matching"));
+    GtkWidget *hbox3 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox3), case_button, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox3, FALSE, FALSE, 0);
+
+
+    GtkWidget *results_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), results_box, FALSE, FALSE, 0);
+    GtkWidget *results_label = gtk_label_new_with_mnemonic(_("S_earch results:"));
+    gtk_box_pack_start(GTK_BOX(results_box), results_label, FALSE, FALSE, 0);
+    GtkWidget *count_label = gtk_label_new(NULL);
+    gtk_box_pack_end(GTK_BOX(results_box), count_label, FALSE, FALSE, 0);
+
+    // Scrolled TreeView
+    GtkWidget *scrolled = gtk_scrolled_window_new(NULL, NULL);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
+                                   GTK_POLICY_AUTOMATIC,
+                                   GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled),
+                                        GTK_SHADOW_IN);
+    gtk_container_add(GTK_CONTAINER(scrolled), tree);
+    gtk_box_pack_start(GTK_BOX(mainbox), scrolled, TRUE, TRUE, 0);
+
+    GtkWidget *bottom_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+
+    GtkWidget *close_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-close",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    gtk_box_pack_start(GTK_BOX(mainbox), bottom_box, FALSE, FALSE, 0);
+    gtk_box_pack_end(GTK_BOX(bottom_box), close_button, FALSE, FALSE, 0);
+
+
+    GUI *gui = new GUI; // wil be deleted by the close button or delete-event
+    gui->procdata = procdata;
+    gui->model = model;
+    gui->window = GTK_WINDOW(dialog);
+    gui->entry = GTK_ENTRY(entry);
+    gui->count = GTK_LABEL(count_label);
+
+    g_signal_connect(G_OBJECT(entry), "activate",
+                     G_CALLBACK(GUI::search_entry_activate), gui);
+    g_signal_connect(G_OBJECT(clear_button), "clicked",
+                     G_CALLBACK(GUI::clear_button_clicked), gui);
+    g_signal_connect(G_OBJECT(search_button), "clicked",
+                     G_CALLBACK(GUI::search_button_clicked), gui);
+    g_signal_connect(G_OBJECT(close_button), "clicked",
+                     G_CALLBACK(GUI::close_button_clicked), gui);
+    g_signal_connect(G_OBJECT(case_button), "toggled",
+                     G_CALLBACK(GUI::case_button_toggled), gui);
+    g_signal_connect(G_OBJECT(dialog), "delete-event",
+                     G_CALLBACK(GUI::window_delete_event), gui);
+
+
+    gtk_widget_show_all(dialog);
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/26.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/26.html new file mode 100644 index 00000000..7bce5b12 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/26.html @@ -0,0 +1,1197 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibtop/procmap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mountlist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <map><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sstream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <iomanip><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdexcept><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+using std::string;
+
+
+#include "procman.h"
+#include "memmaps.h"
+#include "proctable.h"
+#include "util.h"
+
+
+/* be careful with this enum, you could break the column names */
+enum
+{
+    MMAP_COL_FILENAME,
+    MMAP_COL_VMSTART,
+    MMAP_COL_VMEND,
+    MMAP_COL_VMSZ,
+    MMAP_COL_FLAGS,
+    MMAP_COL_VMOFFSET,
+    MMAP_COL_PRIVATE_CLEAN,
+    MMAP_COL_PRIVATE_DIRTY,
+    MMAP_COL_SHARED_CLEAN,
+    MMAP_COL_SHARED_DIRTY,
+    MMAP_COL_DEVICE,
+    MMAP_COL_INODE,
+    MMAP_COL_MAX
+};
+
+
+namespace
+{
+    class OffsetFormater
+    {
+        string format;
+
+    public:
+
+        void set(const glibtop_map_entry &last_map)
+        {
+            this->format = (last_map.end <= G_MAXUINT32) ? "%08" G_GINT64_MODIFIER "x" : "%016" G_GINT64_MODIFIER "x";
+        }
+
+        string operator()(guint64 v) const
+        {
+            char buffer[17];
+            g_snprintf(buffer, sizeof buffer, this->format.c_str(), v);
+            return buffer;
+        }
+    };
+
+
+    class InodeDevices
+    {
+        typedef std::map<guint16, string> Map;
+        Map devices;
+
+    public:
+
+        void update()
+        {
+            this->devices.clear();
+
+            glibtop_mountlist list;
+            glibtop_mountentry *entries = glibtop_get_mountlist(&list, 1);
+
+            for (unsigned i = 0; i != list.number; ++i) {
+                struct stat buf;
+
+                if (stat(entries[i].devname, &buf) != -1)
+                    this->devices[buf.st_rdev] = entries[i].devname;
+            }
+
+            g_free(entries);
+        }
+
+        string get(guint64 dev64)
+        {
+            if (dev64 == 0)
+                return "";
+
+            guint16 dev = dev64 & 0xffff;
+
+            if (dev != dev64)
+                g_warning("weird device %" G_GINT64_MODIFIER "x", dev64);
+
+            Map::iterator it(this->devices.find(dev));
+
+            if (it != this->devices.end())
+                return it->second;
+
+            guint8 major, minor;
+            major = dev >> 8;
+            minor = dev;
+
+            std::ostringstream out;
+            out << std::hex
+                << std::setfill('0')
+                << std::setw(2) << unsigned(major)
+                << ':'
+                << std::setw(2) << unsigned(minor);
+
+            this->devices[dev] = out.str();
+            return out.str();
+        }
+    };
+
+
+    class MemMapsData
+    {
+    public:
+        guint timer;
+        GtkWidget *tree;
+        GSettings *settings;
+        ProcInfo *info;
+        OffsetFormater format;
+        mutable InodeDevices devices;
+        const char * const schema;
+
+        MemMapsData(GtkWidget *a_tree, GSettings *a_settings)
+            : tree(a_tree),
+            settings(a_settings),
+            schema("memmapstree")
+        {
+            procman_get_tree_state(this->settings, this->tree, this->schema);
+        }
+
+        ~MemMapsData()
+        {
+            procman_save_tree_state(this->settings, this->tree, this->schema);
+        }
+    };
+}
+
+
+struct glibtop_map_entry_cmp
+{
+    bool operator()(const glibtop_map_entry &a, const guint64 start) const
+    {
+        return a.start < start;
+    }
+
+    bool operator()(const guint64 &start, const glibtop_map_entry &a) const
+    {
+        return start < a.start;
+    }
+
+};
+
+
+static void
+update_row(GtkTreeModel *model, GtkTreeIter &row, const MemMapsData &mm, const glibtop_map_entry *memmaps)
+{
+    guint64 size;
+    string filename, device;
+    string vmstart, vmend, vmoffset;
+    char flags[5] = "----";
+
+    size = memmaps->end - memmaps->start;
+
+    if(memmaps->perm & GLIBTOP_MAP_PERM_READ)    flags [0] = 'r';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_WRITE)   flags [1] = 'w';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_EXECUTE) flags [2] = 'x';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_SHARED)  flags [3] = 's';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_PRIVATE) flags [3] = 'p';
+
+    if (memmaps->flags & (1 << GLIBTOP_MAP_ENTRY_FILENAME))
+      filename = memmaps->filename;
+
+    vmstart  = mm.format(memmaps->start);
+    vmend    = mm.format(memmaps->end);
+    vmoffset = mm.format(memmaps->offset);
+    device   = mm.devices.get(memmaps->device);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        MMAP_COL_FILENAME, filename.c_str(),
+                        MMAP_COL_VMSTART, vmstart.c_str(),
+                        MMAP_COL_VMEND, vmend.c_str(),
+                        MMAP_COL_VMSZ, size,
+                        MMAP_COL_FLAGS, flags,
+                        MMAP_COL_VMOFFSET, vmoffset.c_str(),
+                        MMAP_COL_PRIVATE_CLEAN, memmaps->private_clean,
+                        MMAP_COL_PRIVATE_DIRTY, memmaps->private_dirty,
+                        MMAP_COL_SHARED_CLEAN, memmaps->shared_clean,
+                        MMAP_COL_SHARED_DIRTY, memmaps->shared_dirty,
+                        MMAP_COL_DEVICE, device.c_str(),
+                        MMAP_COL_INODE, memmaps->inode,
+                        -1);
+}
+
+
+
+
+static void
+update_memmaps_dialog (MemMapsData *mmdata)
+{
+    GtkTreeModel *model;
+    glibtop_map_entry *memmaps;
+    glibtop_proc_map procmap;
+
+    memmaps = glibtop_get_proc_map (&procmap, mmdata->info->pid);
+    /* process has disappeared */
+    if(!memmaps or procmap.number == 0) return;
+
+    mmdata->format.set(memmaps[procmap.number - 1]);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+
+    GtkTreeIter iter;<--- Shadowed declaration
+
+    typedef std::map<guint64, GtkTreeIter> IterCache;
+    IterCache iter_cache;
+
+    /*
+      removes the old maps and
+      also fills a cache of start -> iter in order to speed
+      up add
+    */
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        while (true) {
+            char *vmstart = 0;
+            guint64 start;
+            gtk_tree_model_get(model, &iter,
+                               MMAP_COL_VMSTART, &vmstart,
+                               -1);
+
+            try {
+                std::istringstream(vmstart) >> std::hex >> start;
+            } catch (std::logic_error &e) {
+                g_warning("Could not parse %s", vmstart);
+                start = 0;
+            }
+
+            g_free(vmstart);
+
+            bool found = std::binary_search(memmaps, memmaps + procmap.number,
+                                            start, glibtop_map_entry_cmp());
+
+            if (found) {
+                iter_cache[start] = iter;
+                if (!gtk_tree_model_iter_next(model, &iter))
+                    break;
+            } else {
+                if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                    break;
+            }
+        }
+    }
+
+    mmdata->devices.update();
+
+    /*
+      add the new maps
+    */
+
+    for (guint i = 0; i != procmap.number; i++) {
+        GtkTreeIter iter;<--- Shadow variable
+        IterCache::iterator it(iter_cache.find(memmaps[i].start));
+
+        if (it != iter_cache.end())
+            iter = it->second;
+        else
+            gtk_list_store_prepend(GTK_LIST_STORE(model), &iter);
+
+        update_row(model, iter, *mmdata, &memmaps[i]);
+    }
+
+    g_free (memmaps);
+}
+
+
+
+static void
+dialog_response (GtkDialog * dialog, gint response_id, gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+
+    g_source_remove (mmdata->timer);
+
+    delete mmdata;
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+
+static MemMapsData*
+create_memmapsdata (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Filename"),
+        // xgettext: virtual memory start
+        N_("VM Start"),
+        // xgettext: virtual memory end
+        N_("VM End"),
+        // xgettext: virtual memory syze
+        N_("VM Size"),
+        N_("Flags"),
+        // xgettext: virtual memory offset
+        N_("VM Offset"),
+        // xgettext: memory that has not been modified since
+        // it has been allocated
+        N_("Private clean"),
+        // xgettext: memory that has been modified since it
+        // has been allocated
+        N_("Private dirty"),
+        // xgettext: shared memory that has not been modified
+        // since it has been allocated
+        N_("Shared clean"),
+        // xgettext: shared memory that has been modified
+        // since it has been allocated
+        N_("Shared dirty"),
+        N_("Device"),
+        N_("Inode")
+    };
+
+    model = gtk_list_store_new (MMAP_COL_MAX,
+                                G_TYPE_STRING, /* MMAP_COL_FILENAME  */
+                                G_TYPE_STRING, /* MMAP_COL_VMSTART     */
+                                G_TYPE_STRING, /* MMAP_COL_VMEND     */
+                                G_TYPE_UINT64, /* MMAP_COL_VMSZ     */
+                                G_TYPE_STRING, /* MMAP_COL_FLAGS     */
+                                G_TYPE_STRING, /* MMAP_COL_VMOFFSET  */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_DIRTY */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_DIRTY */
+                                G_TYPE_STRING, /* MMAP_COL_DEVICE     */
+                                G_TYPE_UINT64 /* MMAP_COL_INODE     */
+                                );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < MMAP_COL_MAX; i++) {
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(tree), col);
+
+        switch (i) {
+            case MMAP_COL_PRIVATE_CLEAN:
+            case MMAP_COL_PRIVATE_DIRTY:
+            case MMAP_COL_SHARED_CLEAN:
+            case MMAP_COL_SHARED_DIRTY:
+            case MMAP_COL_VMSZ:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                         &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+                break;
+        }
+
+
+        switch (i) {
+            case MMAP_COL_VMSTART:
+            case MMAP_COL_VMEND:
+            case MMAP_COL_FLAGS:
+            case MMAP_COL_VMOFFSET:
+            case MMAP_COL_DEVICE:
+                g_object_set(cell, "family", "monospace", NULL);
+                break;
+        }
+    }
+
+    return new MemMapsData(tree, procdata->settings);
+}
+
+
+static gboolean
+memmaps_timer (gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+    g_assert(model);
+
+    update_memmaps_dialog (mmdata);
+
+    return TRUE;
+}
+
+
+static void
+create_single_memmaps_dialog (GtkTreeModel *model, GtkTreePath *path,
+                              GtkTreeIter *iter, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    MemMapsData *mmdata;
+    GtkWidget *memmapsdialog;
+    GtkWidget *dialog_vbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    ProcInfo *info;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    mmdata = create_memmapsdata (procdata);
+    mmdata->info = info;
+
+    memmapsdialog = gtk_dialog_new_with_buttons (_("Memory Maps"), GTK_WINDOW (procdata->app),
+                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                 "gtk-close", GTK_RESPONSE_CLOSE,
+                                                 NULL);
+    gtk_window_set_resizable(GTK_WINDOW(memmapsdialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(memmapsdialog), 620, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(memmapsdialog), 5);
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG(memmapsdialog));
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Memory maps for process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), label, FALSE, TRUE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    gtk_container_add (GTK_CONTAINER (scrolled), mmdata->tree);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), mmdata->tree);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+
+    g_signal_connect(G_OBJECT(memmapsdialog), "response",
+                              G_CALLBACK(dialog_response), mmdata);
+
+    gtk_widget_show_all (memmapsdialog);
+
+    mmdata->timer = g_timeout_add_seconds (5, memmaps_timer, mmdata);
+
+    update_memmaps_dialog (mmdata);
+}
+
+
+void
+create_memmaps_dialog (ProcData *procdata)
+{
+    /* TODO: do we really want to open multiple dialogs ? */
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_memmaps_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/27.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/27.html new file mode 100644 index 00000000..fec20c10 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/27.html @@ -0,0 +1,1067 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#if defined (__ELF__) && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
+# define SECTION __attribute__ ((section (".gresource.msm"), aligned (8)))
+#else
+# define SECTION
+#endif
+
+static const SECTION union { const guint8 data[3353]; const double alignment; void * const ptr;}  msm_resource_data = { {<--- union member 'Anonymous0::alignment' is never used.<--- union member 'Anonymous0::ptr' is never used.
+  0107, 0126, 0141, 0162, 0151, 0141, 0156, 0164, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0030, 0000, 0000, 0000, 0310, 0000, 0000, 0000, 0000, 0000, 0000, 0050, 0006, 0000, 0000, 0000, 
+  0000, 0000, 0000, 0000, 0001, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0005, 0000, 0000, 0000, 0376, 0236, 0033, 0101, 0005, 0000, 0000, 0000, 
+  0310, 0000, 0000, 0000, 0024, 0000, 0114, 0000, 0334, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 
+  0113, 0120, 0220, 0013, 0002, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 0004, 0000, 0114, 0000, 
+  0350, 0000, 0000, 0000, 0354, 0000, 0000, 0000, 0324, 0265, 0002, 0000, 0377, 0377, 0377, 0377, 
+  0354, 0000, 0000, 0000, 0001, 0000, 0114, 0000, 0360, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 
+  0173, 0250, 0316, 0037, 0000, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 0014, 0000, 0166, 0000, 
+  0000, 0001, 0000, 0000, 0034, 0006, 0000, 0000, 0234, 0164, 0275, 0021, 0000, 0000, 0000, 0000, 
+  0034, 0006, 0000, 0000, 0016, 0000, 0166, 0000, 0060, 0006, 0000, 0000, 0017, 0015, 0000, 0000, 
+  0201, 0321, 0040, 0031, 0001, 0000, 0000, 0000, 0017, 0015, 0000, 0000, 0005, 0000, 0114, 0000, 
+  0024, 0015, 0000, 0000, 0030, 0015, 0000, 0000, 0155, 0141, 0164, 0145, 0055, 0163, 0171, 0163, 
+  0164, 0145, 0155, 0055, 0155, 0157, 0156, 0151, 0164, 0157, 0162, 0057, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0157, 0162, 0147, 0057, 0005, 0000, 0000, 0000, 0057, 0000, 0000, 0000, 
+  0001, 0000, 0000, 0000, 0151, 0156, 0164, 0145, 0162, 0146, 0141, 0143, 0145, 0056, 0165, 0151, 
+  0242, 0073, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0133, 0133, 0163, 0352, 0066, 
+  0020, 0176, 0317, 0257, 0160, 0375, 0332, 0161, 0010, 0227, 0320, 0164, 0006, 0070, 0323, 0166, 
+  0232, 0364, 0241, 0347, 0114, 0046, 0344, 0114, 0037, 0031, 0331, 0136, 0260, 0212, 0054, 0271, 
+  0222, 0314, 0345, 0337, 0237, 0065, 0066, 0004, 0002, 0370, 0102, 0210, 0061, 0224, 0067, 0154, 
+  0257, 0054, 0355, 0267, 0253, 0335, 0317, 0253, 0245, 0363, 0145, 0346, 0063, 0143, 0002, 0122, 
+  0121, 0301, 0273, 0146, 0375, 0366, 0316, 0064, 0200, 0073, 0302, 0245, 0174, 0324, 0065, 0277, 
+  0277, 0076, 0132, 0017, 0346, 0227, 0336, 0115, 0347, 0047, 0313, 0062, 0236, 0200, 0203, 0044, 
+  0032, 0134, 0143, 0112, 0265, 0147, 0214, 0030, 0161, 0301, 0150, 0336, 0066, 0037, 0156, 0033, 
+  0206, 0145, 0241, 0020, 0345, 0032, 0344, 0220, 0070, 0320, 0353, 0110, 0370, 0057, 0244, 0022, 
+  0224, 0301, 0250, 0335, 0065, 0107, 0172, 0374, 0263, 0371, 0066, 0113, 0363, 0266, 0321, 0062, 
+  0153, 0275, 0216, 0260, 0377, 0005, 0107, 0033, 0016, 0043, 0112, 0165, 0315, 0047, 0075, 0376, 
+  0207, 0162, 0127, 0114, 0115, 0203, 0272, 0135, 0323, 0047, 0224, 0017, 0246, 0361, 0215, 0136, 
+  0047, 0220, 0042, 0000, 0251, 0347, 0006, 0047, 0076, 0164, 0115, 0207, 0160, 0153, 0050, 0234, 
+  0120, 0231, 0275, 0107, 0302, 0024, 0164, 0152, 0113, 0201, 0055, 0121, 0115, 0065, 0003, 0323, 
+  0320, 0222, 0160, 0305, 0210, 0046, 0066, 0303, 0233, 0163, 0300, 0221, 0375, 0271, 0322, 0340, 
+  0033, 0137, 0005, 0247, 0132, 0310, 0224, 0127, 0270, 0060, 0044, 0041, 0323, 0326, 0224, 0272, 
+  0332, 0063, 0173, 0255, 0326, 0135, 0016, 0141, 0017, 0350, 0310, 0323, 0050, 0375, 0353, 0375, 
+  0272, 0264, 0343, 0121, 0346, 0356, 0120, 0375, 0167, 0061, 0133, 0323, 0333, 0306, 0253, 0255, 
+  0067, 0117, 0250, 0242, 0270, 0172, 0263, 0367, 0052, 0303, 0064, 0215, 0013, 0200, 0043, 0044, 
+  0005, 0256, 0211, 0106, 0263, 0230, 0075, 0264, 0217, 0246, 0016, 0141, 0073, 0226, 0033, 0060, 
+  0264, 0252, 0047, 0230, 0013, 0022, 0355, 0126, 0113, 0356, 0356, 0323, 0345, 0233, 0320, 0140, 
+  0013, 0061, 0216, 0025, 0342, 0313, 0253, 0143, 0050, 0224, 0041, 0351, 0023, 0071, 0242, 0334, 
+  0122, 0232, 0110, 0204, 0276, 0336, 0310, 0026, 0005, 0356, 0346, 0023, 0324, 0042, 0170, 0057, 
+  0230, 0151, 0113, 0065, 0127, 0224, 0017, 0105, 0151, 0346, 0364, 0140, 0026, 0220, 0110, 0241, 
+  0214, 0127, 0116, 0162, 0312, 0331, 0102, 0242, 0305, 0227, 0176, 0237, 0212, 0222, 0012, 0210, 
+  0203, 0061, 0143, 0017, 0104, 0251, 0376, 0263, 0373, 0141, 0055, 0206, 0365, 0235, 0264, 0241, 
+  0347, 0101, 0264, 0251, 0211, 0155, 0356, 0000, 0376, 0157, 0142, 0003, 0333, 0204, 0236, 0055, 
+  0156, 0225, 0001, 0176, 0074, 0323, 0376, 0100, 0263, 0076, 0164, 0245, 0034, 0242, 0066, 0106, 
+  0330, 0266, 0243, 0026, 0261, 0255, 0041, 0145, 0154, 0307, 0264, 0265, 0325, 0230, 0254, 0175, 
+  0270, 0362, 0103, 0034, 0354, 0374, 0037, 0234, 0060, 0063, 0234, 0355, 0165, 0332, 0207, 0074, 
+  0373, 0172, 0315, 0275, 0230, 0040, 0356, 0200, 0114, 0106, 0045, 0372, 0227, 0107, 0030, 0035, 
+  0241, 0136, 0213, 0340, 0126, 0310, 0231, 0226, 0100, 0147, 0315, 0020, 0073, 0134, 0306, 0212, 
+  0003, 0241, 0150, 0014, 0360, 0335, 0141, 0136, 0331, 0167, 0244, 0140, 0014, 0334, 0365, 0144, 
+  0037, 0071, 0050, 0050, 0005, 0152, 0240, 0222, 0247, 0145, 0144, 0213, 0143, 0173, 0252, 0362, 
+  0010, 0152, 0144, 0105, 0041, 0312, 0354, 0121, 0236, 0073, 0016, 0236, 0312, 0200, 0365, 0003, 
+  0303, 0112, 0250, 0065, 0016, 0137, 0030, 0016, 0323, 0147, 0142, 0073, 0073, 0276, 0133, 0040, 
+  0054, 0376, 0311, 0135, 0143, 0360, 0034, 0217, 0116, 0131, 0157, 0250, 0300, 0042, 0116, 0264, 
+  0142, 0213, 0004, 0001, 0020, 0174, 0221, 0003, 0331, 0130, 0034, 0337, 0135, 0044, 0070, 0100, 
+  0047, 0240, 0254, 0204, 0342, 0145, 0373, 0127, 0262, 0143, 0021, 0244, 0014, 0375, 0102, 0216, 
+  0036, 0301, 0050, 0337, 0261, 0334, 0123, 0071, 0107, 0043, 0335, 0071, 0062, 0227, 0125, 0314, 
+  0315, 0162, 0347, 0365, 0105, 0052, 0253, 0102, 0122, 0177, 0136, 0206, 0254, 0102, 0306, 0332, 
+  0203, 0312, 0247, 0146, 0177, 0374, 0014, 0273, 0046, 0377, 0242, 0214, 0165, 0077, 0234, 0116, 
+  0020, 0126, 0347, 0373, 0154, 0257, 0116, 0167, 0005, 0011, 0115, 0244, 0125, 0025, 0266, 0325, 
+  0037, 0317, 0337, 0215, 0277, 0250, 0302, 0017, 0362, 0171, 0312, 0370, 0131, 0022, 0131, 0067, 
+  0264, 0044, 0132, 0113, 0212, 0151, 0010, 0324, 0332, 0357, 0144, 0300, 0064, 0376, 0032, 0067, 
+  0046, 0204, 0205, 0013, 0267, 0142, 0156, 0124, 0201, 0250, 0255, 0217, 0071, 0063, 0036, 0265, 
+  0341, 0220, 0043, 0111, 0002, 0357, 0154, 0167, 0371, 0301, 0156, 0336, 0376, 0160, 0255, 0342, 
+  0221, 0211, 0351, 0006, 0222, 0103, 0274, 0121, 0032, 0220, 0223, 0175, 0234, 0076, 0265, 0256, 
+  0161, 0377, 0113, 0332, 0354, 0202, 0205, 0076, 0212, 0056, 0041, 0112, 0013, 0231, 0022, 0331, 
+  0152, 0056, 0101, 0037, 0047, 0137, 0040, 0050, 0201, 0133, 0370, 0300, 0212, 0271, 0112, 0063, 
+  0165, 0311, 0263, 0135, 0103, 0322, 0213, 0010, 0300, 0040, 0146, 0172, 0276, 0160, 0121, 0230, 
+  0013, 0176, 0112, 0056, 0204, 0223, 0044, 0144, 0076, 0235, 0301, 0345, 0246, 0072, 0025, 0045, 
+  0372, 0347, 0032, 0370, 0174, 0360, 0057, 0060, 0023, 0107, 0132, 0125, 0041, 0023, 0177, 0005, 
+  0037, 0223, 0260, 0201, 0206, 0067, 0372, 0123, 0022, 0134, 0263, 0162, 0161, 0347, 0274, 0146, 
+  0345, 0174, 0131, 0071, 0072, 0135, 0302, 0004, 0263, 0310, 0134, 0252, 0333, 0302, 0337, 0230, 
+  0231, 0124, 0167, 0161, 0254, 0264, 0015, 0361, 0223, 0244, 0356, 0033, 0306, 0013, 0227, 0055, 
+  0005, 0337, 0002, 0111, 0070, 0257, 0051, 0066, 0022, 0160, 0273, 0100, 0126, 0157, 0147, 0274, 
+  0324, 0023, 0276, 0030, 0001, 0007, 0261, 0253, 0256, 0221, 0043, 0010, 0051, 0334, 0361, 0145, 
+  0326, 0066, 0163, 0342, 0225, 0122, 0143, 0307, 0005, 0027, 0015, 0115, 0231, 0241, 0205, 0301, 
+  0120, 0133, 0030, 0214, 0210, 0343, 0245, 0223, 0035, 0055, 0202, 0225, 0334, 0201, 0201, 0143, 
+  0063, 0003, 0140, 0240, 0075, 0053, 0370, 0343, 0144, 0361, 0271, 0006, 0250, 0037, 0325, 0000, 
+  0007, 0034, 0111, 0235, 0342, 0341, 0225, 0362, 0136, 0024, 0345, 0255, 0177, 0220, 0125, 0160, 
+  0320, 0027, 0110, 0171, 0043, 0255, 0252, 0100, 0171, 0277, 0201, 0236, 0012, 0071, 0276, 0122, 
+  0335, 0342, 0116, 0171, 0245, 0272, 0173, 0330, 0154, 0073, 0067, 0233, 0215, 0140, 0074, 0031, 
+  0233, 0155, 0345, 0154, 0225, 0151, 0076, 0134, 0062, 0355, 0215, 0217, 0370, 0160, 0252, 0263, 
+  0042, 0137, 0057, 0313, 0125, 0237, 0023, 0377, 0112, 0063, 0203, 0026, 0232, 0260, 0101, 0162, 
+  0336, 0352, 0236, 0225, 0055, 0136, 0243, 0245, 0033, 0057, 0311, 0322, 0253, 0141, 0220, 0372, 
+  0207, 0015, 0242, 0160, 0357, 0237, 0333, 0256, 0350, 0143, 0104, 0377, 0134, 0374, 0357, 0113, 
+  0336, 0020, 0150, 0005, 0175, 0206, 0233, 0241, 0072, 0206, 0070, 0302, 0106, 0300, 0101, 0040, 
+  0267, 0341, 0137, 0034, 0120, 0133, 0121, 0327, 0063, 0050, 0235, 0221, 0045, 0077, 0215, 0322, 
+  0366, 0156, 0112, 0256, 0156, 0154, 0071, 0114, 0334, 0362, 0334, 0070, 0014, 0346, 0337, 0042, 
+  0077, 0360, 0321, 0131, 0336, 0347, 0342, 0200, 0072, 0143, 0220, 0003, 0262, 0172, 0136, 0006, 
+  0244, 0233, 0235, 0007, 0355, 0343, 0065, 0163, 0155, 0300, 0176, 0127, 0071, 0330, 0227, 0241, 
+  0376, 0202, 0101, 0157, 0225, 0016, 0372, 0045, 0026, 0176, 0076, 0122, 0146, 0313, 0255, 0134, 
+  0306, 0262, 0057, 0243, 0050, 0164, 0274, 0126, 0273, 0306, 0061, 0133, 0355, 0242, 0276, 0261, 
+  0052, 0124, 0145, 0136, 0100, 0211, 0120, 0072, 0007, 0167, 0332, 0065, 0112, 0353, 0264, 0033, 
+  0226, 0327, 0150, 0127, 0106, 0143, 0134, 0073, 0317, 0327, 0363, 0256, 0166, 0156, 0227, 0252, 
+  0361, 0265, 0225, 0273, 0102, 0045, 0274, 0002, 0273, 0245, 0171, 0314, 0020, 0062, 0254, 0106, 
+  0004, 0171, 0244, 0014, 0214, 0370, 0137, 0070, 0207, 0006, 0221, 0346, 0261, 0202, 0310, 0231, 
+  0235, 0074, 0364, 0061, 0160, 0204, 0312, 0046, 0062, 0141, 0207, 0253, 0313, 0112, 0237, 0100, 
+  0064, 0076, 0261, 0153, 0054, 0113, 0252, 0170, 0136, 0337, 0276, 0361, 0366, 0117, 0332, 0233, 
+  0037, 0325, 0360, 0311, 0023, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0160, 0162, 0145, 0146, 
+  0145, 0162, 0145, 0156, 0143, 0145, 0163, 0056, 0165, 0151, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0065, 0123, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0134, 0335, 0162, 0342, 0066, 
+  0024, 0276, 0357, 0123, 0250, 0276, 0355, 0050, 0004, 0262, 0155, 0167, 0072, 0301, 0073, 0335, 
+  0335, 0046, 0335, 0231, 0266, 0263, 0323, 0354, 0266, 0227, 0036, 0331, 0076, 0140, 0155, 0204, 
+  0344, 0112, 0002, 0102, 0257, 0372, 0054, 0175, 0264, 0076, 0111, 0217, 0177, 0010, 0140, 0300, 
+  0066, 0004, 0210, 0041, 0334, 0331, 0346, 0110, 0072, 0072, 0377, 0237, 0216, 0206, 0353, 0067, 
+  0017, 0003, 0101, 0106, 0240, 0015, 0127, 0262, 0353, 0264, 0057, 0056, 0035, 0002, 0062, 0120, 
+  0041, 0227, 0375, 0256, 0363, 0371, 0323, 0015, 0175, 0355, 0274, 0161, 0277, 0272, 0376, 0232, 
+  0122, 0162, 0013, 0022, 0064, 0263, 0020, 0222, 0061, 0267, 0021, 0351, 0013, 0026, 0002, 0271, 
+  0272, 0270, 0172, 0175, 0321, 0041, 0224, 0042, 0021, 0227, 0026, 0164, 0217, 0005, 0340, 0136, 
+  0153, 0370, 0153, 0310, 0065, 0030, 0042, 0270, 0337, 0165, 0372, 0366, 0376, 0033, 0147, 0266, 
+  0312, 0325, 0105, 0347, 0225, 0323, 0162, 0257, 0225, 0377, 0005, 0002, 0113, 0002, 0301, 0214, 
+  0351, 0072, 0267, 0366, 0376, 0303, 0200, 0365, 0301, 0041, 0074, 0354, 0072, 0074, 0171, 0154, 
+  0073, 0356, 0165, 0254, 0125, 0014, 0332, 0116, 0210, 0144, 0003, 0350, 0072, 0043, 0156, 0270, 
+  0057, 0300, 0161, 0077, 0351, 0041, 0134, 0267, 0246, 0277, 0056, 0321, 0005, 0114, 0322, 0236, 
+  0012, 0206, 0306, 0161, 0157, 0230, 0060, 0145, 0244, 0074, 0120, 0222, 0046, 0217, 0216, 0073, 
+  0346, 0062, 0124, 0143, 0032, 0010, 0265, 0070, 0242, 0225, 0261, 0132, 0203, 0345, 0316, 0241, 
+  0131, 0216, 0100, 0304, 0324, 0327, 0152, 0154, 0100, 0327, 0143, 0371, 0075, 0147, 0102, 0365, 
+  0063, 0236, 0143, 0015, 0075, 0320, 0250, 0161, 0060, 0136, 0230, 0175, 0177, 0012, 0137, 0276, 
+  0322, 0041, 0150, 0072, 0346, 0241, 0215, 0034, 0367, 0333, 0022, 0112, 0313, 0055, 0212, 0204, 
+  0130, 0315, 0244, 0021, 0314, 0062, 0024, 0120, 0327, 0231, 0000, 0256, 0161, 0067, 0061, 0026, 
+  0006, 0344, 0127, 0045, 0271, 0125, 0232, 0174, 0234, 0161, 0130, 0062, 0135, 0010, 0075, 0066, 
+  0024, 0166, 0272, 0362, 0253, 0313, 0313, 0032, 0304, 0021, 0360, 0176, 0144, 0221, 0272, 0123, 
+  0116, 0155, 0254, 0126, 0023, 0232, 0030, 0075, 0215, 0031, 0262, 0142, 0053, 0125, 0151, 0047, 
+  0061, 0320, 0210, 0047, 0224, 0231, 0124, 0347, 0151, 0203, 0210, 0213, 0220, 0244, 0316, 0042, 
+  0231, 0240, 0351, 0053, 0132, 0211, 0257, 0036, 0234, 0025, 0332, 0172, 0213, 0237, 0123, 0125, 
+  0145, 0023, 0171, 0202, 0115, 0324, 0320, 0076, 0111, 0113, 0003, 0246, 0373, 0134, 0122, 0253, 
+  0342, 0162, 0035, 0345, 0164, 0276, 0262, 0126, 0015, 0312, 0111, 0225, 0346, 0050, 0027, 0146, 
+  0321, 0277, 0035, 0027, 0035, 0335, 0362, 0200, 0211, 0022, 0172, 0023, 0263, 0000, 0103, 0214, 
+  0343, 0166, 0252, 0045, 0303, 0202, 0144, 0132, 0017, 0045, 0317, 0126, 0012, 0150, 0210, 0354, 
+  0311, 0242, 0230, 0026, 0007, 0155, 0040, 0253, 0164, 0321, 0265, 0313, 0144, 0153, 0044, 0076, 
+  0347, 0371, 0331, 0207, 0245, 0311, 0005, 0363, 0101, 0070, 0356, 0317, 0110, 0123, 0042, 0200, 
+  0241, 0001, 0232, 0361, 0110, 0131, 0034, 0003, 0103, 0077, 0010, 0240, 0132, 0165, 0133, 0304, 
+  0222, 0012, 0112, 0015, 0001, 0360, 0021, 0030, 0232, 0173, 0105, 0345, 0200, 0064, 0314, 0071, 
+  0156, 0026, 0355, 0126, 0106, 0034, 0324, 0355, 0075, 0052, 0167, 0151, 0044, 0074, 0304, 0114, 
+  0206, 0325, 0233, 0354, 0161, 0041, 0052, 0331, 0210, 0225, 0341, 0231, 0271, 0055, 0070, 0157, 
+  0353, 0161, 0361, 0126, 0256, 0311, 0072, 0012, 0115, 0003, 0176, 0225, 0106, 0337, 0025, 0263, 
+  0302, 0111, 0252, 0264, 0335, 0004, 0225, 0266, 0313, 0125, 0172, 0140, 0266, 0160, 0021, 0232, 
+  0104, 0164, 0307, 0005, 0031, 0356, 0320, 0044, 0223, 0242, 0112, 0322, 0100, 0211, 0341, 0100, 
+  0232, 0156, 0033, 0237, 0223, 0064, 0216, 0017, 0130, 0115, 0055, 0333, 0353, 0255, 0346, 0141, 
+  0156, 0255, 0012, 0043, 0244, 0264, 0136, 0077, 0371, 0162, 0210, 0162, 0143, 0323, 0350, 0236, 
+  0155, 0211, 0226, 0004, 0371, 0025, 0373, 0373, 0115, 0131, 0360, 0225, 0272, 0317, 0366, 0050, 
+  0247, 0157, 0007, 0360, 0227, 0150, 0152, 0056, 0025, 0164, 0243, 0232, 0164, 0045, 0125, 0120, 
+  0271, 0346, 0073, 0125, 0232, 0307, 0211, 0260, 0016, 0062, 0130, 0254, 0141, 0305, 0344, 0345, 
+  0166, 0160, 0020, 0023, 0330, 0257, 0214, 0332, 0235, 0035, 0132, 0037, 0212, 0162, 0146, 0172, 
+  0355, 0327, 0173, 0021, 0277, 0017, 0021, 0033, 0161, 0245, 0017, 0042, 0373, 0205, 0015, 0175, 
+  0127, 0307, 0227, 0176, 0111, 0063, 0326, 0032, 0236, 0275, 0074, 0237, 0035, 0302, 0152, 0230, 
+  0340, 0175, 0324, 0232, 0261, 0114, 0333, 0022, 0272, 0214, 0243, 0125, 0150, 0340, 0155, 0316, 
+  0164, 0131, 0055, 0211, 0162, 0021, 0100, 0005, 0227, 0100, 0007, 0052, 0134, 0261, 0001, 0146, 
+  0255, 0346, 0230, 0335, 0301, 0314, 0075, 0347, 0243, 0307, 0031, 0010, 0040, 0043, 0046, 0206, 
+  0251, 0135, 0212, 0060, 0301, 0246, 0255, 0371, 0061, 0225, 0371, 0106, 0100, 0317, 0122, 0034, 
+  0301, 0202, 0250, 0020, 0374, 0213, 0300, 0100, 0305, 0253, 0351, 0066, 0115, 0022, 0257, 0066, 
+  0267, 0125, 0317, 0100, 0220, 0071, 0321, 0001, 0064, 0237, 0143, 0207, 0124, 0361, 0025, 0376, 
+  0135, 0151, 0336, 0213, 0042, 0350, 0324, 0316, 0223, 0303, 0070, 0144, 0026, 0274, 0024, 0117, 
+  0240, 0172, 0017, 0227, 0057, 0353, 0006, 0313, 0142, 0236, 0154, 0167, 0266, 0166, 0356, 0307, 
+  0115, 0036, 0316, 0271, 0327, 0073, 0255, 0367, 0071, 0225, 0074, 0231, 0062, 0205, 0017, 0004, 
+  0215, 0117, 0311, 0320, 0374, 0120, 0121, 0100, 0017, 0045, 0246, 0205, 0304, 0225, 0053, 0071, 
+  0035, 0110, 0030, 0050, 0311, 0203, 0044, 0207, 0364, 0001, 0215, 0154, 0205, 0060, 0114, 0314, 
+  0245, 0134, 0163, 0056, 0362, 0014, 0276, 0274, 0244, 0312, 0073, 0344, 0157, 0036, 0207, 0254, 
+  0337, 0302, 0041, 0352, 0040, 0056, 0363, 0071, 0021, 0171, 0063, 0134, 0361, 0277, 0177, 0376, 
+  0055, 0233, 0127, 0360, 0201, 0117, 0223, 0003, 0301, 0102, 0275, 0136, 0074, 0077, 0341, 0175, 
+  0156, 0115, 0241, 0010, 0334, 0114, 0013, 0355, 0335, 0150, 0241, 0121, 0252, 0177, 0027, 0101, 
+  0260, 0200, 0101, 0315, 0100, 0051, 0033, 0125, 0200, 0320, 0125, 0336, 0366, 0223, 0114, 0136, 
+  0210, 0227, 0115, 0100, 0064, 0364, 0064, 0230, 0350, 0070, 0201, 0152, 0025, 0017, 0233, 0205, 
+  0210, 0120, 0263, 0061, 0345, 0062, 0304, 0202, 0321, 0046, 0265, 0132, 0221, 0174, 0077, 0006, 
+  0321, 0336, 0221, 0101, 0004, 0311, 0207, 0055, 0354, 0341, 0107, 0201, 0144, 0304, 0207, 0236, 
+  0322, 0100, 0020, 0261, 0342, 0352, 0104, 0151, 0342, 0335, 0043, 0330, 0115, 0236, 0037, 0203, 
+  0314, 0331, 0104, 0236, 0313, 0104, 0072, 0273, 0212, 0031, 0112, 0060, 0315, 0315, 0026, 0106, 
+  0342, 0275, 0347, 0043, 0036, 0002, 0171, 0367, 0361, 0063, 0031, 0032, 0326, 0007, 0342, 0117, 
+  0322, 0227, 0100, 0015, 0245, 0075, 0133, 0306, 0163, 0131, 0306, 0325, 0163, 0244, 0260, 0166, 
+  0163, 0363, 0346, 0323, 0241, 0172, 0217, 0203, 0010, 0315, 0121, 0036, 0222, 0354, 0010, 0370, 
+  0147, 0022, 0150, 0004, 0062, 0370, 0040, 0061, 0053, 0015, 0322, 0263, 0034, 0162, 0223, 0262, 
+  0125, 0062, 0315, 0227, 0241, 0261, 0274, 0067, 0161, 0334, 0344, 0230, 0266, 0204, 0016, 0060, 
+  0257, 0305, 0206, 0377, 0135, 0171, 0100, 0133, 0175, 0122, 0120, 0030, 0360, 0220, 0237, 0137, 
+  0134, 0236, 0370, 0151, 0302, 0306, 0356, 0324, 0074, 0054, 0135, 0327, 0247, 0052, 0117, 0023, 
+  0267, 0161, 0255, 0324, 0304, 0033, 0341, 0140, 0037, 0063, 0326, 0010, 0367, 0346, 0074, 0315, 
+  0104, 0152, 0054, 0023, 0020, 0056, 0270, 0261, 0173, 0106, 0340, 0126, 0003, 0170, 0271, 0201, 
+  0155, 0352, 0131, 0315, 0302, 0346, 0201, 0126, 0102, 0100, 0370, 0147, 0172, 0047, 0244, 0250, 
+  0170, 0223, 0377, 0172, 0214, 0375, 0011, 0023, 0261, 0344, 0226, 0113, 0326, 0322, 0342, 0262, 
+  0216, 0361, 0177, 0102, 0255, 0376, 0301, 0141, 0116, 0014, 0363, 0172, 0076, 0214, 0020, 0030, 
+  0332, 0245, 0241, 0217, 0063, 0127, 0371, 0010, 0244, 0260, 0230, 0032, 0054, 0121, 0023, 0053, 
+  0130, 0335, 0350, 0137, 0272, 0154, 0140, 0100, 0074, 0236, 0222, 0256, 0224, 0302, 0335, 0043, 
+  0301, 0242, 0105, 0114, 0203, 0052, 0235, 0315, 0320, 0132, 0121, 0102, 0235, 0140, 0041, 0327, 
+  0350, 0105, 0027, 0274, 0234, 0044, 0046, 0217, 0363, 0060, 0337, 0251, 0033, 0340, 0223, 0076, 
+  0133, 0203, 0342, 0372, 0042, 0150, 0257, 0024, 0055, 0316, 0100, 0263, 0036, 0367, 0322, 0312, 
+  0073, 0357, 0112, 0153, 0060, 0152, 0250, 0203, 0163, 0157, 0362, 0171, 0172, 0223, 0063, 0361, 
+  0367, 0065, 0213, 0243, 0146, 0001, 0236, 0047, 0001, 0231, 0342, 0316, 0016, 0331, 0277, 0254, 
+  0271, 0277, 0365, 0176, 0173, 0233, 0262, 0174, 0006, 0071, 0307, 0000, 0162, 0226, 0014, 0255, 
+  0241, 0015, 0323, 0203, 0037, 0063, 0154, 0333, 0200, 0235, 0011, 0264, 0320, 0212, 0075, 0255, 
+  0056, 0354, 0154, 0233, 0347, 0056, 0254, 0273, 0102, 0030, 0307, 0326, 0205, 0135, 0277, 0205, 
+  0163, 0027, 0366, 0324, 0273, 0260, 0076, 0112, 0151, 0233, 0166, 0312, 0135, 0244, 0306, 0104, 
+  0202, 0035, 0053, 0175, 0117, 0114, 0014, 0220, 0100, 0113, 0222, 0314, 0166, 0232, 0275, 0224, 
+  0272, 0301, 0365, 0004, 0032, 0266, 0057, 0247, 0347, 0122, 0271, 0150, 0355, 0033, 0332, 0233, 
+  0301, 0355, 0105, 0350, 0330, 0204, 0334, 0371, 0373, 0224, 0243, 0215, 0254, 0157, 0215, 0170, 
+  0366, 0007, 0312, 0053, 0113, 0332, 0020, 0106, 0374, 0014, 0311, 0237, 0011, 0222, 0117, 0205, 
+  0177, 0074, 0227, 0205, 0213, 0034, 0037, 0025, 0324, 0256, 0161, 0125, 0370, 0014, 0266, 0033, 
+  0003, 0266, 0227, 0114, 0355, 0310, 0301, 0366, 0336, 0100, 0364, 0124, 0120, 0047, 0174, 0215, 
+  0171, 0151, 0213, 0057, 0027, 0076, 0057, 0211, 0342, 0330, 0300, 0363, 0272, 0015, 0234, 0241, 
+  0363, 0251, 0103, 0147, 0046, 0204, 0067, 0325, 0176, 0172, 0167, 0165, 0023, 0000, 0235, 0342, 
+  0147, 0017, 0247, 0040, 0230, 0232, 0201, 0230, 0364, 0117, 0000, 0316, 0330, 0371, 0214, 0235, 
+  0137, 0310, 0175, 0305, 0251, 0343, 0274, 0324, 0333, 0212, 0213, 0373, 0077, 0052, 0334, 0161, 
+  0276, 0323, 0170, 0012, 0056, 0167, 0302, 0067, 0032, 0367, 0350, 0247, 0315, 0271, 0370, 0170, 
+  0063, 0053, 0033, 0236, 0347, 0362, 0143, 0310, 0315, 0175, 0162, 0051, 0116, 0302, 0370, 0144, 
+  0357, 0077, 0116, 0265, 0377, 0242, 0157, 0077, 0256, 0120, 0364, 0013, 0276, 0000, 0231, 0233, 
+  0004, 0115, 0044, 0062, 0102, 0031, 0235, 0357, 0077, 0036, 0305, 0242, 0263, 0126, 0105, 0147, 
+  0227, 0235, 0234, 0004, 0274, 0171, 0071, 0170, 0153, 0114, 0063, 0047, 0115, 0015, 0167, 0313, 
+  0210, 0162, 0133, 0041, 0075, 0245, 0237, 0323, 0314, 0276, 0136, 0315, 0320, 0271, 0247, 0177, 
+  0161, 0232, 0176, 0310, 0341, 0174, 0226, 0120, 0115, 0341, 0235, 0150, 0060, 0261, 0222, 0006, 
+  0127, 0240, 0355, 0166, 0366, 0277, 0207, 0171, 0243, 0036, 0113, 0321, 0171, 0312, 0222, 0201, 
+  0337, 0073, 0356, 0374, 0137, 0175, 0055, 0015, 0154, 0025, 0131, 0230, 0361, 0070, 0373, 0163, 
+  0313, 0257, 0376, 0007, 0112, 0344, 0157, 0105, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0155, 
+  0141, 0164, 0145, 0057, 0000, 0000, 0000, 0000
+} };
+
+static GStaticResource static_resource = { msm_resource_data.data, sizeof (msm_resource_data.data) - 1 /* nul terminator */, NULL, NULL, NULL };
+
+G_MODULE_EXPORT
+GResource *msm_get_resource (void);
+GResource *msm_get_resource (void)
+{
+  return g_static_resource_get_resource (&static_resource);
+}
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GLib Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __G_CONSTRUCTOR_H__
+#define __G_CONSTRUCTOR_H__
+
+/*
+  If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and
+  destructors, in a usable way, including e.g. on library unload. If not you're on
+  your own.
+
+  Some compilers need #pragma to handle this, which does not work with macros,
+  so the way you need to use this is (for constructors):
+
+  #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+  #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(my_constructor)
+  #endif
+  G_DEFINE_CONSTRUCTOR(my_constructor)
+  static void my_constructor(void) {
+   ...
+  }
+
+*/
+
+#ifndef __GTK_DOC_IGNORE__
+
+#if  __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func (void);
+#define G_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func (void);
+
+#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
+/* Visual studio 2008 and later has _Pragma */
+
+/*
+ * Only try to include gslist.h if not already included via glib.h,
+ * so that items using gconstructor.h outside of GLib (such as
+ * GResources) continue to build properly.
+ */
+#ifndef __G_LIB_H__
+#include "gslist.h"
+#endif
+
+#include <stdlib.h>
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* We do some weird things to avoid the constructors being optimized
+ * away on VS2015 if WholeProgramOptimization is enabled. First we
+ * make a reference to the array from the wrapper to make sure its
+ * references. Then we use a pragma to make sure the wrapper function
+ * symbol is always included at the link stage. Also, the symbols
+ * need to be extern (but not dllexport), even though they are not
+ * really used from another object file.
+ */
+
+/* We need to account for differences between the mangling of symbols
+ * for x86 and x64/ARM/ARM64 programs, as symbols on x86 are prefixed
+ * with an underscore but symbols on x64/ARM/ARM64 are not.
+ */
+#ifdef _M_IX86
+#define G_MSVC_SYMBOL_PREFIX "_"
+#else
+#define G_MSVC_SYMBOL_PREFIX ""
+#endif
+
+#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
+#define G_DEFINE_DESTRUCTOR(_func) G_MSVC_DTOR (_func, G_MSVC_SYMBOL_PREFIX)
+
+#define G_MSVC_CTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _wrapper(void) { _func(); g_slist_find (NULL,  _array ## _func); return 0; } \
+  __pragma(comment(linker,"/include:" _sym_prefix # _func "_wrapper")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _wrapper;
+
+#define G_MSVC_DTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _constructor(void) { atexit (_func); g_slist_find (NULL,  _array ## _func); return 0; } \
+   __pragma(comment(linker,"/include:" _sym_prefix # _func "_constructor")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined (_MSC_VER)
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* Pre Visual studio 2008 must use #pragma section */
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _wrapper(void) { _func(); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func ## _wrapper;
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _constructor(void) { atexit (_func); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined(__SUNPRO_C)
+
+/* This is not tested, but i believe it should work, based on:
+ * http://opensource.apple.com/source/OpenSSL098/OpenSSL098-35/src/fips/fips_premain.c
+ */
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  init(_func)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void);
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  fini(_func)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void);
+
+#else
+
+/* constructors not supported for this compiler */
+
+#endif
+
+#endif /* __GTK_DOC_IGNORE__ */
+#endif /* __G_CONSTRUCTOR_H__ */
+
+#ifdef G_HAS_CONSTRUCTORS
+
+#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(msmresource_constructor)
+#endif
+G_DEFINE_CONSTRUCTOR(msmresource_constructor)
+#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(msmresource_destructor)
+#endif
+G_DEFINE_DESTRUCTOR(msmresource_destructor)
+
+#else
+#warning "Constructor not supported on this compiler, linking in resources will not work"
+#endif
+
+static void msmresource_constructor (void)
+{
+  g_static_resource_init (&static_resource);
+}
+
+static void msmresource_destructor (void)
+{
+  g_static_resource_fini (&static_resource);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/28.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/28.html new file mode 100644 index 00000000..88cc9fc6 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/28.html @@ -0,0 +1,1039 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procopenfiles.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <netdb.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/socket.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <netinet/in.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <arpa/inet.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "openfiles.h"
+#include "proctable.h"
+#include "util.h"
+#include "settings-keys.h"
+
+#ifndef NI_IDN
+#define NI_IDN 0
+#endif
+
+enum
+{
+    COL_FD,
+    COL_TYPE,
+    COL_OBJECT,
+    COL_OPENFILE_STRUCT,
+    NUM_OPENFILES_COL
+};
+
+
+static const char*
+get_type_name(enum glibtop_file_type t)
+{
+    switch(t)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        return _("file");
+    case GLIBTOP_FILE_TYPE_PIPE:
+        return _("pipe");
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+        return _("IPv6 network connection");
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        return _("IPv4 network connection");
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        return _("local socket");
+    default:
+        return _("unknown type");
+    }
+}
+
+
+
+static char *
+friendlier_hostname(const char *addr_str, int port)
+{
+    struct addrinfo hints = { };
+    struct addrinfo *res = NULL;
+    char hostname[NI_MAXHOST];
+    char service[NI_MAXSERV];
+    char port_str[6];
+
+    if (!addr_str[0]) return g_strdup("");
+
+    snprintf(port_str, sizeof port_str, "%d", port);
+
+    hints.ai_family = AF_UNSPEC;
+    hints.ai_socktype = SOCK_STREAM;
+
+    if (getaddrinfo(addr_str, port_str, &hints, &res))
+        goto failsafe;
+
+    if (getnameinfo(res->ai_addr, res->ai_addrlen, hostname,<--- Null pointer dereference
+            sizeof hostname, service, sizeof service, NI_IDN))
+        goto failsafe;
+
+    if (res) freeaddrinfo(res);<--- Assuming that condition 'res' is not redundant
+        return g_strdup_printf("%s, TCP port %d (%s)", hostname, port, service);
+
+  failsafe:
+    if (res) freeaddrinfo(res);
+    return g_strdup_printf("%s, TCP port %d", addr_str, port);
+}
+
+
+
+static void
+add_new_files (gpointer key, gpointer value, gpointer data)
+{
+    glibtop_open_files_entry *openfiles = static_cast<glibtop_open_files_entry*>(value);
+
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreeIter row;
+
+    char *object;
+
+    switch(openfiles->type)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        object = g_strdup(openfiles->info.file.name);
+        break;
+
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        object = friendlier_hostname(openfiles->info.sock.dest_host,
+                         openfiles->info.sock.dest_port);
+        break;
+
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        object = g_strdup(openfiles->info.localsock.name);
+        break;
+
+    default:
+        object = g_strdup("");
+    }
+
+    gtk_list_store_insert (GTK_LIST_STORE (model), &row, 0);
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        COL_FD, openfiles->fd,
+                        COL_TYPE, get_type_name(static_cast<glibtop_file_type>(openfiles->type)),
+                        COL_OBJECT, object,
+#if GLIB_CHECK_VERSION (2, 68, 0)
+                        COL_OPENFILE_STRUCT, g_memdup2(openfiles, sizeof(*openfiles)),
+#else
+                        COL_OPENFILE_STRUCT, g_memdup(openfiles, sizeof(*openfiles)),
+#endif
+                        -1);
+
+    g_free(object);
+}
+
+static GList *old_maps = NULL;
+
+static gboolean
+classify_openfiles (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+    GHashTable *new_maps = static_cast<GHashTable*>(data);
+    GtkTreeIter *old_iter;
+    glibtop_open_files_entry *openfiles;
+    gchar *old_name;
+
+    gtk_tree_model_get (model, iter, 1, &old_name, -1);
+
+    openfiles = static_cast<glibtop_open_files_entry*>(g_hash_table_lookup (new_maps, old_name));
+    if (openfiles) {
+        g_hash_table_remove (new_maps, old_name);
+        g_free (old_name);
+        return FALSE;
+
+    }
+
+    old_iter = gtk_tree_iter_copy (iter);
+    old_maps = g_list_append (old_maps, old_iter);
+    g_free (old_name);
+    return FALSE;
+
+}
+
+
+static gboolean
+compare_open_files(gconstpointer a, gconstpointer b)
+{
+    const glibtop_open_files_entry *o1 = static_cast<const glibtop_open_files_entry *>(a);
+    const glibtop_open_files_entry *o2 = static_cast<const glibtop_open_files_entry *>(b);
+
+    /* Falta manejar los diferentes tipos! */
+    return (o1->fd == o2->fd) && (o1->type == o2->type); /* XXX! */
+}
+
+
+static void
+update_openfiles_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+    GtkTreeModel *model;
+    glibtop_open_files_entry *openfiles;<--- Shadowed declaration
+    glibtop_proc_open_files procmap;
+    GHashTable *new_maps;
+    guint i;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    if (!info)
+        return;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    openfiles = glibtop_get_proc_open_files (&procmap, info->pid);
+
+    if (!openfiles)
+        return;
+
+    new_maps = static_cast<GHashTable *>(g_hash_table_new_full (g_str_hash, compare_open_files,
+                                                                NULL, NULL));
+    for (i=0; i < procmap.number; i++)
+        g_hash_table_insert (new_maps, openfiles + i, openfiles + i);
+
+    gtk_tree_model_foreach (model, classify_openfiles, new_maps);
+
+    g_hash_table_foreach (new_maps, add_new_files, model);
+
+    while (old_maps) {
+        GtkTreeIter *iter = static_cast<GtkTreeIter*>(old_maps->data);
+        glibtop_open_files_entry *openfiles = NULL;<--- Shadow variable
+
+        gtk_tree_model_get (model, iter,
+                            COL_OPENFILE_STRUCT, &openfiles,
+                            -1);
+
+        gtk_list_store_remove (GTK_LIST_STORE (model), iter);
+        gtk_tree_iter_free (iter);
+        g_free (openfiles);
+
+        old_maps = g_list_next (old_maps);
+
+    }
+
+    g_hash_table_destroy (new_maps);
+    g_free (openfiles);
+}
+
+static void
+close_openfiles_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GSettings *settings;
+    guint timer;
+
+    settings = static_cast<GSettings*>(g_object_get_data (G_OBJECT (tree), "settings"));
+    procman_save_tree_state (settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    return ;
+}
+
+
+static GtkWidget *
+create_openfiles_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    const gchar * const titles[] = {
+        /* Translators: "FD" here means "File Descriptor". Please use
+           a very short translation if possible, and at most
+           2-3 characters for it to be able to fit in the UI. */
+        N_("FD"),
+        N_("Type"),
+        N_("Object")
+    };
+
+    model = gtk_list_store_new (NUM_OPENFILES_COL,
+                                G_TYPE_INT,        /* FD */
+                                G_TYPE_STRING,    /* Type */
+                                G_TYPE_STRING,    /* Object */
+                                G_TYPE_POINTER    /* open_files_entry */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_OPENFILES_COL-1; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        switch (i) {
+        case COL_FD:
+            g_object_set(cell, "xalign", 1.0f, NULL);
+            break;
+        }
+
+        column = gtk_tree_view_column_new_with_attributes (_(titles[i]),
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_sort_column_id (column, i);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    procman_get_tree_state (procdata->settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    return tree;
+}
+
+
+static gboolean
+openfiles_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_openfiles_dialog (tree);
+
+    return TRUE;
+}
+
+
+static void
+create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *openfilesdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    openfilesdialog = gtk_dialog_new_with_buttons (_("Open Files"), NULL,
+                                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                   "gtk-close", GTK_RESPONSE_CLOSE,
+                                                   NULL);
+    gtk_window_set_resizable (GTK_WINDOW (openfilesdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (openfilesdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (openfilesdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (openfilesdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Files opened by process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                    GTK_POLICY_AUTOMATIC,
+                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_openfiles_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+    g_object_set_data (G_OBJECT (tree), "settings", procdata->settings);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (openfilesdialog), "response",
+                      G_CALLBACK (close_openfiles_dialog), tree);
+
+    gtk_widget_show_all (openfilesdialog);
+
+    timer = g_timeout_add_seconds (5, openfiles_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_openfiles_dialog (tree);
+
+}
+
+
+void
+create_openfiles_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_openfiles_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/29.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/29.html new file mode 100644 index 00000000..a5901ac6 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/29.html @@ -0,0 +1,271 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
#ifndef H_PROCMAN_SETTINGS_KEYS_1177430397
+#define H_PROCMAN_SETTINGS_KEYS_1177430397
+
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+namespace procman
+{
+    namespace settings
+    {
+        extern const std::string root;
+        extern const std::string solaris_mode;
+        extern const std::string open_files_tree_prefix;
+        extern const std::string network_in_bits;
+    }
+}
+
+#endif //  H_PROCMAN_SETTINGS_KEYS_1177430397
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/3.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/3.html new file mode 100644 index 00000000..1d042194 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/3.html @@ -0,0 +1,395 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
/* Procman - callbacks
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef _PROCMAN_CALLBACKS_H_
+#define _PROCMAN_CALLBACKS_H_
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+#include "gsm_color_button.h"
+
+void            cb_show_memory_maps (GtkAction *action, gpointer data);
+void            cb_show_open_files (GtkAction *action, gpointer data);
+void            cb_show_process_properties (GtkAction *action, gpointer data);
+void            cb_show_lsof(GtkAction *action, gpointer data);
+void            cb_renice (GtkAction *action, GtkRadioAction *current, gpointer data);
+void            cb_end_process (GtkAction *action, gpointer data);
+void            cb_kill_process (GtkAction *action, gpointer data);
+void            cb_edit_preferences (GtkAction *action, gpointer data);
+
+void            cb_help_contents (GtkAction *action, gpointer data);
+void            cb_about (GtkAction *action, gpointer data);
+
+void            cb_app_exit (GtkAction *action, gpointer data);
+gboolean        cb_app_delete (GtkWidget *window, GdkEventAny *event, gpointer data);
+
+void            cb_end_process_button_pressed (GtkButton *button, gpointer data);
+void            cb_logout (GtkButton *button, gpointer data);
+
+void            cb_info_button_pressed (GtkButton *button, gpointer user_data);
+
+void            cb_cpu_color_changed (GSMColorButton *widget, gpointer user_data);
+void            cb_mem_color_changed (GSMColorButton *widget, gpointer user_data);
+void            cb_swap_color_changed (GSMColorButton *widget, gpointer user_data);
+void            cb_net_in_color_changed (GSMColorButton *widget, gpointer user_data);
+void            cb_net_out_color_changed (GSMColorButton *widget, gpointer user_data);
+
+void            cb_row_selected (GtkTreeSelection *selection, gpointer data);
+
+gboolean        cb_tree_popup_menu (GtkWidget *widget, gpointer data);
+gboolean        cb_tree_button_pressed (GtkWidget *widget, GdkEventButton *event,
+                                        gpointer data);
+
+void            cb_change_current_page (GtkNotebook *nb,
+                                        gint num, gpointer data);
+void            cb_switch_page (GtkNotebook *nb, GtkWidget *page,
+                                gint num, gpointer data);
+
+gint            cb_update_disks (gpointer data);
+gint            cb_user_refresh (GtkAction* action, gpointer data);
+gint            cb_timeout (gpointer data);
+
+void            cb_radio_processes(GtkAction *action,
+                                   GtkRadioAction *current,
+                                   gpointer data);
+
+void            cb_kill_sigstop(GtkAction *action,
+                                gpointer data);
+
+void            cb_kill_sigcont(GtkAction *action,
+                                gpointer data);
+
+#endif /* _PROCMAN_CALLBACKS_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/30.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/30.html new file mode 100644 index 00000000..7bdd1228 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/30.html @@ -0,0 +1,899 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef HAVE_WNCK
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <dirent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk-pixbuf/gdk-pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procstate.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/error.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/file.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/miscutils.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <iostream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <vector><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "prettytable.h"
+#include "defaulttable.h"
+#include "proctable.h"
+#include "util.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+namespace
+{
+  const unsigned APP_ICON_SIZE = 16;
+}
+
+
+PrettyTable::PrettyTable()
+{
+#ifdef HAVE_WNCK
+#ifdef GDK_WINDOWING_X11
+  if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+      WnckScreen* screen = wnck_screen_get_default();
+      g_signal_connect(G_OBJECT(screen), "application_opened",
+		       G_CALLBACK(PrettyTable::on_application_opened), this);
+      g_signal_connect(G_OBJECT(screen), "application_closed",
+	               G_CALLBACK(PrettyTable::on_application_closed), this);
+  }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    // init GIO apps cache
+    std::vector<std::string> dirs = Glib::get_system_data_dirs();
+    for (std::vector<std::string>::iterator it = dirs.begin(); it != dirs.end(); ++it) {
+        std::string path = (*it).append("/applications");
+        Glib::RefPtr<Gio::File> file = Gio::File::create_for_path(path);
+        Glib::RefPtr<Gio::FileMonitor> monitor = file->monitor_directory();
+        monitor->set_rate_limit(1000); // 1 second
+
+        monitor->signal_changed().connect(sigc::mem_fun(this, &PrettyTable::file_monitor_event));
+        monitors[path] = monitor;
+    }
+
+    this->init_gio_app_cache();
+}
+
+
+PrettyTable::~PrettyTable()
+{
+}
+
+#ifdef HAVE_WNCK
+void
+PrettyTable::on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data)
+{
+    PrettyTable * const that = static_cast<PrettyTable*>(data);
+    FILE *f;
+
+    pid_t pid = wnck_application_get_pid(app);
+
+    if (pid == 0)
+        return;
+
+    const char* icon_name = wnck_application_get_icon_name(app);
+
+
+    Glib::RefPtr<Gdk::Pixbuf> icon;
+
+    // Make sure that icon_name is a valid symlink before loading.
+    f = fopen (icon_name, "r");
+    if (f != NULL) {
+        fclose (f);
+        icon = that->theme->load_icon(icon_name, APP_ICON_SIZE);
+    }
+
+    if (not icon) {
+        icon = Glib::wrap(wnck_application_get_icon(app), /* take_copy */ true);
+        icon = icon->scale_simple(APP_ICON_SIZE, APP_ICON_SIZE, Gdk::INTERP_HYPER);
+    }
+
+    if (not icon)
+        return;
+
+    that->register_application(pid, icon);
+}
+
+void
+PrettyTable::register_application(pid_t pid, Glib::RefPtr<Gdk::Pixbuf> icon)
+{
+  /* If process already exists then set the icon. Otherwise put into hash
+  ** table to be added later */
+  if (ProcInfo* info = ProcInfo::find(pid))
+    {
+      info->set_icon(icon);
+      // move the ref to the map
+      this->apps[pid] = icon;
+      procman_debug("MATEWNCK OK for %u", unsigned(pid));
+    }
+}
+
+void
+PrettyTable::on_application_closed(WnckScreen* screen, WnckApplication* app, gpointer data)
+{
+    pid_t pid = wnck_application_get_pid(app);
+
+    if (pid == 0)
+        return;
+
+    static_cast<PrettyTable*>(data)->unregister_application(pid);
+}
+
+void
+PrettyTable::unregister_application(pid_t pid)
+{
+    IconsForPID::iterator it(this->apps.find(pid));
+
+    if (it != this->apps.end())
+        this->apps.erase(it);
+}
+#endif // HAVE_WNCK
+
+void PrettyTable::init_gio_app_cache ()
+{
+    this->gio_apps.clear();
+
+    Glib::ListHandle<Glib::RefPtr<Gio::AppInfo>> registered_apps = Gio::AppInfo::get_all();
+    for (Glib::ListHandle<Glib::RefPtr<Gio::AppInfo>>::const_iterator it = registered_apps.begin(); it != registered_apps.end(); ++it) {
+        Glib::RefPtr<Gio::AppInfo> app = *it;
+        std::string executable = app->get_executable();
+        if (executable != "sh" && executable != "env")
+            this->gio_apps[executable] = app;
+    }
+}
+
+void PrettyTable::file_monitor_event(Glib::RefPtr<Gio::File>,
+                                     Glib::RefPtr<Gio::File>,
+                                     Gio::FileMonitorEvent)
+{
+  this->init_gio_app_cache();
+}
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_theme(const ProcInfo &info)
+{
+    return this->theme->load_icon(info.name, APP_ICON_SIZE);
+}
+
+
+bool PrettyTable::get_default_icon_name(const string &cmd, string &name)
+{
+    for (size_t i = 0; i != G_N_ELEMENTS(default_table); ++i) {
+        if (default_table[i].command->match(cmd)) {
+            name = default_table[i].icon;
+            return true;
+        }
+    }
+
+    return false;
+}
+
+/*
+  Try to get an icon from the default_table
+  If it's not in defaults, try to load it.
+  If there is no default for a command, store NULL in defaults
+  so we don't have to lookup again.
+*/
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_default(const ProcInfo &info)
+{
+    Glib::RefPtr<Gdk::Pixbuf> pix;
+    string name;
+
+    if (this->get_default_icon_name(info.name, name)) {
+        IconCache::iterator it(this->defaults.find(name));
+
+        if (it == this->defaults.end()) {
+            pix = this->theme->load_icon(name, APP_ICON_SIZE);
+            if (pix)
+                this->defaults[name] = pix;
+            } else
+                pix = it->second;
+    }
+
+    return pix;
+}
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_gio(const ProcInfo &info)
+{
+    gchar **cmdline = g_strsplit(info.name, " ", 2);
+    const gchar *executable = cmdline[0];
+    Glib::RefPtr<Gdk::Pixbuf> icon;
+
+    if (executable) {
+        Glib::RefPtr<Gio::AppInfo> app = this->gio_apps[executable];
+        Glib::RefPtr<Gio::Icon> gicon;
+
+        if (app)
+          gicon = app->get_icon();
+
+        if (gicon)
+          icon = this->theme->load_gicon(gicon, APP_ICON_SIZE, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
+    }
+
+    g_strfreev(cmdline);
+    return icon;
+}
+
+#ifdef HAVE_WNCK
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_wnck(const ProcInfo &info)
+{
+    Glib::RefPtr<Gdk::Pixbuf> icon;
+
+    IconsForPID::iterator it(this->apps.find(info.pid));
+
+    if (it != this->apps.end())
+        icon = it->second;
+
+    return icon;
+}
+#endif
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_name(const ProcInfo &info)
+{
+    return this->theme->load_icon(info.name, APP_ICON_SIZE);
+}
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_dummy(const ProcInfo &)
+{
+    return this->theme->load_icon("application-x-executable", APP_ICON_SIZE);
+}
+
+
+namespace
+{
+    bool has_kthreadd()
+    {
+        glibtop_proc_state buf;
+        glibtop_get_proc_state(&buf, 2);
+
+        return buf.cmd == string("kthreadd");
+    }
+
+    // @pre: has_kthreadd
+    bool is_kthread(const ProcInfo &info)
+    {
+        return info.pid == 2 or info.ppid == 2;
+    }
+}
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_for_kernel(const ProcInfo &info)
+{
+    if (is_kthread(info))
+        return this->theme->load_icon("applications-system", APP_ICON_SIZE);
+
+    return Glib::RefPtr<Gdk::Pixbuf>();
+}
+
+
+
+void
+PrettyTable::set_icon(ProcInfo &info)
+{
+    typedef Glib::RefPtr<Gdk::Pixbuf>
+        (PrettyTable::*Getter)(const ProcInfo &);
+
+    static std::vector<Getter> getters;
+
+    if (getters.empty())
+    {
+        getters.push_back(&PrettyTable::get_icon_from_gio);
+#ifdef HAVE_WNCK
+        getters.push_back(&PrettyTable::get_icon_from_wnck);
+#endif
+        getters.push_back(&PrettyTable::get_icon_from_theme);
+        getters.push_back(&PrettyTable::get_icon_from_default);
+        getters.push_back(&PrettyTable::get_icon_from_name);
+        if (has_kthreadd())
+        {
+            procman_debug("kthreadd is running with PID 2");
+            getters.push_back(&PrettyTable::get_icon_for_kernel);
+        }
+        getters.push_back(&PrettyTable::get_icon_dummy);
+    }
+
+    Glib::RefPtr<Gdk::Pixbuf> icon;
+
+    for (size_t i = 0; not icon and i < getters.size(); ++i) {
+        try {
+            icon = (this->*getters[i])(info);
+        }
+        catch (std::exception& e) {
+            g_warning("Failed to load icon for %s(%u) : %s", info.name, info.pid, e.what());
+            continue;
+        }
+        catch (Glib::Exception& e) {
+            g_warning("Failed to load icon for %s(%u) : %s", info.name, info.pid, e.what().c_str());
+            continue;
+        }
+    }
+
+    info.set_icon(icon);
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/31.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/31.html new file mode 100644 index 00000000..d8618dcb --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/31.html @@ -0,0 +1,331 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
#ifndef _PROCMAN_DEFAULTTABLE_H_
+#define _PROCMAN_DEFAULTTABLE_H_
+
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/refptr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/regex.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+/* This file contains prettynames and icons for well-known applications, that by default has no .desktop entry */
+
+struct PrettyTableItem
+{
+    Glib::RefPtr<Glib::Regex> command;
+    std::string icon;
+
+PrettyTableItem(const std::string& a_command, const std::string& a_icon)
+: command(Glib::Regex::create("^(" + a_command + ")$")),
+        icon(a_icon)
+    { }
+};
+
+#define ITEM PrettyTableItem
+
+static const PrettyTableItem default_table[] = {
+    ITEM("(ba|z|tc|c|k)?sh", "utilities-terminal"),
+    ITEM("(k|sys|u)logd|logger", "internet-news-reader"),
+    ITEM("X(org)?", "display"),
+    ITEM("apache2?|httpd|lighttpd", "internet-web-browser"),
+    ITEM("atd|cron|CRON|ntpd", "date"),
+    ITEM("cupsd|lpd?", "printer"),
+    ITEM("cvsd|mtn|git|svn", "file-manager"),
+    ITEM("evolution.*", "internet-mail"),
+    ITEM("famd|gam_server", "file-manager"),
+    ITEM("getty", "input-keyboard"),
+    ITEM("gdb|((gcc|g\\+\\+)(-.*)?)|ar|ld|make", "applications-development"),
+    ITEM("marco|metacity", "gnome-window-manager"),
+    ITEM("sendmail|exim\\d?", "internet-mail"),
+    ITEM("squid", "proxy"),
+    ITEM("ssh(d|-agent)", "ssh-askpass-gnome"),
+    ITEM("top|vmstat", "system-monitor"),
+    ITEM("vim?", "vim"),
+    ITEM("x?inetd", "internet-web-browser"),
+    ITEM("vino.*", "gnome-remote-desktop")
+};
+
+#undef ITEM
+
+#endif /* _PROCMAN_DEFAULTTABLE_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/32.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/32.html new file mode 100644 index 00000000..d34b6a5f --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/32.html @@ -0,0 +1,621 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
/* Procman process actions
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/resource.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procactions.h"
+#include "procman.h"
+#include "proctable.h"
+#include "procdialogs.h"
+#include "callbacks.h"
+
+
+static void
+renice_single_process (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+    const struct ReniceArgs * const args = static_cast<ReniceArgs*>(data);
+
+    ProcInfo *info = NULL;
+    gint error;
+    int saved_errno;
+    gchar *error_msg;
+    GtkWidget *dialog;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+    if (info->nice == args->nice_value)
+        return;
+    error = setpriority (PRIO_PROCESS, info->pid, args->nice_value);
+
+    /* success */
+    if(error != -1) return;
+
+    saved_errno = errno;
+
+    /* need to be root */
+    if(errno == EPERM || errno == EACCES) {
+        gboolean success;
+
+        success = procdialog_create_root_password_dialog (
+            PROCMAN_ACTION_RENICE, args->procdata, info->pid,
+            args->nice_value);
+
+        if(success) return;
+
+        if(errno) {
+            saved_errno = errno;
+        }
+    }
+
+    /* failed */
+    error_msg = g_strdup_printf (
+        _("Cannot change the priority of process with PID %d to %d.\n"
+          "%s"),
+        info->pid, args->nice_value, g_strerror(saved_errno));
+
+    dialog = gtk_message_dialog_new (
+        NULL,
+        GTK_DIALOG_DESTROY_WITH_PARENT,
+        GTK_MESSAGE_ERROR,
+        GTK_BUTTONS_OK,
+        "%s", error_msg);
+
+    gtk_dialog_run (GTK_DIALOG (dialog));
+    gtk_widget_destroy (dialog);
+    g_free (error_msg);
+}
+
+
+void
+renice (ProcData *procdata, int nice)
+{
+    struct ReniceArgs args = { procdata, nice };
+
+    /* EEEK - ugly hack - make sure the table is not updated as a crash
+    ** occurs if you first kill a process and the tree node is removed while
+    ** still in the foreach function
+    */
+    g_source_remove(procdata->timeout);
+
+    gtk_tree_selection_selected_foreach(procdata->selection, renice_single_process,
+                                        &args);
+
+    procdata->timeout = g_timeout_add(procdata->config.update_interval,
+                                      cb_timeout,
+                                      procdata);
+
+    proctable_update (procdata);
+}
+
+
+
+
+static void
+kill_single_process (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+    const struct KillArgs * const args = static_cast<KillArgs*>(data);
+    char *error_msg;
+    ProcInfo *info;
+    int error;
+    int saved_errno;
+    GtkWidget *dialog;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    error = kill (info->pid, args->signal);
+
+    /* success */
+    if(error != -1) return;
+
+    saved_errno = errno;
+
+    /* need to be root */
+    if(errno == EPERM) {
+        gboolean success;
+
+        success = procdialog_create_root_password_dialog (
+            PROCMAN_ACTION_KILL, args->procdata, info->pid,
+            args->signal);
+
+        if(success) return;
+
+        if(errno) {
+            saved_errno = errno;
+        }
+    }
+
+    /* failed */
+    error_msg = g_strdup_printf (
+        _("Cannot kill process with PID %d with signal %d.\n"
+          "%s"),
+        info->pid, args->signal, g_strerror(saved_errno));
+
+    dialog = gtk_message_dialog_new (
+        NULL,
+        GTK_DIALOG_DESTROY_WITH_PARENT,
+        GTK_MESSAGE_ERROR,
+        GTK_BUTTONS_OK,
+        "%s", error_msg);
+
+    gtk_dialog_run (GTK_DIALOG (dialog));
+    gtk_widget_destroy (dialog);
+    g_free (error_msg);
+}
+
+
+void
+kill_process (ProcData *procdata, int sig)
+{
+    struct KillArgs args = { procdata, sig };
+
+    /* EEEK - ugly hack - make sure the table is not updated as a crash
+    ** occurs if you first kill a process and the tree node is removed while
+    ** still in the foreach function
+    */
+    g_source_remove (procdata->timeout);
+
+    gtk_tree_selection_selected_foreach (procdata->selection, kill_single_process,
+                                         &args);
+
+    procdata->timeout = g_timeout_add (procdata->config.update_interval,
+                                       cb_timeout,
+                                       procdata);
+    proctable_update (procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/33.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/33.html new file mode 100644 index 00000000..41c754fc --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/33.html @@ -0,0 +1,1417 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
/* Procman - dialogs
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procdialogs.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "procactions.h"
+#include "util.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "procman_gksu.h"
+#include "procman_pkexec.h"
+#include "cgroups.h"
+
+#define GET_WIDGET(x) GTK_WIDGET(gtk_builder_get_object(builder, x))
+
+static GtkWidget *renice_dialog = NULL;
+static GtkWidget *prefs_dialog = NULL;
+static gint new_nice_value = 0;
+
+
+static void
+kill_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    struct KillArgs *kargs = static_cast<KillArgs*>(data);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    if (id == GTK_RESPONSE_OK)
+        kill_process (kargs->procdata, kargs->signal);
+
+    g_free (kargs);
+}
+
+void
+procdialog_create_kill_dialog (ProcData *procdata, int signal)
+{
+    GtkWidget *kill_alert_dialog;
+    gchar *primary, *secondary, *button_text;
+    struct KillArgs *kargs;
+
+    kargs = g_new(KillArgs, 1);
+    kargs->procdata = procdata;
+    kargs->signal = signal;
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if ( selected_count == 1 ) {
+        ProcInfo *selected_process = NULL;
+        // get the last selected row
+        gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &selected_process);
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing single process*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        } else {
+            /*xgettext: primary alert message for ending single process*/
+            primary = g_strdup_printf (_("Are you sure you want to end the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        }
+    } else {
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the %d selected processes?"),
+                                       selected_count);
+        } else {
+            /*xgettext: primary alert message for ending multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to end the %d selected processes?"),
+                                       selected_count);
+
+        }
+    }
+
+    if ( signal == SIGKILL ) {
+        /*xgettext: secondary alert message*/
+        secondary = _("Killing a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be killed.");
+        button_text = ngettext("_Kill Process", "_Kill Processes", selected_count);
+    } else {
+        /*xgettext: secondary alert message*/
+        secondary = _("Ending a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be ended.");
+        button_text = ngettext("_End Process", "_End Processes", selected_count);
+    }
+
+    kill_alert_dialog = gtk_message_dialog_new (GTK_WINDOW (procdata->app),
+                                                static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
+                                                GTK_MESSAGE_WARNING,
+                                                GTK_BUTTONS_NONE,
+                                                "%s",
+                                                primary);
+    g_free (primary);
+
+    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (kill_alert_dialog),
+                                              "%s",
+                                              secondary);
+
+    gtk_dialog_add_buttons (GTK_DIALOG (kill_alert_dialog),
+                            "gtk-cancel", GTK_RESPONSE_CANCEL,
+                            button_text, GTK_RESPONSE_OK,
+                            NULL);
+
+    gtk_dialog_set_default_response (GTK_DIALOG (kill_alert_dialog),
+                                     GTK_RESPONSE_CANCEL);
+
+    g_signal_connect (G_OBJECT (kill_alert_dialog), "response",
+                      G_CALLBACK (kill_dialog_button_pressed), kargs);
+
+    gtk_widget_show_all (kill_alert_dialog);
+}
+
+static void
+renice_scale_changed (GtkAdjustment *adj, gpointer data)
+{
+    GtkWidget *label = GTK_WIDGET (data);
+
+    new_nice_value = int(gtk_adjustment_get_value (adj));
+    gchar* text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (new_nice_value));
+    gtk_label_set_text (GTK_LABEL (label), text);
+    g_free(text);
+
+}
+
+static void
+renice_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (id == 100) {
+        if (new_nice_value == -100)
+            return;
+        renice(procdata, new_nice_value);
+    }
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+    renice_dialog = NULL;
+}
+
+void
+procdialog_create_renice_dialog (ProcData *procdata)
+{
+    ProcInfo  *info;
+    GtkWidget *dialog = NULL;
+    GtkWidget *dialog_vbox;
+    GtkWidget *vbox;
+    GtkWidget *label;
+    GtkWidget *priority_label;
+    GtkWidget *grid;
+    GtkAdjustment *renice_adj;
+    GtkWidget *hscale;
+    GtkWidget *button;
+    GtkWidget *icon;
+    gchar     *text;
+    gchar     *dialog_title;
+
+    if (renice_dialog)
+        return;
+
+    gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &info);
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if (!info)
+        return;
+
+    if ( selected_count == 1 ) {
+        dialog_title = g_strdup_printf (_("Change Priority of Process “%s†(PID: %u)"),
+                                        info->name, info->pid);
+    } else {
+        dialog_title = g_strdup_printf (_("Change Priority of %d Selected Processes"),
+                                        selected_count);
+    }
+
+    dialog = gtk_dialog_new_with_buttons (dialog_title, NULL,
+                                          GTK_DIALOG_DESTROY_WITH_PARENT,
+                                          "gtk-cancel", GTK_RESPONSE_CANCEL,
+                                          NULL);
+    g_free (dialog_title);
+
+    renice_dialog = dialog;
+    gtk_window_set_resizable (GTK_WINDOW (renice_dialog), FALSE);
+    gtk_container_set_border_width (GTK_CONTAINER (renice_dialog), 5);
+
+    button = gtk_button_new_with_mnemonic (_("Change _Priority"));
+    gtk_widget_set_can_default (button, TRUE);
+
+    icon = gtk_image_new_from_icon_name ("gtk-apply", GTK_ICON_SIZE_BUTTON);
+    gtk_button_set_image (GTK_BUTTON (button), icon);
+
+    gtk_dialog_add_action_widget (GTK_DIALOG (renice_dialog), button, 100);
+    gtk_dialog_set_default_response (GTK_DIALOG (renice_dialog), 100);
+    new_nice_value = -100;
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+    gtk_box_set_spacing (GTK_BOX (dialog_vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), vbox, TRUE, TRUE, 0);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+
+    grid = gtk_grid_new ();
+    gtk_grid_set_column_spacing (GTK_GRID(grid), 12);
+    gtk_grid_set_row_spacing (GTK_GRID(grid), 6);
+    gtk_box_pack_start (GTK_BOX (vbox), grid, TRUE, TRUE, 0);
+
+    label = gtk_label_new_with_mnemonic (_("_Nice value:"));
+    gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 2);
+
+    renice_adj = gtk_adjustment_new (info->nice, RENICE_VAL_MIN, RENICE_VAL_MAX, 1, 1, 0);
+    new_nice_value = 0;
+    hscale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, renice_adj);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), hscale);
+    gtk_scale_set_digits (GTK_SCALE (hscale), 0);
+    gtk_widget_set_hexpand (hscale, TRUE);
+    gtk_grid_attach (GTK_GRID (grid), hscale, 1, 0, 1, 1);
+    text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (info->nice));
+    priority_label = gtk_label_new (text);
+    gtk_grid_attach (GTK_GRID (grid), priority_label, 1, 1, 1, 1);
+    g_free(text);
+
+    text = g_strconcat("<small><i><b>", _("Note:"), "</b> ",
+        _("The priority of a process is given by its nice value. A lower nice value corresponds to a higher priority."),
+        "</i></small>", NULL);
+    label = gtk_label_new (_(text));
+    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+    g_free (text);
+
+    g_signal_connect (G_OBJECT (dialog), "response",
+                      G_CALLBACK (renice_dialog_button_pressed), procdata);
+    g_signal_connect (G_OBJECT (renice_adj), "value_changed",
+                      G_CALLBACK (renice_scale_changed), priority_label);
+
+    gtk_widget_show_all (dialog);
+
+
+}
+
+static void
+prefs_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    if (id == GTK_RESPONSE_HELP)
+    {
+        GError* error = 0;
+        if (!g_app_info_launch_default_for_uri("help:mate-system-monitor/mate-system-monitor-prefs", NULL, &error))
+        {
+            g_warning("Could not display preferences help : %s", error->message);
+            g_error_free(error);
+        }
+    }
+    else
+    {
+        gtk_widget_destroy (GTK_WIDGET (dialog));
+        prefs_dialog = NULL;
+    }
+}
+
+
+class SpinButtonUpdater
+{
+public:
+    SpinButtonUpdater(const string& key)
+        : key(key)
+    { }
+
+    static gboolean callback(GtkWidget *widget, GdkEventFocus *event, gpointer data)
+    {
+        SpinButtonUpdater* updater = static_cast<SpinButtonUpdater*>(data);
+        gtk_spin_button_update(GTK_SPIN_BUTTON(widget));
+        updater->update(GTK_SPIN_BUTTON(widget));
+        return FALSE;
+    }
+
+private:
+
+    void update(GtkSpinButton* spin)
+    {
+        int new_value = int(1000 * gtk_spin_button_get_value(spin));
+        g_settings_set_int(ProcData::get_instance()->settings,
+                           this->key.c_str(), new_value);
+
+        procman_debug("set %s to %d", this->key.c_str(), new_value);
+    }
+
+    const string key;
+};
+
+
+static void
+field_toggled (const gchar *child_schema, GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+    GtkTreeIter iter;
+    GtkTreeViewColumn *column;
+    gboolean toggled;
+    GSettings *settings = g_settings_get_child (ProcData::get_instance()->settings, child_schema);
+    gchar *key;
+    int id;
+
+    if (!path)
+        return;
+
+    gtk_tree_model_get_iter (model, &iter, path);
+
+    gtk_tree_model_get (model, &iter, 2, &column, -1);
+    toggled = gtk_cell_renderer_toggle_get_active (cell);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, !toggled, -1);
+    gtk_tree_view_column_set_visible (column, !toggled);
+
+    id = gtk_tree_view_column_get_sort_column_id (column);
+
+    key = g_strdup_printf ("col-%d-visible", id);
+    g_settings_set_boolean (settings, key, !toggled);
+    g_free (key);
+
+    gtk_tree_path_free (path);
+}
+
+static void
+proc_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("proctree", cell, path_str, data);
+}
+
+static void
+disk_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("disktreenew", cell, path_str, data);
+}
+
+static void
+create_field_page(GtkBuilder* builder, GtkWidget *tree, const gchar *widgetname)
+{
+    GtkTreeView *treeview;
+    GList *it, *columns;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;<--- Shadowed declaration
+    GtkCellRenderer *cell;
+    gchar *full_widgetname;
+
+    full_widgetname = g_strdup_printf ("%s_columns", widgetname);
+    treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, full_widgetname));
+    g_free (full_widgetname);
+
+    model = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER);
+
+    gtk_tree_view_set_model (GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(model));
+    g_object_unref (G_OBJECT (model));
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_toggle_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "active", 0,
+                                         NULL);
+
+    if (g_strcmp0 (widgetname, "proctree") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (proc_field_toggled), model);
+    else if (g_strcmp0 (widgetname, "disktreenew") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (disk_field_toggled), model);
+
+    gtk_tree_view_column_set_clickable (column, TRUE);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "text", 1,
+                                         NULL);
+
+    gtk_tree_view_column_set_title (column, "Not Shown");
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    for(it = columns; it; it = it->next)
+    {
+        GtkTreeViewColumn *column = static_cast<GtkTreeViewColumn*>(it->data);<--- Shadow variable
+        GtkTreeIter iter;
+        const gchar *title;
+        gboolean visible;
+        gint column_id;
+
+        title = gtk_tree_view_column_get_title (column);
+        if (!title)
+            title = _("Icon");
+
+        column_id = gtk_tree_view_column_get_sort_column_id(column);
+        if ((column_id == COL_CGROUP) && (!cgroups_enabled()))
+            continue;
+
+        if ((column_id == COL_UNIT ||
+             column_id == COL_SESSION ||
+             column_id == COL_SEAT ||
+             column_id == COL_OWNER)
+#ifdef HAVE_SYSTEMD
+            && !LOGIND_RUNNING()
+#endif
+                )
+            continue;
+
+        visible = gtk_tree_view_column_get_visible (column);
+
+        gtk_list_store_append (model, &iter);
+        gtk_list_store_set (model, &iter, 0, visible, 1, title, 2, column,-1);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procdialog_create_preferences_dialog (ProcData *procdata)
+{
+    typedef SpinButtonUpdater SBU;
+
+    static SBU interval_updater("update-interval");
+    static SBU graph_interval_updater("graph-update-interval");
+    static SBU disks_interval_updater("disks-interval");
+
+    GtkWidget *notebook;
+    GtkAdjustment *adjustment;
+    GtkWidget *spin_button;
+    GtkWidget *check_button;
+    GtkWidget *smooth_button;
+    GtkBuilder *builder;
+    gfloat update;
+
+    if (prefs_dialog)
+        return;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/preferences.ui");
+
+    prefs_dialog = GET_WIDGET("preferences_dialog");
+    notebook = GET_WIDGET("notebook");
+    spin_button = GET_WIDGET("processes_interval_spinner");
+
+    update = (gfloat) procdata->config.update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0,
+                                   MIN_UPDATE_INTERVAL / 1000,
+                                   MAX_UPDATE_INTERVAL / 1000,
+                                   0.25,
+                                   1.0,
+                                   0);
+
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK (SBU::callback), &interval_updater);
+
+    smooth_button = GET_WIDGET("smooth_button");
+    g_settings_bind(procdata->settings, SmoothRefresh::KEY.c_str(), smooth_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    check_button = GET_WIDGET("check_button");
+    g_settings_bind(procdata->settings, "kill-dialog", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    GtkWidget *solaris_button = GET_WIDGET("solaris_button");
+    g_settings_bind(procdata->settings, procman::settings::solaris_mode.c_str(), solaris_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->tree, "proctree");
+
+    update = (gfloat) procdata->config.graph_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0, 0.25,
+                                                      100.0, 0.25, 1.0, 0);
+
+    spin_button = GET_WIDGET("resources_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &graph_interval_updater);
+
+    GtkWidget *bits_button = GET_WIDGET("bits_button");
+    g_settings_bind(procdata->settings, procman::settings::network_in_bits.c_str(), bits_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+
+    update = (gfloat) procdata->config.disks_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new (update / 1000.0, 1.0,
+                                                       100.0, 1.0, 1.0, 0);
+
+    spin_button = GET_WIDGET("devices_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &disks_interval_updater);
+
+    check_button = GET_WIDGET("all_devices_check");
+    g_settings_bind(procdata->settings, "show-all-fs", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->disk_list, "disktreenew");
+
+    gtk_widget_show_all (prefs_dialog);
+    g_signal_connect (G_OBJECT (prefs_dialog), "response",
+                       G_CALLBACK (prefs_dialog_button_pressed), procdata);
+
+    switch (procdata->config.current_tab) {
+    case PROCMAN_TAB_SYSINFO:
+    case PROCMAN_TAB_PROCESSES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
+        break;
+    case PROCMAN_TAB_RESOURCES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 1);
+        break;
+    case PROCMAN_TAB_DISKS:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 2);
+        break;
+    }
+
+    gtk_builder_connect_signals (builder, NULL);
+    g_object_unref (G_OBJECT (builder));
+}
+
+
+static char *
+procman_action_to_command(ProcmanActionType type,
+                          gint pid,
+                          gint extra_value)
+{
+    switch (type) {
+    case PROCMAN_ACTION_KILL:
+           return g_strdup_printf("kill -s %d %d", extra_value, pid);
+    case PROCMAN_ACTION_RENICE:
+        return g_strdup_printf("renice %d %d", extra_value, pid);
+    default:
+        g_assert_not_reached();
+    }
+}
+
+
+/*
+ * type determines whether if dialog is for killing process or renice.
+ * type == PROCMAN_ACTION_KILL,   extra_value -> signal to send
+ * type == PROCMAN_ACTION_RENICE, extra_value -> new priority.
+ */
+gboolean
+procdialog_create_root_password_dialog(ProcmanActionType type,
+                                       ProcData *procdata,
+                                       gint pid,
+                                       gint extra_value)
+{
+    char * command;
+    gboolean ret = FALSE;
+
+    command = procman_action_to_command(type, pid, extra_value);
+
+    procman_debug("Trying to run '%s' as root", command);
+
+    if (procman_has_pkexec())
+        ret = procman_pkexec_create_root_password_dialog(command);
+    else if (procman_has_gksu())
+        ret = procman_gksu_create_root_password_dialog(command);
+
+    g_free(command);
+    return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/34.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/34.html new file mode 100644 index 00000000..b9fac436 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/34.html @@ -0,0 +1,261 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
#ifndef H_MATE_SYSTEM_MONITOR_GKSU_H_1132171928
+#define H_MATE_SYSTEM_MONITOR_GKSU_H_1132171928
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+gboolean
+procman_gksu_create_root_password_dialog(const char * command);
+
+gboolean
+procman_has_gksu(void) G_GNUC_CONST;
+
+#endif /* H_MATE_SYSTEM_MONITOR_GKSU_H_1132171928 */
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/35.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/35.html new file mode 100644 index 00000000..a61896ec --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/35.html @@ -0,0 +1,261 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
#ifndef _PROCMAN_PKEXEC_H_
+#define _PROCMAN_PKEXEC_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+gboolean
+procman_pkexec_create_root_password_dialog(const char *command);
+
+gboolean
+procman_has_pkexec(void) G_GNUC_CONST;
+
+#endif /* _PROCMAN_PKEXEC_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/36.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/36.html new file mode 100644 index 00000000..f3d2b88d --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/36.html @@ -0,0 +1,1109 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/close.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/sysinfo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman-app.h"
+#include "procman.h"
+#include "interface.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "argv.h"
+#include "util.h"
+
+static void
+mount_changed(const Glib::RefPtr<Gio::Mount>&)
+{
+    cb_update_disks(ProcData::get_instance());
+}
+
+
+static void
+init_volume_monitor(ProcData *procdata)
+{
+    using namespace Gio;
+    using namespace Glib;
+
+    RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+    monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
+}
+
+static gboolean
+has_key (gchar **keys, const gchar *key)
+{
+    gchar **loop = keys;
+
+    while (*loop) {
+        if (!strcmp (*loop++, key))
+            return TRUE;
+    }
+
+    return FALSE;
+}
+
+static void
+tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_tree = g_settings_get_boolean(settings, key);
+
+    g_object_set(G_OBJECT(procdata->tree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
+    proctable_update (procdata);
+}
+
+
+static void
+network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
+    // force scale to be redrawn
+    procdata->net_graph->clear_background();
+}
+
+static void
+view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.whose_process = g_settings_get_int (settings, key);
+    procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2);
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "kill-dialog")) {
+        procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
+    }
+}
+
+static void
+timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "update-interval")) {
+        procdata->config.update_interval = g_settings_get_int (settings, key);
+        procdata->config.update_interval =
+            MAX (procdata->config.update_interval, 1000);
+
+        procdata->smooth_refresh->reset();
+
+        if(procdata->timeout) {
+            g_source_remove (procdata->timeout);
+            procdata->timeout = g_timeout_add (procdata->config.update_interval,
+                                               cb_timeout,
+                                               procdata);
+        }
+    }
+    else if (g_str_equal (key, "graph-update-interval")){
+        procdata->config.graph_update_interval = g_settings_get_int (settings, key);
+        procdata->config.graph_update_interval =
+            MAX (procdata->config.graph_update_interval,
+                 250);
+        load_graph_change_speed(procdata->cpu_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->mem_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->net_graph,
+                                procdata->config.graph_update_interval);
+    }
+    else if (g_str_equal(key, "disks-interval")) {
+        procdata->config.disks_update_interval = g_settings_get_int (settings, key);
+        procdata->config.disks_update_interval =
+            MAX (procdata->config.disks_update_interval, 1000);
+
+        if(procdata->disk_timeout) {
+            g_source_remove (procdata->disk_timeout);
+            procdata->disk_timeout = \
+                g_timeout_add (procdata->config.disks_update_interval,
+                               cb_update_disks,
+                               procdata);
+        }
+    }
+    else {
+        g_assert_not_reached();
+    }
+}
+
+static void
+color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    gchar *color = g_settings_get_string (settings, key);
+
+    if (g_str_has_prefix (key, "cpu-color")) {
+        for (int i = 0; i < procdata->config.num_cpus; i++) {
+            string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
+            if (cpu_key == key) {
+                gdk_rgba_parse (&procdata->config.cpu_color[i], color);
+                procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
+                break;
+            }
+        }
+    }
+    else if (g_str_equal (key, "mem-color")) {
+        gdk_rgba_parse (&procdata->config.mem_color, color);
+        procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
+    }
+    else if (g_str_equal (key, "swap-color")) {
+        gdk_rgba_parse (&procdata->config.swap_color, color);
+        procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
+    }
+    else if (g_str_equal (key, "net-in-color")) {
+        gdk_rgba_parse (&procdata->config.net_in_color, color);
+        procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
+    }
+    else if (g_str_equal (key, "net-out-color")) {
+        gdk_rgba_parse (&procdata->config.net_out_color, color);
+        procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
+    }
+    else {
+        g_assert_not_reached();
+    }
+    g_free(color);
+}
+
+static void
+show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
+
+    cb_update_disks (data);
+}
+
+static ProcData *
+procman_data_new (GSettings *settings)
+{
+    GSettingsSchema *schema;
+    ProcData *pd;
+    gchar *color;
+    gchar **keys;
+    glibtop_cpu cpu;
+
+    pd = ProcData::get_instance();
+
+    g_settings_get (settings, "window-state", "(iiii)",
+                    &pd->config.width, &pd->config.height,
+                    &pd->config.xpos, &pd->config.ypos);
+
+    pd->config.maximized = g_settings_get_boolean(settings, "maximized");
+
+    pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
+    g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd);
+
+    pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
+    std::string detail_string("changed::" + procman::settings::solaris_mode);
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd);
+
+    pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
+    detail_string = "changed::" + procman::settings::network_in_bits;
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd);
+
+    pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
+    g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd);
+    pd->config.update_interval = g_settings_get_int (settings, "update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.graph_update_interval = g_settings_get_int (settings,
+                                                           "graph-update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",
+                      G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd);
+
+
+    /* show_all_fs */
+    pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
+    g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd);
+
+
+    pd->config.whose_process = g_settings_get_int (settings, "view-as");
+    g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd);
+    pd->config.current_tab = g_settings_get_int (settings, "current-tab");
+
+    glibtop_get_cpu (&cpu);
+    pd->frequency = cpu.frequency;
+    pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
+
+    g_object_get (settings, "settings-schema", &schema, NULL);
+    keys = g_settings_schema_list_keys (schema);
+    g_settings_schema_unref (schema);
+
+    for (int i = 0; i < pd->config.num_cpus; i++) {
+        gchar *key;
+        key = g_strdup_printf ("cpu-color%d", i);
+
+        if (has_key (keys, key))
+            color = g_settings_get_string (settings, key);
+        else
+            color = g_strdup ("#f25915e815e8");
+        detail_string = std::string("changed::") + std::string(key);
+        g_signal_connect (G_OBJECT(settings), detail_string.c_str(),
+                          G_CALLBACK(color_changed_cb), pd);
+        gdk_rgba_parse (&pd->config.cpu_color[i], color);
+        g_free (color);
+        g_free (key);
+    }
+    g_strfreev (keys);
+
+    color = g_settings_get_string (settings, "mem-color");
+    if (!color)
+        color = g_strdup ("#000000ff0082");
+    g_signal_connect (G_OBJECT(settings), "changed::mem-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.mem_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "swap-color");
+    if (!color)
+        color = g_strdup ("#00b6000000ff");
+    g_signal_connect (G_OBJECT(settings), "changed::swap-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.swap_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-in-color");
+    if (!color)
+        color = g_strdup ("#000000f200f2");
+    g_signal_connect (G_OBJECT(settings), "changed::net-in-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_in_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-out-color");
+    if (!color)
+        color = g_strdup ("#00f2000000c1");
+    g_signal_connect (G_OBJECT(settings), "changed::net-out-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_out_color, color);
+    g_free (color);
+
+    /* Sanity checks */
+    GdkDisplay *display;
+    GdkMonitor *monitor;
+    GdkRectangle monitor_geometry;
+
+    display = gdk_display_get_default ();
+    monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
+    if (monitor == NULL) {
+        monitor = gdk_display_get_monitor (display, 0);
+    }
+    gdk_monitor_get_geometry (monitor, &monitor_geometry);
+
+    pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width);
+    pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height);
+    pd->config.update_interval = MAX (pd->config.update_interval, 1000);
+    pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250);
+    pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000);
+    pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2);
+    pd->config.current_tab = CLAMP(pd->config.current_tab,
+                                   PROCMAN_TAB_SYSINFO,
+                                   PROCMAN_TAB_DISKS);
+
+    // delayed initialization as SmoothRefresh() needs ProcData
+    // i.e. we can't call ProcData::get_instance
+    pd->smooth_refresh = new SmoothRefresh(settings);
+
+    pd->terminating = FALSE;
+
+    return pd;
+}
+
+static void
+procman_free_data (ProcData *procdata)
+{
+
+    proctable_free_table (procdata);
+    delete procdata->smooth_refresh;
+}
+
+ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
+{
+    Glib::set_application_name(_("System Monitor"));
+}
+
+Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
+{
+    return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
+}
+
+void ProcmanApp::on_activate()
+{
+    gtk_window_present (GTK_WINDOW (procdata->app));
+}
+
+static void
+set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
+{
+    gtk_notebook_set_current_page(notebook, tab);
+    cb_change_current_page(notebook, tab, procdata);
+}
+
+int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
+{
+    int argc = 0;
+    char** argv = command_line->get_arguments(argc);
+
+    Glib::OptionContext context;
+    context.set_summary(_("A simple process and system monitor."));
+    context.set_ignore_unknown_options(true);
+    procman::OptionGroup option_group;
+    context.set_main_group(option_group);
+
+    try {
+        context.parse(argc, argv);
+    } catch (const Glib::Error& ex) {
+        g_error("Arguments parse error : %s", ex.what().c_str());
+    }
+
+    if (option_group.show_system_tab) {
+        procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_SYSINFO, procdata);
+    } else if (option_group.show_processes_tab) {
+        procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_PROCESSES, procdata);
+    } else if (option_group.show_resources_tab) {
+        procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_RESOURCES, procdata);
+    } else if (option_group.show_file_systems_tab) {
+        procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_DISKS, procdata);
+    }
+
+    on_activate ();
+
+    return 0;
+}
+
+void ProcmanApp::on_startup()
+{
+    Gtk::Application::on_startup();
+
+    GSettings *settings;
+
+    Gtk::Window::set_default_icon_name ("utilities-system-monitor");
+
+    settings = g_settings_new (GSM_GSETTINGS_SCHEMA);
+
+    glibtop_init ();
+
+    procdata = procman_data_new (settings);
+    procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA);
+
+    create_main_window (procdata);
+    init_volume_monitor (procdata);
+
+    Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app));
+    window->show();
+    window->set_name ("mate-system-monitor");
+
+    add_window (*window);
+}
+
+void ProcmanApp::on_shutdown()
+{
+    procman_free_data(procdata);
+    glibtop_close();
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/37.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/37.html new file mode 100644 index 00000000..9a0699dc --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/37.html @@ -0,0 +1,283 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
#ifndef _PROCMAN_PROCMAN_APP_H_
+#define _PROCMAN_PROCMAN_APP_H_
+
+#include <gtkmm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+class ProcmanApp : public Gtk::Application
+{
+    ProcData *procdata;
+protected:
+    ProcmanApp();
+public:
+    static Glib::RefPtr<ProcmanApp> create ();
+protected:
+    virtual void on_activate();
+    virtual int on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line);
+    virtual void on_startup();
+    virtual void on_shutdown();
+};
+
+#endif  /* _PROCMAN_PROCMAN_APP_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/38.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/38.html new file mode 100644 index 00000000..972eeaf8 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/38.html @@ -0,0 +1,671 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtkmm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman-app.h"
+#include "procman.h"
+#include "proctable.h"
+
+ProcData::ProcData()
+    : tree(NULL),
+      cpu_graph(NULL),
+      mem_graph(NULL),
+      net_graph(NULL),
+      selected_process(NULL),
+      timeout(0),
+      disk_timeout(0),
+      cpu_total_time(1),
+      cpu_total_time_last(1)
+{ }
+
+ProcData* ProcData::get_instance()
+{
+    static ProcData instance;
+    return &instance;
+}
+
+gboolean
+procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns, *it;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    sort_col = g_settings_get_int (pt_settings, "sort-col");
+
+    order = static_cast<GtkSortType>(g_settings_get_int (pt_settings, "sort-order"));
+
+    if (sort_col != -1)
+        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
+                                              sort_col,
+                                              order);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        for (it = columns; it; it = it->next)
+        {
+            GtkTreeViewColumn *column;
+            gint width;
+            gboolean visible;
+            int id;
+            gchar *key;
+
+            column = static_cast<GtkTreeViewColumn*>(it->data);
+            id = gtk_tree_view_column_get_sort_column_id (column);
+
+            key = g_strdup_printf ("col-%d-width", id);
+            g_settings_get (pt_settings, key, "i", &width);
+            g_free (key);
+
+            key = g_strdup_printf ("col-%d-visible", id);
+            visible = g_settings_get_boolean (pt_settings, key);
+            g_free (key);
+
+            gtk_tree_view_column_set_visible (column, visible);
+            if (visible) {
+                /* ensure column is really visible */
+                width = MAX(width, 20);
+                gtk_tree_view_column_set_fixed_width(column, width);
+            }
+        }
+
+        GVariant     *value;
+        GVariantIter iter;
+        int          sortIndex;
+
+        GSList *order = NULL;<--- Shadow variable
+
+        value = g_settings_get_value(pt_settings, "columns-order");
+        g_variant_iter_init(&iter, value);
+
+        while (g_variant_iter_loop (&iter, "i", &sortIndex))
+            order = g_slist_append(order, GINT_TO_POINTER(sortIndex));
+
+        proctable_set_columns_order(GTK_TREE_VIEW(tree), order);
+
+        g_variant_unref(value);
+        g_slist_free(order);
+    }
+
+    g_object_unref(pt_settings);
+    pt_settings = NULL;
+
+    g_list_free(columns);
+
+    return TRUE;
+}
+
+void
+procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    if (ProcData::get_instance()->terminating)
+        return;
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    if (gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (model), &sort_col,
+                                              &order)) {
+        g_settings_set_int (pt_settings, "sort-col", sort_col);
+        g_settings_set_int (pt_settings, "sort-order", order);
+    }
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        GSList *order;<--- Shadow variable
+        GSList *order_node;
+        GVariantBuilder *builder;
+        GVariant *order_variant;
+
+        order = proctable_get_columns_order(GTK_TREE_VIEW(tree));
+
+        builder = g_variant_builder_new (G_VARIANT_TYPE ("ai"));
+
+        for (order_node = order; order_node; order_node = order_node->next)
+            g_variant_builder_add(builder, "i", GPOINTER_TO_INT(order_node->data));
+
+        order_variant = g_variant_new("ai", builder);
+        g_settings_set_value(pt_settings, "columns-order", order_variant);
+
+        g_slist_free(order);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procman_save_config (ProcData *data)
+{
+    GSettings *settings = data->settings;
+
+    g_assert(data);
+
+    data->config.maximized = gdk_window_get_state(gtk_widget_get_window (data->app)) & GDK_WINDOW_STATE_MAXIMIZED;
+    if (!data->config.maximized) {
+        // we only want to store/overwrite size and position info with non-maximized state info
+        data->config.width  = gdk_window_get_width (gtk_widget_get_window (data->app));
+        data->config.height = gdk_window_get_height(gtk_widget_get_window (data->app));
+
+        gtk_window_get_position(GTK_WINDOW(data->app), &data->config.xpos, &data->config.ypos);
+
+        g_settings_set (settings, "window-state", "(iiii)",
+                        data->config.width, data->config.height,
+                        data->config.xpos, data->config.ypos);
+    }
+    g_settings_set_boolean (settings, "maximized", data->config.maximized);
+
+    g_settings_set_int (settings, "current-tab", data->config.current_tab);
+}
+
+int
+main (int argc, char *argv[])
+{
+    bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+    textdomain (GETTEXT_PACKAGE);
+    setlocale (LC_ALL, "");
+
+    Glib::RefPtr<ProcmanApp> application = ProcmanApp::create();
+    return application->run (argc, argv);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/39.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/39.html new file mode 100644 index 00000000..c34d3e03 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/39.html @@ -0,0 +1,303 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "procman_gksu.h"
+
+gboolean
+procman_gksu_create_root_password_dialog (const char *command)
+{
+    gchar *command_line;
+    gboolean success;
+    GError *error = NULL;
+
+    command_line = g_strdup_printf ("gksu '%s'", command);
+    success = g_spawn_command_line_sync (command_line, NULL, NULL, NULL, &error);
+    g_free (command_line);
+
+    if (!success) {
+        g_critical ("Could not run gksu '%s' : %s\n",
+                    command, error->message);
+        g_error_free (error);
+        return FALSE;
+    }
+
+    g_debug ("gksu did fine\n");
+    return TRUE;
+}
+
+gboolean
+procman_has_gksu (void)
+{
+    return g_file_test ("/usr/bin/gksu", G_FILE_TEST_EXISTS);
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/4.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/4.html new file mode 100644 index 00000000..d7329c12 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/4.html @@ -0,0 +1,763 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef _PROCMAN_PROCMAN_H_
+#define _PROCMAN_PROCMAN_H_
+
+#include <glibmm/refptr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <cairo-gobject.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk-pixbuf/gdk-pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <map><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+struct ProcInfo;
+struct ProcData;
+struct LoadGraph;
+
+#include "smooth_refresh.h"
+#include "prettytable.h"
+
+#define GSM_GSETTINGS_SCHEMA "org.mate.system-monitor"
+
+enum
+{
+    ALL_PROCESSES,
+    MY_PROCESSES,
+    ACTIVE_PROCESSES
+};
+
+enum
+{
+    VERY_HIGH_PRIORITY,
+    HIGH_PRIORITY,
+    NORMAL_PRIORITY,
+    LOW_PRIORITY,
+    VERY_LOW_PRIORITY,
+    CUSTOM_PRIORITY
+};
+
+static const unsigned MIN_UPDATE_INTERVAL =   1 * 1000;
+static const unsigned MAX_UPDATE_INTERVAL = 100 * 1000;
+
+enum ProcmanTab
+{
+    PROCMAN_TAB_SYSINFO,
+    PROCMAN_TAB_PROCESSES,
+    PROCMAN_TAB_RESOURCES,
+    PROCMAN_TAB_DISKS
+};
+
+struct ProcConfig
+{
+    gint        width;
+    gint        height;
+    gint        xpos;
+    gint        ypos;
+    gboolean    maximized;
+    gboolean    show_kill_warning;
+    gboolean    show_tree;
+    gboolean    show_all_fs;
+    int         update_interval;
+    int         graph_update_interval;
+    int         disks_update_interval;
+    gint        whose_process;
+    gint        current_tab;
+    GdkRGBA     cpu_color[GLIBTOP_NCPU];
+    GdkRGBA     mem_color;
+    GdkRGBA     swap_color;
+    GdkRGBA     net_in_color;
+    GdkRGBA     net_out_color;
+    GdkRGBA     bg_color;
+    GdkRGBA     frame_color;
+    gint        num_cpus;
+    bool solaris_mode;
+    bool network_in_bits;
+};
+
+struct MutableProcInfo
+{
+MutableProcInfo()
+  : disk_write_bytes_current(0ULL),
+    disk_read_bytes_current(0ULL),
+    disk_write_bytes_total(0ULL),
+    disk_read_bytes_total(0ULL),
+    status(0U)
+    { }
+
+    std::string user;
+
+    gchar wchan[40];
+
+    // all these members are filled with libgtop which uses
+    // guint64 (to have fixed size data) but we don't need more
+    // than an unsigned long (even for 32bit apps on a 64bit
+    // kernel) as these data are amounts, not offsets.
+    gulong vmsize;
+    gulong memres;
+    gulong memshared;
+    gulong memwritable;
+    gulong mem;
+
+#ifdef HAVE_WNCK
+    // wnck gives an unsigned long
+    gulong memxserver;
+#endif
+
+    gulong start_time;
+    guint64 cpu_time;
+    guint64 disk_write_bytes_current;
+    guint64 disk_read_bytes_current;
+    guint64 disk_write_bytes_total;
+    guint64 disk_read_bytes_total;
+    guint status;
+    guint pcpu;
+    gint nice;
+    gchar *cgroup_name;
+
+    gchar *unit;
+    gchar *session;
+    gchar *seat;
+
+    std::string owner;
+};
+
+class ProcInfo
+: public MutableProcInfo
+{
+    /* undefined */ ProcInfo& operator=(const ProcInfo&);
+    /* undefined */ ProcInfo(const ProcInfo&);
+
+    typedef std::map<guint, std::string> UserMap;
+    /* cached username */
+    static UserMap users;
+
+  public:
+
+    // TODO: use a set instead
+    // sorted by pid. The map has a nice property : it is sorted
+    // by pid so this helps a lot when looking for the parent node
+    // as ppid is nearly always < pid.
+    typedef std::map<pid_t, ProcInfo*> List;
+    typedef List::iterator Iterator;
+
+    static List all;
+
+    static ProcInfo* find(pid_t pid);
+    static Iterator begin() { return ProcInfo::all.begin(); }
+    static Iterator end() { return ProcInfo::all.end(); }
+
+    ProcInfo(pid_t pid);
+    ~ProcInfo();
+    // adds one more ref to icon
+    void set_icon(Glib::RefPtr<Gdk::Pixbuf> icon);
+    void set_user(guint uid);
+    std::string lookup_user(guint uid);
+
+    GtkTreeIter      node;
+    cairo_surface_t *surface;
+    gchar           *tooltip;
+    gchar           *name;
+    gchar           *arguments;
+    gchar           *security_context;
+
+    const pid_t      pid;
+    pid_t            ppid;
+    guint            uid;
+
+// private:
+    // tracks cpu time per process keeps growing because if a
+    // ProcInfo is deleted this does not mean that the process is
+    // not going to be recreated on the next update.  For example,
+    // if dependencies + (My or Active), the proclist is cleared
+    // on each update.  This is a workaround
+    static std::map<pid_t, guint64> cpu_times;
+};
+
+struct ProcData
+{
+    // lazy initialization
+    static ProcData* get_instance();
+
+    GtkUIManager    *uimanager;
+    GtkActionGroup    *action_group;
+    GtkWidget    *statusbar;
+    gint        tip_message_cid;
+    GtkWidget    *tree;
+    GtkWidget    *loadavg;
+    GtkWidget    *endprocessbutton;
+    GtkWidget    *popup_menu;
+    GtkWidget    *disk_list;
+    GtkWidget    *notebook;
+    ProcConfig    config;
+    LoadGraph    *cpu_graph;
+    LoadGraph    *mem_graph;
+    LoadGraph    *net_graph;
+    gint        cpu_label_fixed_width;
+    gint        net_label_fixed_width;
+    ProcInfo    *selected_process;
+    GtkTreeSelection *selection;
+    guint        timeout;
+    guint        disk_timeout;
+
+    PrettyTable    pretty_table;
+
+    GSettings       *settings;
+    GtkWidget        *app;
+    GtkUIManager    *menu;
+
+    unsigned    frequency;
+
+    SmoothRefresh  *smooth_refresh;
+
+    guint64 cpu_total_time;
+    guint64 cpu_total_time_last;
+
+    gboolean terminating;
+
+private:
+    ProcData();
+    /* undefined */ ProcData(const ProcData &);
+    /* undefined */ ProcData& operator=(const ProcData &);
+};
+
+void        procman_save_config (ProcData *data);
+void        procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+gboolean    procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+
+struct ReniceArgs
+{
+    ProcData *procdata;
+    int nice_value;
+};
+
+struct KillArgs
+{
+    ProcData *procdata;
+    int signal;
+};
+
+#endif /* _PROCMAN_PROCMAN_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/40.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/40.html new file mode 100644 index 00000000..59cb183e --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/40.html @@ -0,0 +1,303 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman_pkexec.h"
+
+gboolean
+procman_pkexec_create_root_password_dialog (const char *command)
+{
+    gchar *command_line;
+    gboolean success;
+    GError *error = NULL;
+
+    command_line = g_strdup_printf ("pkexec --disable-internal-agent %s/msm-%s",
+                                    PKGLIBEXECDIR, command);
+    success = g_spawn_command_line_sync (command_line, NULL, NULL, NULL, &error);
+    g_free (command_line);
+
+    if (!success) {
+        g_critical ("Could not run pkexec (\"%s\") : %s\n",
+                    command, error->message);
+        g_error_free (error);
+        return FALSE;
+    }
+
+    g_debug ("pkexec did fine\n");
+    return TRUE;
+}
+
+gboolean
+procman_has_pkexec (void)
+{
+    return g_file_test("/usr/bin/pkexec", G_FILE_TEST_EXISTS);
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/41.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/41.html new file mode 100644 index 00000000..a96c88d2 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/41.html @@ -0,0 +1,913 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
/* Process properties dialog
+ * Copyright (C) 2010 Krishnan Parthasarathi <krishnan.parthasarathi@gmail.com>
+ *                    Robert Ancell <robert.ancell@canonical.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procmem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procmap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procstate.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "procproperties.h"
+#include "proctable.h"
+#include "util.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+enum
+{
+    COL_PROP = 0,
+    COL_VAL,
+    NUM_COLS,
+};
+
+typedef struct _proc_arg {
+    const gchar *prop;
+    gchar *val;
+} proc_arg;
+
+static void
+get_process_memory_writable (ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info (ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+static gchar*
+format_memsize(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
+}
+
+static gchar*
+format_size(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size(size);
+}
+
+static void
+fill_proc_properties (GtkWidget *tree, ProcInfo *info)
+{
+    guint i;
+    GtkListStore *store;
+
+    if (!info)
+        return;
+
+    get_process_memory_info(info);
+
+    proc_arg proc_props[] = {
+        { N_("Process Name"), g_strdup_printf("%s", info->name)},
+        { N_("User"), g_strdup_printf("%s (%d)", info->user.c_str(), info->uid)},
+        { N_("Status"), g_strdup(format_process_state(info->status))},
+        { N_("Memory"), format_memsize(info->mem)},
+        { N_("Virtual Memory"), format_memsize(info->vmsize)},
+        { N_("Resident Memory"), format_memsize(info->memres)},
+        { N_("Writable Memory"), format_memsize(info->memwritable)},
+        { N_("Shared Memory"), format_memsize(info->memshared)},
+#ifdef HAVE_WNCK
+        { N_("X Server Memory"), format_memsize(info->memxserver)},
+#endif
+        { N_("Disk Read Total"), format_size(info->disk_read_bytes_total)},
+        { N_("Disk Write Total"), format_size(info->disk_write_bytes_total)},
+        { N_("CPU"), g_strdup_printf("%d%%", info->pcpu)},
+        { N_("CPU Time"), procman::format_duration_for_display(100 * info->cpu_time / ProcData::get_instance()->frequency) },
+        { N_("Started"), procman_format_date_for_display(info->start_time) },
+        { N_("Nice"), g_strdup_printf("%d", info->nice)},
+        { N_("Priority"), g_strdup_printf("%s", procman::get_nice_level(info->nice)) },
+        { N_("ID"), g_strdup_printf("%d", info->pid)},
+        { N_("Security Context"), info->security_context ? g_strdup_printf("%s", info->security_context) : g_strdup(_("N/A"))},
+        { N_("Command Line"), g_strdup_printf("%s", info->arguments)},
+        { N_("Waiting Channel"), g_strdup_printf("%s", info->wchan)},
+        { N_("Control Group"), info->cgroup_name ? g_strdup_printf("%s", info->cgroup_name) : g_strdup(_("N/A"))},
+        { NULL, NULL}
+    };
+
+    store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
+    for (i = 0; proc_props[i].prop; i++) {
+        GtkTreeIter iter;
+
+        if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL(store), &iter, NULL, i)) {
+            gtk_list_store_append(store, &iter);
+            gtk_list_store_set(store, &iter, COL_PROP, _(proc_props[i].prop), -1);
+        }
+
+        gtk_list_store_set(store, &iter, COL_VAL, g_strstrip(proc_props[i].val), -1);
+        g_free(proc_props[i].val);
+    }
+}
+
+static void
+update_procproperties_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    fill_proc_properties(tree, info);
+}
+
+static void
+close_procprop_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    guint timer;
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static GtkWidget *
+create_procproperties_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    model = gtk_list_store_new (NUM_COLS,
+                                G_TYPE_STRING,	/* Property */
+                                G_TYPE_STRING	/* Value */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_COLS; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        column = gtk_tree_view_column_new_with_attributes (NULL,
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tree), FALSE);
+    fill_proc_properties(tree, procdata->selected_process);
+
+    return tree;
+}
+
+static gboolean
+procprop_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_procproperties_dialog (tree);
+
+    return TRUE;
+}
+
+static void
+create_single_procproperties_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                     GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *procpropdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    procpropdialog = gtk_dialog_new_with_buttons (_("Process Properties"), NULL,
+                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                  "gtk-close", GTK_RESPONSE_CLOSE,
+                                                  NULL);
+    gtk_window_set_resizable (GTK_WINDOW (procpropdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (procpropdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (procpropdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (procpropdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("Properties of process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_procproperties_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (procpropdialog), "response",
+                      G_CALLBACK (close_procprop_dialog), tree);
+
+    gtk_widget_show_all (procpropdialog);
+
+    timer = g_timeout_add_seconds (5, procprop_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_procproperties_dialog (tree);
+}
+
+void
+create_procproperties_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_procproperties_dialog,
+                                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/42.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/42.html new file mode 100644 index 00000000..194f1844 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/42.html @@ -0,0 +1,2635 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
/* Procman tree view and process updating
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <cairo-gobject.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gprintf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/loadavg.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/proclist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procstate.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procmem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procmap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/proctime.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procuid.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procargs.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/prockernel.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/swap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <pwd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <set><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <list><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef HAVE_SYSTEMD
+#include <systemd/sd-login.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include "procman.h"
+#include "selection.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "util.h"
+#include "interface.h"
+#include "selinux.h"
+#include "cgroups.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+ProcInfo::UserMap ProcInfo::users;
+ProcInfo::List ProcInfo::all;
+std::map<pid_t, guint64> ProcInfo::cpu_times;
+
+
+ProcInfo* ProcInfo::find(pid_t pid)
+{
+    Iterator it(ProcInfo::all.find(pid));
+    return (it == ProcInfo::all.end() ? NULL : it->second);
+}
+
+void
+get_last_selected (GtkTreeModel *model, GtkTreePath *path,
+           GtkTreeIter *iter, gpointer data)
+{
+    ProcInfo **info = static_cast<ProcInfo**>(data);
+
+    gtk_tree_model_get (model, iter, COL_POINTER, info, -1);
+}
+
+static void
+cb_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "proctree");
+}
+
+static void
+cb_sort_changed (GtkTreeSortable *model, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state (procdata->settings,
+                             GTK_WIDGET (procdata->tree),
+                             "proctree");
+}
+
+
+static GtkTreeViewColumn*
+my_gtk_tree_view_get_column_with_sort_column_id(GtkTreeView *treeview, int id)
+{
+    GList *columns, *it;
+    GtkTreeViewColumn *col = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(it = columns; it; it = it->next)
+    {
+        if(gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(it->data)) == id)
+        {
+            col = static_cast<GtkTreeViewColumn*>(it->data);
+            break;
+        }
+    }
+
+    g_list_free(columns);
+
+    return col;
+}
+
+
+void
+proctable_set_columns_order(GtkTreeView *treeview, GSList *order)
+{
+    GtkTreeViewColumn* last = NULL;
+    GSList *it;
+
+    for(it = order; it; it = it->next)
+    {
+        int id;
+        GtkTreeViewColumn *cur;
+
+        id = GPOINTER_TO_INT(it->data);
+
+        cur = my_gtk_tree_view_get_column_with_sort_column_id(treeview, id);
+
+        if(cur && cur != last)
+        {
+            gtk_tree_view_move_column_after(treeview, cur, last);
+            last = cur;
+        }
+    }
+}
+
+
+GSList*
+proctable_get_columns_order(GtkTreeView *treeview)
+{
+    GList *columns, *col;
+    GSList *order = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(col = columns; col; col = col->next)
+    {
+        int id;
+
+        id = gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(col->data));
+        order = g_slist_prepend(order, GINT_TO_POINTER(id));
+    }
+
+    g_list_free(columns);
+
+    order = g_slist_reverse(order);
+
+    return order;
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "proctree");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_proctable_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+static gboolean
+search_equal_func(GtkTreeModel *model,
+                  gint column,
+                  const gchar *key,
+                  GtkTreeIter *iter,
+                  gpointer search_data)
+{
+    char* name;
+    char* user;
+    gboolean found;
+
+    gtk_tree_model_get(model, iter,
+                       COL_NAME, &name,
+                       COL_USER, &user,
+                       -1);
+
+    found = !((name && strcasestr(name, key))
+              || (user && strcasestr(user, key)));
+
+    g_free(name);
+    g_free(user);
+
+    return found;
+}
+
+
+
+GtkWidget *
+proctable_new (ProcData * const procdata)
+{
+    GtkWidget *proctree;
+    GtkTreeStore *model;
+    GtkTreeSelection *selection;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell_renderer;
+
+    const gchar *titles[] = {
+        N_("Process Name"),
+        N_("User"),
+        N_("Status"),
+        N_("Virtual Memory"),
+        N_("Resident Memory"),
+        N_("Writable Memory"),
+        N_("Shared Memory"),
+        N_("X Server Memory"),
+        /* xgettext:no-c-format */ N_("% CPU"),
+        N_("CPU Time"),
+        N_("Started"),
+        N_("Nice"),
+        N_("ID"),
+        N_("Security Context"),
+        N_("Command Line"),
+        N_("Memory"),
+        /* xgettext: combined noun, the function the process is waiting in, see wchan ps(1) */
+        N_("Waiting Channel"),
+        N_("Control Group"),
+        N_("Unit"),
+        N_("Session"),
+        /* TRANSLATORS: Seat = i.e. the physical seat the session of the process belongs to, only
+	for multi-seat environments. See http://en.wikipedia.org/wiki/Multiseat_configuration */
+        N_("Seat"),
+        N_("Owner"),
+        N_("Disk Read Total"),
+        N_("Disk Write Total"),
+        N_("Disk Read"),
+        N_("Disk Write"),
+        N_("Priority"),
+        NULL,
+        "POINTER"
+    };
+
+    gint i;
+
+    model = gtk_tree_store_new (NUM_COLUMNS,
+                                G_TYPE_STRING,              /* Process Name */
+                                G_TYPE_STRING,              /* User         */
+                                G_TYPE_UINT,                /* Status       */
+                                G_TYPE_ULONG,               /* VM Size      */
+                                G_TYPE_ULONG,               /* Resident Memory */
+                                G_TYPE_ULONG,               /* Writable Memory */
+                                G_TYPE_ULONG,               /* Shared Memory */
+                                G_TYPE_ULONG,               /* X Server Memory */
+                                G_TYPE_UINT,                /* % CPU        */
+                                G_TYPE_UINT64,              /* CPU time     */
+                                G_TYPE_ULONG,               /* Started      */
+                                G_TYPE_INT,                 /* Nice         */
+                                G_TYPE_UINT,                /* ID           */
+                                G_TYPE_STRING,              /* Security Context */
+                                G_TYPE_STRING,              /* Arguments    */
+                                G_TYPE_ULONG,               /* Memory       */
+                                G_TYPE_STRING,              /* wchan        */
+                                G_TYPE_STRING,              /* Cgroup       */
+                                G_TYPE_STRING,              /* Unit         */
+                                G_TYPE_STRING,              /* Session      */
+                                G_TYPE_STRING,              /* Seat         */
+                                G_TYPE_STRING,              /* Owner        */
+                                G_TYPE_UINT64,              /* Disk read total */
+                                G_TYPE_UINT64,              /* Disk write total*/
+                                G_TYPE_UINT64,              /* Disk read    */
+                                G_TYPE_UINT64,              /* Disk write   */
+                                G_TYPE_STRING,              /* Priority     */
+                                CAIRO_GOBJECT_TYPE_SURFACE, /* Icon         */
+                                G_TYPE_POINTER,             /* ProcInfo     */
+                                G_TYPE_STRING               /* Sexy tooltip */
+        );
+
+    proctree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (proctree), COL_TOOLTIP);
+    g_object_set(G_OBJECT(proctree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+    gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (proctree),
+                                         search_equal_func,
+                                         NULL,
+                                         NULL);
+    g_object_unref (G_OBJECT (model));
+
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree));
+    gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+
+    column = gtk_tree_view_column_new ();
+
+    cell_renderer = gtk_cell_renderer_pixbuf_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "surface", COL_SURFACE,
+                                         NULL);
+
+    cell_renderer = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "text", COL_NAME,
+                                         NULL);
+    gtk_tree_view_column_set_title (column, _(titles[0]));
+    gtk_tree_view_column_set_sort_column_id (column, COL_NAME);
+    gtk_tree_view_column_set_resizable (column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+    gtk_tree_view_column_set_min_width (column, 20);
+    gtk_tree_view_column_set_reorderable (column, TRUE);
+    g_signal_connect(G_OBJECT(column), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (proctree), column);
+    gtk_tree_view_set_expander_column (GTK_TREE_VIEW (proctree), column);
+
+
+    for (i = COL_USER; i <= COL_PRIORITY; i++) {
+
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+#ifndef HAVE_WNCK
+        if (i == COL_MEMXSERVER) {
+          continue;
+        }
+#endif
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(proctree), col);
+
+        // type
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_CPU_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::duration_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_START_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::time_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_STATUS:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::status_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::io_rate_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_PRIORITY:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::priority_cell_data_func,
+                                                        GUINT_TO_POINTER(COL_NICE),
+                                                        NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+        }
+
+        // sorting
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+            case COL_CPU:
+            case COL_CPU_TIME:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_START_TIME:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::number_compare_func, GUINT_TO_POINTER(i),
+                                                NULL);
+                break;
+            case COL_PRIORITY:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::priority_compare_func,
+                                                GUINT_TO_POINTER(COL_NICE), NULL);
+                break;
+            default:
+                break;
+        }
+
+        // xalign
+        switch(i)
+        {
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMWRITABLE:
+            case COL_MEMSHARED:
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_CPU:
+            case COL_NICE:
+            case COL_PID:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_CPU_TIME:
+            case COL_MEM:
+                g_object_set(G_OBJECT(cell), "xalign", 1.0f, NULL);
+                break;
+        }
+
+        // sizing
+        switch (i) {
+            case COL_ARGS:
+                gtk_tree_view_column_set_min_width(col, 150);
+                break;
+            default:
+                gtk_tree_view_column_set_min_width(col, 20);
+                break;
+        }
+    }
+
+    procdata->tree = proctree;
+
+    procman_get_tree_state (procdata->settings, proctree, "proctree");
+
+    /* Override column settings by hiding this column if it's meaningless: */
+    if (!can_show_security_context_column ()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id (GTK_TREE_VIEW (proctree), COL_SECURITYCONTEXT);
+        gtk_tree_view_column_set_visible (column, FALSE);
+    }
+
+    if (!cgroups_enabled()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), COL_CGROUP);
+        gtk_tree_view_column_set_visible(column, FALSE);
+    }
+
+#ifdef HAVE_SYSTEMD
+    if (!LOGIND_RUNNING())
+#endif
+    {
+        for (i = COL_UNIT; i <= COL_OWNER; i++) {
+            column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), i);
+            gtk_tree_view_column_set_visible(column, FALSE);
+        }
+    }
+
+    g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree))),
+                      "changed",
+                      G_CALLBACK (cb_row_selected), procdata);
+    g_signal_connect (G_OBJECT (proctree), "popup_menu",
+                      G_CALLBACK (cb_tree_popup_menu), procdata);
+    g_signal_connect (G_OBJECT (proctree), "button_press_event",
+                      G_CALLBACK (cb_tree_button_pressed), procdata);
+
+    g_signal_connect (G_OBJECT(proctree), "columns-changed",
+                      G_CALLBACK(cb_columns_changed), procdata);
+
+    g_signal_connect (G_OBJECT (model), "sort-column-changed",
+                      G_CALLBACK (cb_sort_changed), procdata);
+
+    return proctree;
+}
+
+
+ProcInfo::~ProcInfo()
+{
+    g_free(this->name);
+    g_free(this->tooltip);
+    g_free(this->arguments);
+    g_free(this->security_context);
+    g_free(this->cgroup_name);
+    g_free(this->unit);
+    g_free(this->session);
+    g_free(this->seat);
+    cairo_surface_destroy(this->surface);
+}
+
+
+static void
+get_process_name (ProcInfo *info,
+                  const gchar *cmd, const GStrv args)
+{
+    if (args) {
+        // look for /usr/bin/very_long_name
+        // and also /usr/bin/interpreter /usr/.../very_long_name
+        // which may have use prctl to alter 'cmd' name
+        for (int i = 0; i != 2 && args[i]; ++i) {
+            char* basename;
+            basename = g_path_get_basename(args[i]);
+
+            if (g_str_has_prefix(basename, cmd)) {
+                info->name = basename;
+                return;
+            }
+
+            g_free(basename);
+        }
+    }
+
+    info->name = g_strdup (cmd);
+}
+
+std::string
+ProcInfo::lookup_user(guint uid)
+{
+    typedef std::pair<ProcInfo::UserMap::iterator, bool> Pair;
+    ProcInfo::UserMap::value_type hint(uid, "");
+    Pair p(ProcInfo::users.insert(hint));
+
+    // procman_debug("User lookup for uid %u: %s", uid, (p.second ? "MISS" : "HIT"));
+
+    if (p.second) {
+        struct passwd* pwd;
+        pwd = getpwuid(uid);
+
+        if (pwd && pwd->pw_name)
+            p.first->second = pwd->pw_name;
+        else {
+            char username[16];
+            g_sprintf(username, "%u", uid);
+            p.first->second = username;
+        }
+    }
+
+    return p.first->second;
+}
+
+void
+ProcInfo::set_user(guint uid)
+{
+    if (G_LIKELY(this->uid == uid))
+        return;
+
+    this->uid = uid;
+    this->user = lookup_user(uid);
+}
+
+static void get_process_memory_writable(ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info(ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+
+static void
+update_info_mutable_cols(ProcInfo *info)
+{
+    ProcData * const procdata = ProcData::get_instance();
+    GtkTreeModel *model;
+    model = gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->tree));
+
+    using procman::tree_store_update;
+
+    tree_store_update(model, &info->node, COL_STATUS, info->status);
+    tree_store_update(model, &info->node, COL_USER, info->user.c_str());
+    tree_store_update(model, &info->node, COL_VMSIZE, info->vmsize);
+    tree_store_update(model, &info->node, COL_MEMRES, info->memres);
+    tree_store_update(model, &info->node, COL_MEMWRITABLE, info->memwritable);
+    tree_store_update(model, &info->node, COL_MEMSHARED, info->memshared);
+#ifdef HAVE_WNCK
+    tree_store_update(model, &info->node, COL_MEMXSERVER, info->memxserver);
+#endif
+    tree_store_update(model, &info->node, COL_CPU, info->pcpu);
+    tree_store_update(model, &info->node, COL_CPU_TIME, info->cpu_time);
+    tree_store_update(model, &info->node, COL_DISK_READ_TOTAL, info->disk_read_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_TOTAL, info->disk_write_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_READ_CURRENT, info->disk_read_bytes_current);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_CURRENT, info->disk_write_bytes_current);
+    tree_store_update(model, &info->node, COL_START_TIME, info->start_time);
+    tree_store_update(model, &info->node, COL_NICE, info->nice);
+    tree_store_update(model, &info->node, COL_MEM, info->mem);
+    tree_store_update(model, &info->node, COL_WCHAN, info->wchan);
+    tree_store_update(model, &info->node, COL_CGROUP, info->cgroup_name);
+    tree_store_update(model, &info->node, COL_UNIT, info->unit);
+    tree_store_update(model, &info->node, COL_SESSION, info->session);
+    tree_store_update(model, &info->node, COL_SEAT, info->seat);
+    tree_store_update(model, &info->node, COL_OWNER, info->owner.c_str());
+}
+
+
+
+static void
+insert_info_to_tree (ProcInfo *info, ProcData *procdata, bool forced = false)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    if (procdata->config.show_tree) {
+
+        ProcInfo *parent = 0;
+
+        if (not forced)
+            parent = ProcInfo::find(info->ppid);
+
+        if (parent) {
+            GtkTreePath *parent_node = gtk_tree_model_get_path(model, &parent->node);
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, &parent->node, 0);
+
+            if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(procdata->tree), parent_node)
+#ifdef __linux__
+                // on linuxes we don't want to expand kthreadd by default (always has pid 2)
+                && (parent->pid != 2)
+#endif
+            )
+                gtk_tree_view_expand_row(GTK_TREE_VIEW(procdata->tree), parent_node, FALSE);
+            gtk_tree_path_free(parent_node);
+        } else
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, NULL, 0);
+    }
+    else
+        gtk_tree_store_insert (GTK_TREE_STORE (model), &info->node, NULL, 0);
+
+    gtk_tree_store_set (GTK_TREE_STORE (model), &info->node,
+                        COL_POINTER, info,
+                        COL_NAME, info->name,
+                        COL_ARGS, info->arguments,
+                        COL_TOOLTIP, info->tooltip,
+                        COL_PID, info->pid,
+                        COL_SECURITYCONTEXT, info->security_context,
+                        -1);
+
+    procdata->pretty_table.set_icon(*info);
+
+    procman_debug("inserted %d%s", info->pid, (forced ? " (forced)" : ""));
+}
+
+
+/* Removing a node with children - make sure the children are queued
+** to be readded.
+*/
+template<typename List>
+static void
+remove_info_from_tree (ProcData *procdata, GtkTreeModel *model,
+                       ProcInfo *current, List &orphans, unsigned lvl = 0)
+{
+    GtkTreeIter child_node;
+
+    if (std::find(orphans.begin(), orphans.end(), current) != orphans.end()) {
+        procman_debug("[%u] %d already removed from tree", lvl, int(current->pid));
+        return;
+    }
+
+    procman_debug("[%u] pid %d, %d children", lvl, int(current->pid),
+                  gtk_tree_model_iter_n_children(model, &current->node));
+
+    // it is not possible to iterate&erase over a treeview so instead we
+    // just pop one child after another and recursively remove it and
+    // its children
+
+    while (gtk_tree_model_iter_children(model, &child_node, &current->node)) {
+        ProcInfo *child = 0;
+        gtk_tree_model_get(model, &child_node, COL_POINTER, &child, -1);
+        remove_info_from_tree(procdata, model, child, orphans, lvl + 1);
+    }
+
+    g_assert(not gtk_tree_model_iter_has_child(model, &current->node));
+
+    if (procdata->selected_process == current)
+        procdata->selected_process = NULL;
+
+    orphans.push_back(current);
+    gtk_tree_store_remove(GTK_TREE_STORE(model), &current->node);
+    procman::poison(current->node, 0x69);
+}
+
+static void
+get_process_systemd_info(ProcInfo *info)
+{
+#ifdef HAVE_SYSTEMD
+    uid_t uid;
+
+    if (!LOGIND_RUNNING())
+        return;
+
+    free(info->unit);
+    info->unit = NULL;
+    sd_pid_get_unit(info->pid, &info->unit);
+
+    free(info->session);
+    info->session = NULL;
+    sd_pid_get_session(info->pid, &info->session);
+
+    free(info->seat);
+    info->seat = NULL;
+
+    if (info->session != NULL)
+        sd_session_get_seat(info->session, &info->seat);
+
+    if (sd_pid_get_owner_uid(info->pid, &uid) >= 0)
+        info->owner = info->lookup_user(uid);
+    else
+        info->owner = "";
+#endif
+}
+
+static void
+update_info (ProcData *procdata, ProcInfo *info)
+{
+    glibtop_proc_state procstate;
+    glibtop_proc_uid procuid;
+    glibtop_proc_time proctime;
+    glibtop_proc_kernel prockernel;
+    glibtop_proc_io procio;
+
+    glibtop_get_proc_kernel(&prockernel, info->pid);
+    g_strlcpy(info->wchan, prockernel.wchan, sizeof info->wchan);
+
+    glibtop_get_proc_state (&procstate, info->pid);
+    info->status = procstate.state;
+
+    glibtop_get_proc_uid (&procuid, info->pid);
+    glibtop_get_proc_time (&proctime, info->pid);
+    glibtop_get_proc_io (&procio, info->pid);
+
+    get_process_memory_info(info);
+
+    info->set_user(procstate.uid);
+
+    // if the cpu time has increased reset the status to running
+    // regardless of kernel state (https://bugzilla.gnome.org/606579)
+    guint64 difference = proctime.rtime - info->cpu_time;
+    if (difference > 0)
+        info->status = GLIBTOP_PROCESS_RUNNING;
+    info->pcpu = difference * 100 / procdata->cpu_total_time;
+    info->pcpu = MIN(info->pcpu, 100);
+
+    if (not procdata->config.solaris_mode)
+      info->pcpu *= procdata->config.num_cpus;
+
+    ProcInfo::cpu_times[info->pid] = info->cpu_time = proctime.rtime;
+    info->nice = procuid.nice;
+
+    gdouble update_interval_seconds = procdata->config.update_interval / 1000.0;
+    difference = procio.disk_wbytes - info->disk_write_bytes_total;
+    info->disk_write_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+    difference = procio.disk_rbytes - info->disk_read_bytes_total;
+    info->disk_read_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+
+    info->disk_write_bytes_total = procio.disk_wbytes;
+    info->disk_read_bytes_total = procio.disk_rbytes;
+
+    // set the ppid only if one can exist
+    // i.e. pid=0 can never have a parent
+    if (info->pid > 0) {
+        info->ppid = procuid.ppid;
+    }
+
+    g_assert(info->pid != info->ppid);
+    g_assert(info->ppid != -1 || info->pid == 0);
+
+    /* get cgroup data */
+    get_process_cgroup_info(info);
+
+    get_process_systemd_info(info);
+}
+
+
+ProcInfo::ProcInfo(pid_t pid)
+    : node(),
+      surface(),
+      tooltip(NULL),
+      name(NULL),
+      arguments(NULL),
+      security_context(NULL),
+      pid(pid),
+      ppid(-1),
+      uid(-1)
+{
+    ProcInfo * const info = this;
+    glibtop_proc_state procstate;
+    glibtop_proc_time proctime;
+    glibtop_proc_args procargs;
+    gchar** arguments;<--- Shadow variable
+
+    glibtop_get_proc_state (&procstate, pid);
+    glibtop_get_proc_time (&proctime, pid);
+    arguments = glibtop_get_proc_argv (&procargs, pid, 0);
+
+    /* FIXME : wrong. name and arguments may change with exec* */
+    get_process_name (info, procstate.cmd, static_cast<const GStrv>(arguments));
+
+    std::string tooltip = make_string(g_strjoinv(" ", arguments));<--- Shadow variable
+    if (tooltip.empty())
+        tooltip = procstate.cmd;
+
+    info->tooltip = g_markup_escape_text(tooltip.c_str(), -1);
+
+    info->arguments = g_strescape(tooltip.c_str(), "\\\"");
+    g_strfreev(arguments);
+
+    guint64 cpu_time = proctime.rtime;
+    std::map<pid_t, guint64>::iterator it(ProcInfo::cpu_times.find(pid));
+    if (it != ProcInfo::cpu_times.end())
+    {
+        if (proctime.rtime >= it->second)
+          cpu_time = it->second;
+    }
+    info->cpu_time = cpu_time;
+    info->start_time = proctime.start_time;
+
+    get_process_selinux_context (info);
+    info->cgroup_name = NULL;
+    get_process_cgroup_info(info);
+
+    info->unit = info->session = info->seat = NULL;
+    get_process_systemd_info(info);
+}
+
+static void
+refresh_list (ProcData *procdata, const pid_t* pid_list, const guint n)
+{
+    typedef std::list<ProcInfo*> ProcList;
+    ProcList addition;
+
+    GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+    guint i;
+
+    // Add or update processes in the process list
+    for(i = 0; i < n; ++i) {
+        ProcInfo *info = ProcInfo::find(pid_list[i]);
+
+        if (!info) {
+            info = new ProcInfo(pid_list[i]);
+            ProcInfo::all[info->pid] = info;
+            addition.push_back(info);
+        }
+
+        update_info (procdata, info);
+    }
+
+
+    // Remove dead processes from the process list and from the
+    // tree. children are queued to be readded at the right place
+    // in the tree.
+
+    const std::set<pid_t> pids(pid_list, pid_list + n);
+
+    ProcInfo::Iterator it(ProcInfo::begin());<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration
+
+    while (it != ProcInfo::end()) {
+        ProcInfo * const info = it->second;
+        ProcInfo::Iterator next(it);
+        ++next;
+
+        if (pids.find(info->pid) == pids.end()) {
+            procman_debug("ripping %d", info->pid);
+            remove_info_from_tree(procdata, model, info, addition);
+            addition.remove(info);
+            ProcInfo::all.erase(it);
+            delete info;
+        }
+
+        it = next;
+    }
+
+    // INVARIANT
+    // pid_list == ProcInfo::all + addition
+
+
+    if (procdata->config.show_tree) {
+
+        // insert process in the tree. walk through the addition list
+        // (new process + process that have a new parent). This loop
+        // handles the dependencies because we cannot insert a process
+        // until its parent is in the tree.
+
+        std::set<pid_t> in_tree(pids);
+
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            in_tree.erase((*it)->pid);
+
+
+        while (not addition.empty()) {
+            procman_debug("looking for %d parents", int(addition.size()));
+            ProcList::iterator it(addition.begin());<--- Shadow variable
+
+            while (it != addition.end()) {
+                procman_debug("looking for %d's parent with ppid %d",
+                              int((*it)->pid), int((*it)->ppid));
+
+
+                // inserts the process in the treeview if :
+                // - it has no parent (ppid = -1),
+                //   ie it is for example the [kernel] on FreeBSD
+                // - it is init
+                // - its parent is already in tree
+                // - its parent is unreachable
+                //
+                // rounds == 2 means that addition contains processes with
+                // unreachable parents
+                //
+                // FIXME: this is broken if the unreachable parent becomes active
+                // i.e. it gets active or changes ower
+                // so we just clear the tree on __each__ update
+                // see proctable_update_list (ProcData * const procdata)
+
+
+                if ((*it)->ppid <= 0 or in_tree.find((*it)->ppid) != in_tree.end()) {
+                    insert_info_to_tree(*it, procdata);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ProcInfo *parent = ProcInfo::find((*it)->ppid);<--- Variable 'parent' can be declared as pointer to const
+                // if the parent is unreachable
+                if (not parent) {
+                    // or std::find(addition.begin(), addition.end(), parent) == addition.end()) {
+                    insert_info_to_tree(*it, procdata, true);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ++it;
+            }
+        }
+    }
+    else {
+        // don't care of the tree
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            insert_info_to_tree(*it, procdata);
+    }
+
+
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)<--- Shadow variable
+        update_info_mutable_cols(it->second);
+}
+
+
+static void
+proctable_update_list (ProcData * const procdata)
+{
+    pid_t* pid_list;
+    glibtop_proclist proclist;
+    glibtop_cpu cpu;
+    gint which, arg;
+    procman::SelectionMemento selection;
+
+    switch (procdata->config.whose_process) {
+        case ALL_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL;
+            arg = 0;
+            break;
+
+        case ACTIVE_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL | GLIBTOP_EXCLUDE_IDLE;
+            arg = 0;
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+
+        default:
+            which = GLIBTOP_KERN_PROC_UID;
+            arg = getuid ();
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+    }
+
+    pid_list = glibtop_get_proclist (&proclist, which, arg);
+
+    /* FIXME: total cpu time elapsed should be calculated on an individual basis here
+    ** should probably have a total_time_last gint in the ProcInfo structure */
+    glibtop_get_cpu (&cpu);
+    procdata->cpu_total_time = MAX(cpu.total - procdata->cpu_total_time_last, 1);
+    procdata->cpu_total_time_last = cpu.total;
+
+    // FIXME: not sure if glibtop always returns a sorted list of pid
+    // but it is important otherwise refresh_list won't find the parent
+    std::sort(pid_list, pid_list + proclist.number);
+
+    refresh_list (procdata, pid_list, proclist.number);
+
+    selection.restore(procdata->tree);
+
+    g_free (pid_list);
+
+    /* proclist.number == g_list_length(procdata->info) == g_hash_table_size(procdata->pids) */
+}
+
+
+void
+proctable_update (ProcData * const procdata)
+{
+    char* string;
+
+    string = make_loadavg_string();
+    gtk_label_set_text (GTK_LABEL(procdata->loadavg), string);
+    g_free (string);
+
+    proctable_update_list (procdata);
+}
+
+
+void
+proctable_free_table (ProcData * const procdata)
+{
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)
+        delete it->second;
+
+    ProcInfo::all.clear();
+}
+
+
+void
+proctable_clear_tree (ProcData * const procdata)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    gtk_tree_store_clear (GTK_TREE_STORE (model));
+
+    proctable_free_table (procdata);
+
+    update_sensitivity(procdata);
+}
+
+
+char*
+make_loadavg_string(void)
+{
+    glibtop_loadavg buf;
+
+    glibtop_get_loadavg(&buf);
+
+    return g_strdup_printf(
+        _("Load averages for the last 1, 5, 15 minutes: "
+          "%0.2f, %0.2f, %0.2f"),
+        buf.loadavg[0],
+        buf.loadavg[1],
+        buf.loadavg[2]);
+}
+
+
+
+void
+ProcInfo::set_icon(Glib::RefPtr<Gdk::Pixbuf> icon)
+{
+  this->surface = gdk_cairo_surface_create_from_pixbuf (icon->gobj(), 0, NULL);
+
+  GtkTreeModel *model;
+  model = gtk_tree_view_get_model(GTK_TREE_VIEW(ProcData::get_instance()->tree));
+  gtk_tree_store_set(GTK_TREE_STORE(model), &this->node,
+                     COL_SURFACE, this->surface,
+                    -1);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/43.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/43.html new file mode 100644 index 00000000..dc1ef059 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/43.html @@ -0,0 +1,279 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
#ifndef H_MATE_SYSTEM_MONITOR_SELECTION_H_1183113337
+#define H_MATE_SYSTEM_MONITOR_SELECTION_H_1183113337
+
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <vector><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+namespace procman
+{
+    class SelectionMemento
+    {
+        std::vector<pid_t> pids;
+        static void add_to_selected(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer data);
+
+    public:
+        void save(GtkWidget* tree);
+        void restore(GtkWidget* tree);
+    };
+}
+
+#endif /* H_MATE_SYSTEM_MONITOR_SELECTION_H_1183113337 */
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/44.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/44.html new file mode 100644 index 00000000..b0525da6 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/44.html @@ -0,0 +1,265 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
#ifndef PROCMAN_SELINUX_H_20050525
+#define PROCMAN_SELINUX_H_20050525
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+void
+get_process_selinux_context (ProcInfo *info);
+
+gboolean
+can_show_security_context_column (void) G_GNUC_CONST;
+
+#endif /* PROCMAN_SELINUX_H_20050525 */
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/45.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/45.html new file mode 100644 index 00000000..dc3f8198 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/45.html @@ -0,0 +1,323 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "selection.h"
+#include "proctable.h"
+#include "util.h"
+
+namespace procman
+{
+    void SelectionMemento::add_to_selected(GtkTreeModel* model, GtkTreePath*, GtkTreeIter* iter, gpointer data)
+    {
+        guint pid = 0;
+        gtk_tree_model_get(model, iter, COL_PID, &pid, -1);
+        if (pid)
+            static_cast<SelectionMemento*>(data)->pids.push_back(pid);
+    }
+
+
+    void SelectionMemento::save(GtkWidget* tree)
+    {
+        GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
+        gtk_tree_selection_selected_foreach(selection, &SelectionMemento::add_to_selected, this);
+    }
+
+
+    void SelectionMemento::restore(GtkWidget* tree)
+    {
+        if (not this->pids.empty())
+        {
+            GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
+            typedef std::vector<pid_t>::iterator iterator;
+            for (iterator it(this->pids.begin()); it != this->pids.end(); ++it)
+            {
+                if (ProcInfo* proc = ProcInfo::find(*it))
+                {
+                    gtk_tree_selection_select_iter(selection, &proc->node);
+                    procman_debug("Re-selected process %u", unsigned(*it));
+                }
+                else
+                    procman_debug("Could not find process %u, cannot re-select it", unsigned(*it));
+            }
+        }
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/46.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/46.html new file mode 100644 index 00000000..de751e8f --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/46.html @@ -0,0 +1,405 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "selinux.h"
+#include "procman.h"
+#include "util.h"
+
+
+static int (*getpidcon)(pid_t, char**);
+static void (*freecon)(char*);
+static int (*is_selinux_enabled)(void);
+
+static gboolean has_selinux;
+
+static gboolean load_selinux(void)
+{
+    return load_symbols("libselinux.so.1",
+                        "getpidcon", &getpidcon,
+                        "freecon", &freecon,
+                        "is_selinux_enabled", &is_selinux_enabled,
+                        NULL);
+}
+
+
+
+void
+get_process_selinux_context (ProcInfo *info)
+{
+    char *con;
+
+    if (has_selinux && !getpidcon (info->pid, &con)) {
+        info->security_context = g_strdup (con);
+        freecon (con);
+    }
+}
+
+
+
+gboolean
+can_show_security_context_column (void)
+{
+    if (!(has_selinux = load_selinux()))
+        return FALSE;
+
+    switch (is_selinux_enabled()) {
+        case 1:
+            /* We're running on an SELinux kernel */
+            return TRUE;
+
+        case -1:
+            /* Error; hide the security context column */
+
+        case 0:
+            /* We're not running on an SELinux kernel:
+               hide the security context column */
+
+        default:
+            g_warning("SELinux was found but is not enabled.\n");
+            return FALSE;
+    }
+}
+
+
+
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/47.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/47.html new file mode 100644 index 00000000..9b078f12 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/47.html @@ -0,0 +1,553 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/proctime.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <algorithm><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "smooth_refresh.h"
+#include "procman.h"
+#include "util.h"
+
+
+const string SmoothRefresh::KEY("smooth-refresh");
+
+
+unsigned SmoothRefresh::get_own_cpu_usage()
+{
+    glibtop_cpu cpu;
+    glibtop_proc_time proctime;
+    guint64 elapsed;
+    unsigned usage = PCPU_LO;
+
+    glibtop_get_cpu (&cpu);
+    elapsed = cpu.total - this->last_total_time;
+
+    if (elapsed) { // avoid division by 0
+        glibtop_get_proc_time(&proctime, getpid());
+        usage = (proctime.rtime - this->last_cpu_time) * 100 / elapsed;
+        this->last_cpu_time = proctime.rtime;
+    }
+
+    usage = MIN (usage, 100);
+
+    this->last_total_time = cpu.total;
+
+    return usage;
+}
+
+
+
+void SmoothRefresh::status_changed(GSettings *settings,
+                                   const gchar *key,
+                                   gpointer user_data)
+{
+    static_cast<SmoothRefresh*>(user_data)->load_settings_value(key);
+}
+
+void SmoothRefresh::load_settings_value(const gchar *key)
+{
+    this->active = g_settings_get_boolean(settings, key);
+
+    if (this->active)
+        procman_debug("smooth_refresh is enabled");
+}
+
+SmoothRefresh::SmoothRefresh(GSettings *a_settings)
+    :
+    settings(a_settings)
+{
+    this->connection = g_signal_connect(G_OBJECT(settings),
+                                        "changed::smooth-refresh",
+                                        G_CALLBACK(status_changed),
+                                        this);
+
+  this->reset();
+  this->load_settings_value(KEY.c_str());
+}
+
+
+
+void SmoothRefresh::reset()
+{
+    glibtop_cpu cpu;
+    glibtop_proc_time proctime;
+
+    glibtop_get_cpu(&cpu);
+    glibtop_get_proc_time(&proctime, getpid());
+
+    this->interval = ProcData::get_instance()->config.update_interval;
+    this->last_pcpu = PCPU_LO;
+    this->last_total_time = cpu.total;
+    this->last_cpu_time = proctime.rtime;
+}
+
+
+
+SmoothRefresh::~SmoothRefresh()
+{
+    if (this->connection)
+        g_signal_handler_disconnect(G_OBJECT(settings), this->connection);
+}
+
+
+
+bool
+SmoothRefresh::get(guint &new_interval)
+{
+    const unsigned config_interval = ProcData::get_instance()->config.update_interval;
+
+    g_assert(this->interval >= config_interval);
+
+    if (not this->active)
+        return false;
+
+
+    const unsigned pcpu = this->get_own_cpu_usage();
+    /*
+      invariant: MAX_UPDATE_INTERVAL >= interval >= config_interval >= MIN_UPDATE_INTERVAL
+
+      i see 3 cases:
+
+      a) interval is too big (CPU usage < 10%)
+      -> increase interval
+
+      b) interval is too small (CPU usage > 10%) AND interval != config_interval
+      >
+      -> decrease interval
+
+      c) interval is config_interval (start or interval is perfect)
+
+    */
+
+    if (pcpu > PCPU_HI && this->last_pcpu > PCPU_HI)
+        new_interval = this->interval * 11 / 10;
+    else if (this->interval != config_interval && pcpu < PCPU_LO && this->last_pcpu < PCPU_LO)
+        new_interval = this->interval * 9 / 10;
+    else
+        new_interval = this->interval;
+
+    new_interval = CLAMP(new_interval, config_interval, config_interval * 2);
+    new_interval = CLAMP(new_interval, MIN_UPDATE_INTERVAL, MAX_UPDATE_INTERVAL);
+
+    bool changed = this->interval != new_interval;
+
+    if (changed)
+        this->interval = new_interval;
+
+    this->last_pcpu = pcpu;
+
+
+    if (changed) {
+        procman_debug("CPU usage is %3u%%, changed refresh_interval to %u (config %u)",
+                      this->last_pcpu,
+                      this->interval,
+                      config_interval);
+    }
+
+    g_assert(this->interval == new_interval);
+    g_assert(this->interval >= config_interval);
+
+    return changed;
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/48.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/48.html new file mode 100644 index 00000000..cbae209f --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/48.html @@ -0,0 +1,2359 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <libxml/parser.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libxml/xpath.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libxml/xpathInternals.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibtop/fsusage.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mountlist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/sysinfo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <netdb.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/socket.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/wait.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <exception><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <vector><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <fstream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sstream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/utsname.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "sysinfo.h"
+#include "procman.h"
+#include "util.h"
+
+
+using std::string;
+using std::vector;
+
+
+namespace {
+
+    class SysInfo
+    {
+    public:
+        string hostname;
+        string distro_name;
+        string distro_release;
+        string kernel;
+        string mate_version;
+        guint64 memory_bytes;
+        guint64 free_space_bytes;
+
+        string graphics;
+        string processors;
+
+        SysInfo()
+        {
+            this->load_processors_info();
+            this->load_graphics_info();
+            this->load_memory_info();
+            this->load_disk_info();
+            this->load_uname_info();
+            this->load_mate_version();
+        }
+
+        virtual ~SysInfo()
+        { }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Virtual function in base class
+        {
+            g_object_set(G_OBJECT(name),
+                        "label",
+                        ("<big><big><b>" + this->distro_name + "</b></big></big>").c_str(),
+                        NULL);
+
+            char* markup;
+#ifdef __linux__
+            if (this->distro_release != "")
+            {
+                /* Translators: The first string parameter is release version (codename),
+                 * the second one is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("Release %s %s"),
+                                         this->distro_release.c_str(),
+                                         SysInfo::get_os_type().c_str());
+            }
+            else
+            {
+                /* Translators: The string parameter is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("%s Version"),
+                                         SysInfo::get_os_type().c_str());
+            }
+#else
+            /* Translators: The string parameter is release version (codename) */
+            markup = g_strdup_printf(_("Release %s"),
+                                     this->distro_release.c_str());
+#endif
+
+            g_object_set(G_OBJECT(release),
+                         "label",
+                         markup,
+                         NULL);
+
+            g_free(markup);
+        }
+
+        static string release()
+        {
+            return uname().release;
+        }
+
+        static string system()
+        {
+            return uname().sysname;
+        }
+
+    private:
+
+        void load_memory_info()
+        {
+            glibtop_mem mem;
+
+            glibtop_get_mem(&mem);
+            this->memory_bytes = mem.total;
+        }
+
+        static string get_os_type ()<--- Unused private function: 'SysInfo::get_os_type'
+        {
+            int bits;
+
+            if (GLIB_SIZEOF_VOID_P == 8)
+                bits = 64;
+            else
+                bits = 32;
+
+            /* translators: This is the type of architecture, for example:
+             * "64-bit" or "32-bit" */
+            char* bytes = g_strdup_printf (_("%d-bit"), bits);
+            string retval(bytes);
+            g_free(bytes);
+            return retval;
+        }
+
+        typedef struct
+        {
+            const char* regex;
+            const char* replacement;
+        } ReplaceStrings;
+
+        static char* remove_duplicate_whitespace (const char* old)
+        {
+            char* result;
+            GRegex* re;
+            GError* error = NULL;
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+
+            re = g_regex_new ("[ \t\n\r]+", G_REGEX_MULTILINE, flags, &error);
+            if (re == NULL) {
+                g_warning ("Error building regex: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+            result = g_regex_replace (re, old, -1, 0, " ", flags, &error);
+            g_regex_unref (re);
+            if (result == NULL) {
+                g_warning ("Error replacing string: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+
+            return result;
+        }
+
+        static char* prettify_info (const char *info)
+        {
+            char* pretty;
+            const GRegexCompileFlags cflags = static_cast<GRegexCompileFlags>(0);
+            const GRegexMatchFlags mflags = static_cast<GRegexMatchFlags>(0);
+
+            static const ReplaceStrings rs[] = {
+                { "Intel[(]R[)]", "Intel\302\256"},
+                { "Core[(]TM[)]", "Core\342\204\242"},
+                { "Atom[(]TM[)]", "Atom\342\204\242"},
+            };
+
+            pretty = g_markup_escape_text (info, -1);
+
+            for (uint i = 0; i < G_N_ELEMENTS (rs); i++) {
+                GError* error;
+                GRegex* re;
+                char* result;
+
+                error = NULL;
+
+                re = g_regex_new (rs[i].regex, cflags, mflags, &error);
+                if (re == NULL) {
+                    g_warning ("Error building regex: %s", error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                result = g_regex_replace_literal (re, pretty, -1, 0,
+                                             rs[i].replacement, mflags, &error);
+
+                g_regex_unref (re);
+
+                if (error != NULL) {
+                    g_warning ("Error replacing %s: %s", rs[i].regex, error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                g_free (pretty);
+                pretty = result;
+            }
+
+            return pretty;
+        }
+
+        static char* get_renderer_from_helper (gboolean discrete_gpu)
+        {
+            int status;
+            const char *argv[] = { LIBEXECDIR "/mate-session-check-accelerated", NULL };
+            g_auto(GStrv) envp = NULL;
+            g_autofree char *renderer = NULL;
+            g_autoptr(GError) error = NULL;
+
+            if (discrete_gpu)
+            {
+                envp = g_get_environ ();
+                envp = g_environ_setenv (envp, "DRI_PRIME", "1", TRUE);
+            }
+
+            if (!g_spawn_sync (NULL, (char **) argv, envp, G_SPAWN_DEFAULT, NULL, NULL, &renderer, NULL, &status, &error))
+            {
+                g_debug ("Failed to get %s GPU: %s",
+                         discrete_gpu ? "discrete" : "integrated",
+                         error->message);
+                return NULL;
+            }
+
+            if (!g_spawn_check_exit_status (status, NULL))
+                return NULL;
+
+            if (renderer == NULL || *renderer == '\0')
+                return NULL;
+
+            return prettify_info (renderer);
+        }
+
+
+        void load_graphics_info()
+        {
+            g_autofree char *renderer = NULL;
+
+            try
+            {
+                g_autoptr(GDBusProxy) session_proxy = NULL;
+                g_autoptr(GVariant) renderer_variant = NULL;
+                g_autoptr(GError) error = NULL;
+
+                session_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                               G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL,
+                                                               "org.gnome.SessionManager",
+                                                               "/org/gnome/SessionManager",
+                                                               "org.gnome.SessionManager",
+                                                               NULL, &error);
+                if (error != NULL)
+                {
+                    throw std::runtime_error ("Unable to connect to create a proxy for org.gnome.SessionManager");
+                }
+
+                renderer_variant = g_dbus_proxy_get_cached_property (session_proxy, "Renderer");
+                if (!renderer_variant)
+                {
+                    throw std::runtime_error ("Unable to retrieve org.gnome.SessionManager.Renderer property.");
+                }
+
+                renderer = prettify_info (g_variant_get_string (renderer_variant, NULL));
+            }
+            catch (std::exception& e)
+            {
+                g_warning ("%s", e.what());
+            }
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (FALSE);
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (TRUE);
+
+            if (renderer)
+            {
+                this->graphics = g_strdup (renderer);
+            }
+            else
+            {
+                this->graphics = _("Unknown");
+            }
+        }
+
+        void load_processors_info()
+        {
+            const glibtop_sysinfo *info = glibtop_get_sysinfo();
+
+            GHashTable* counts;
+            GString* cpu;
+            GHashTableIter iter;
+            gpointer key, value;
+
+            counts = g_hash_table_new (g_str_hash, g_str_equal);
+
+            /* count duplicates */
+            for (uint i = 0; i != info->ncpu; ++i) {
+                const char* const keys[] = { "model name", "cpu", "Processor" };
+                char* model;
+                int* count;
+
+                model = NULL;
+
+                for (int j = 0; model == NULL && j != G_N_ELEMENTS (keys); ++j) {
+                    model = static_cast<char*>(g_hash_table_lookup (info->cpuinfo[i].values,
+                                                 keys[j]));
+                }
+
+                if (model == NULL)
+                    continue;
+
+                count = static_cast<int*>(g_hash_table_lookup (counts, model));
+                if (count == NULL)
+                    g_hash_table_insert (counts, model, GINT_TO_POINTER (1));
+                else
+                    g_hash_table_replace (counts, model, GINT_TO_POINTER (GPOINTER_TO_INT (count) + 1));
+            }
+
+            cpu = g_string_new (NULL);
+            g_hash_table_iter_init (&iter, counts);
+            while (g_hash_table_iter_next (&iter, &key, &value)) {
+                char* stripped;
+                int   count;
+
+                count = GPOINTER_TO_INT (value);
+                stripped = remove_duplicate_whitespace ((const char *)key);
+                if (count > 1)
+                    g_string_append_printf (cpu, "%s \303\227 %d ", stripped, count);
+                else
+                    g_string_append_printf (cpu, "%s ", stripped);
+                g_free (stripped);
+            }
+
+            g_hash_table_destroy (counts);
+            this->processors = string(prettify_info (cpu->str));
+            g_string_free (cpu, TRUE);
+        }
+
+        void load_disk_info()
+        {
+            GHashTable *devices;
+            glibtop_mountentry *entries;
+            glibtop_mountlist mountlist;
+
+            entries = glibtop_get_mountlist(&mountlist, 0);
+            devices = g_hash_table_new(g_str_hash, g_str_equal);
+            this->free_space_bytes = 0;
+
+            for (guint i = 0; i != mountlist.number; ++i) {
+                if ((string(entries[i].mountdir).compare("/") == 0) && \
+                    (string(entries[i].type).compare("zfs") == 0)) {
+                    // Root filesystem is ZFS based: Calculate usage based on "/".
+                    glibtop_fsusage usage;
+                    glibtop_get_fsusage(&usage, "/");
+                    this->free_space_bytes = usage.bavail * usage.block_size;
+                    break;
+                }
+
+                if (string(entries[i].devname).find("/dev/") != 0)
+                    continue;
+
+                if (string(entries[i].mountdir).find("/media/") == 0)
+                    continue;
+
+                /* avoid adding a device more than once such as for btrfs filesystem */
+                if (g_hash_table_contains (devices, entries[i].devname))
+                    continue;
+                else
+                    g_hash_table_insert (devices, entries[i].devname, entries[i].mountdir);
+
+                glibtop_fsusage usage;
+                glibtop_get_fsusage(&usage, entries[i].mountdir);
+                this->free_space_bytes += usage.bavail * usage.block_size;
+            }
+
+            g_hash_table_destroy (devices);
+            g_free(entries);
+        }
+
+        static const struct utsname & uname()
+        {
+            static struct utsname name;
+
+            if (!name.sysname[0]) {
+                ::uname(&name);
+            }
+
+            return name;
+        }
+
+        void load_uname_info()
+        {
+            this->hostname = uname().nodename;
+#if defined(__linux__)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().machine;
+#elif defined(__sun) && defined(__SVR4)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().version + ' ' + uname().machine;
+#else
+            this->kernel = string(uname().version) + ' ' + uname().machine;
+#endif
+        }
+
+
+        void load_mate_version()
+        {
+            xmlDocPtr document;
+            xmlXPathContextPtr context;
+            const string nodes[3] = { "string(/mate-version/platform)",
+                                      "string(/mate-version/minor)",
+                                      "string(/mate-version/micro)" };
+            string values[3];
+
+            if (not (document = xmlParseFile(DATADIR "/mate-about/mate-version.xml")))
+                return;
+
+            if (not (context = xmlXPathNewContext(document)))
+                return;
+
+            for (size_t i = 0; i != 3; ++i)
+            {
+                xmlXPathObjectPtr xpath;
+                xpath = xmlXPathEvalExpression(BAD_CAST nodes[i].c_str(), context);
+
+                if (xpath and xpath->type == XPATH_STRING)
+                    values[i] = reinterpret_cast<const char*>(xpath->stringval);
+
+                xmlXPathFreeObject(xpath);
+            }
+
+            xmlXPathFreeContext(context);
+            xmlFreeDoc(document);
+
+            if (!values[0].empty() && !values[1].empty() && !values[2].empty())
+                this->mate_version = values[0] + '.' + values[1] + '.' + values[2];
+        }
+    };
+
+    class FreeBSDSysInfo
+        : public SysInfo
+    {
+    public:
+	FreeBSDSysInfo()
+        {
+            this->load_freebsd_info();
+        }
+
+    private:
+        void load_freebsd_info()
+        {
+            this->distro_name = "FreeBSD";
+            this->distro_release = release();
+        }
+    };
+
+    class SolarisSysInfo
+        : public SysInfo
+    {
+    public:
+        SolarisSysInfo()
+        {
+            this->load_solaris_info();
+        }
+
+    private:
+        void load_solaris_info()
+        {
+            std::ifstream input("/etc/release");
+
+            if (input) {
+                std::string s;
+                std::getline(input, s);
+                std::size_t found = s.find("OpenIndiana ");
+                if (found!=std::string::npos) {
+                    this->distro_name = "OpenIndiana";
+                    this->distro_release = s.substr(found + strlen("OpenIndiana "));
+                } else if (!s.empty()) {
+                    this->distro_release = s;
+                }
+            }
+
+            if (this->distro_release.empty()) {
+                this->distro_name = "Solaris";
+            }
+        }
+    };
+
+
+    class LSBSysInfo
+        : public SysInfo
+    {
+    public:
+        LSBSysInfo()
+            : re(Glib::Regex::create("^.+?:\\s*(.+)\\s*$"))
+        {
+            // start();
+        }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Function in derived class
+        {
+            this->name = name;
+            this->release = release;
+
+            this->start();
+        }
+
+
+    private:
+
+        sigc::connection child_watch;
+        int lsb_fd;
+        GtkWidget* name;
+        GtkWidget* release;<--- Shadowed declaration<--- Shadowed declaration
+
+        void strip_description(string &s) const
+        {
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+            GMatchInfo* info = 0;
+
+           if (g_regex_match(this->re->gobj(), s.c_str(), flags, &info)) {
+               s = make_string(g_match_info_fetch(info, 1));
+               g_match_info_free(info);
+           }
+        }
+
+        std::istream& get_value(std::istream &is, string &s) const
+        {
+            if (std::getline(is, s))
+                this->strip_description(s);
+            return is;
+        }
+
+
+        void read_lsb(Glib::Pid pid, int status)
+        {
+            this->child_watch.disconnect();
+
+            if (!WIFEXITED(status) or WEXITSTATUS(status) != 0) {
+                g_error("Child %d failed with status %d", int(pid), status);
+                return;
+            }
+
+            Glib::RefPtr<Glib::IOChannel> channel = Glib::IOChannel::create_from_fd(this->lsb_fd);
+            Glib::ustring content;
+
+            while (channel->read_to_end(content) == Glib::IO_STATUS_AGAIN)
+                ;
+
+            channel->close();
+            Glib::spawn_close_pid(pid);
+
+            procman_debug("lsb_release output = '%s'", content.c_str());
+
+            string release, codename;<--- Shadow variable
+            std::istringstream input(content);
+
+            this->get_value(input, this->distro_name)
+                and this->get_value(input, release)
+                and this->get_value(input, codename);
+
+            this->distro_release = release;
+            if (codename != "" && codename != "n/a")
+                this->distro_release += " (" + codename + ')';
+
+            this->SysInfo::set_distro_labels(this->name, this->release);
+        }
+
+
+        void start()
+        {
+            std::vector<string> argv(2);
+            argv[0] = "lsb_release";
+            argv[1] = "-irc";
+
+            Glib::SpawnFlags flags = Glib::SPAWN_DO_NOT_REAP_CHILD
+                | Glib::SPAWN_SEARCH_PATH
+                | Glib::SPAWN_STDERR_TO_DEV_NULL;
+
+            Glib::Pid child;
+
+            try {
+                Glib::spawn_async_with_pipes("/", // wd
+                                             argv,
+                                             flags,
+                                             sigc::slot<void>(), // child setup
+                                             &child,
+                                             0, // stdin
+                                             &this->lsb_fd); // stdout
+            } catch (Glib::SpawnError &e) {
+                g_error("g_spawn_async_with_pipes error: %s", e.what().c_str());
+                return;
+            }
+
+            sigc::slot<void,GPid, int> slot = sigc::mem_fun(this, &LSBSysInfo::read_lsb);
+            this->child_watch = Glib::signal_child_watch().connect(slot, child);
+        }
+
+
+        void sync_lsb_release()<--- Unused private function: 'LSBSysInfo::sync_lsb_release'
+        {
+            char *out= 0;
+            GError *error = 0;
+            int status;
+
+            if (g_spawn_command_line_sync("lsb_release -irc",
+                                          &out,
+                                          0,
+                                          &status,
+                                          &error)) {
+                string release, codename;<--- Shadow variable
+                if (!error and WIFEXITED(status) and WEXITSTATUS(status) == 0) {
+                    std::istringstream input(out);
+                    this->get_value(input, this->distro_name)
+                        and this->get_value(input, release)
+                        and this->get_value(input, codename);
+                    this->distro_release = release;
+                if (codename != "" && codename != "n/a")
+                    this->distro_release += " (" + codename + ')';
+                }
+            }
+
+            if (error)
+                g_error_free(error);
+
+            g_free(out);
+        }
+
+    private:
+        Glib::RefPtr<Glib::Regex> re;
+    };
+
+
+    class NetBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        NetBSDSysInfo()
+        {
+            this->load_netbsd_info();
+        }
+
+    private:
+        void load_netbsd_info()
+        {
+            this->distro_name = "NetBSD";
+
+            std::ifstream input("/etc/release");
+
+            if (input)
+                std::getline(input, this->distro_release);
+        }
+    };
+
+
+    class GenericSysInfo
+        : public SysInfo
+    {
+    public:
+        GenericSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            std::ifstream input("/etc/os-release");
+
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int start;
+                    std::getline(input, s);
+                    if (s.find("NAME=") == 0) {
+                        start = strlen("NAME=");
+                        if ((s.at(start) == '\"') && (s.at(s.size() - 1) == '\"')) {
+                            this->distro_name = s.substr(start + 1, s.size() - start - 2);
+                        } else {
+                            this->distro_name = s.substr(start);
+                        }
+                    } else if (s.find("VERSION=") == 0) {
+                        start = strlen("VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    } else if (s.find("# VERSION=") == 0) {
+                        start = strlen("# VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    }
+                }
+                input.close();
+                input.clear();
+            }
+            if (this->distro_release.empty()) {
+                input.open("/etc/debian_version");
+                if (input) {
+                    getline(input, this->distro_release);
+                }
+            }
+        }
+    };
+
+    class MintSysInfo
+        : public SysInfo
+    {
+    public:
+        MintSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            this->distro_name = "Linux Mint";
+            std::ifstream input("/etc/linuxmint/info");
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int len;
+                    std::getline(input, s);
+                    if (s.find("DESCRIPTION=") == 0) {
+                        len = strlen("DESCRIPTION=");
+                        // also strip the surrounding quotes
+                       this->distro_release = s.substr(len + 1, s.size() - len - 2);
+                   }
+                }
+            }
+        }
+    };
+
+    class OpenBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        OpenBSDSysInfo()
+        {
+            this->load_openbsd_info();
+        }
+
+    private:
+        void load_openbsd_info()
+        {
+            this->distro_name = "OpenBSD";
+            this->distro_release = this->kernel;
+
+            std::ifstream input("/etc/motd");
+
+            if (input)
+                std::getline(input, this->kernel);
+        }
+    };
+
+    SysInfo* get_sysinfo()
+    {
+        if (g_file_test ("/etc/linuxmint/info", G_FILE_TEST_EXISTS)) {
+            return new MintSysInfo;
+        }
+        else if (g_file_test ("/etc/os-release", G_FILE_TEST_EXISTS)) {
+            return new GenericSysInfo;
+        }
+        else if (char *p = g_find_program_in_path("lsb_release")) {
+            g_free(p);
+            return new LSBSysInfo;
+        }
+        else if (SysInfo::system() == "FreeBSD") {
+            return new FreeBSDSysInfo;
+        }
+        else if (SysInfo::system() == "SunOS") {
+            return new SolarisSysInfo;
+        }
+        else if (SysInfo::system() == "NetBSD") {
+            return new NetBSDSysInfo;
+        }
+        else if (SysInfo::system() == "OpenBSD") {
+            return new OpenBSDSysInfo;
+        }
+
+        return new SysInfo;
+    }
+}
+
+
+#define X_PAD  0
+#define Y_PAD  0
+#define LOGO_W 92
+#define LOGO_H 351
+#define RADIUS 5
+
+static gboolean sysinfo_logo_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    GtkStyle *style;
+    cairo_t *cr;
+    cairo_pattern_t *cp;
+
+    cr = gdk_cairo_create(gtk_widget_get_window(widget));
+
+    gtk_widget_get_allocation (widget, &allocation);
+    cairo_translate(cr, allocation.x, allocation.y);
+
+    cairo_move_to(cr, X_PAD + RADIUS, Y_PAD);
+    cairo_line_to(cr, X_PAD + LOGO_W - RADIUS, Y_PAD);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + RADIUS, RADIUS, -0.5 * M_PI, 0);
+    cairo_line_to(cr, X_PAD + LOGO_W, Y_PAD + LOGO_H - RADIUS);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0, 0.5 * M_PI);
+    cairo_line_to(cr, X_PAD + RADIUS, Y_PAD + LOGO_H);
+    cairo_arc(cr, X_PAD + RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0.5 * M_PI, -1.0 * M_PI);
+    cairo_line_to(cr, X_PAD, Y_PAD + RADIUS);
+    cairo_arc(cr,  X_PAD + RADIUS, Y_PAD + RADIUS, RADIUS, -1.0 * M_PI, -0.5 * M_PI);
+
+    cp = cairo_pattern_create_linear(0, Y_PAD, 0, Y_PAD + LOGO_H);
+    style = gtk_widget_get_style (widget);
+    cairo_pattern_add_color_stop_rgba(cp, 0.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      1.0);
+    cairo_pattern_add_color_stop_rgba(cp, 1.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      0.0);
+    cairo_set_source(cr, cp);
+    cairo_fill(cr);
+
+    cairo_pattern_destroy(cp);
+    cairo_destroy(cr);
+
+    return FALSE;
+}
+
+static GtkWidget*
+add_section(GtkBox *vbox , const char * title, int num_row, int num_col, GtkWidget **out_frame)
+{
+    GtkWidget *table;
+
+    GtkWidget *frame = gtk_frame_new(title);
+    gtk_frame_set_label_align(GTK_FRAME(frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
+
+    table = gtk_grid_new();
+    gtk_grid_set_row_spacing(GTK_GRID(table), 6);
+    gtk_grid_set_column_spacing(GTK_GRID(table), 6);
+    gtk_widget_set_margin_start (GTK_WIDGET(table), 12);
+    gtk_container_set_border_width(GTK_CONTAINER(table), 6);
+    gtk_container_add(GTK_CONTAINER(frame), table);
+
+    if(out_frame)
+        *out_frame = frame;
+
+    return table;
+}
+
+
+static GtkWidget*
+add_row(GtkGrid * table, const char * label, const char * value, int row)
+{
+    GtkWidget *header = gtk_label_new(NULL);
+    gtk_label_set_markup(GTK_LABEL(header), label);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        table, header,
+        0, row, 1, 1);
+
+    GtkWidget *label_widget = gtk_label_new(value);
+    gtk_label_set_selectable(GTK_LABEL(label_widget), TRUE);
+    gtk_widget_set_can_focus(label_widget, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (label_widget), 0.0);
+    gtk_grid_attach(
+        table, label_widget,
+        1, row, 1, 1);
+
+    return label_widget;
+}
+
+
+static GtkWidget *
+procman_create_sysinfo_view(void)
+{
+    GtkWidget *hbox;
+    GtkWidget *vbox;
+
+    SysInfo *data = get_sysinfo();;
+
+    GtkWidget * logo;
+
+    GtkWidget *distro_frame;
+    GtkWidget *distro_release_label;
+    GtkWidget *distro_table;
+
+    GtkWidget *hardware_table;
+    GtkWidget *disk_space_table;
+
+    GtkWidget *header;
+
+    gchar *markup;
+
+    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);
+
+    /* left-side logo */
+    if (g_file_test (DATADIR "/pixmaps/mate-system-monitor/distribution/side.png", G_FILE_TEST_EXISTS)) {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/distribution/side.png");
+    }
+    else {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/side.png");
+    }
+    gtk_widget_set_valign (logo, GTK_ALIGN_START);
+    gtk_widget_set_margin_start (logo, 5);
+    gtk_widget_set_margin_end (logo, 5);
+    gtk_widget_set_margin_top (logo, 12);
+    gtk_widget_set_margin_bottom (logo, 12);
+    gtk_box_pack_start(GTK_BOX(hbox), logo, FALSE, FALSE, 0);
+
+    g_signal_connect(G_OBJECT(logo), "draw", G_CALLBACK(sysinfo_logo_draw), NULL);
+
+    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
+    gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
+
+    // hostname
+
+    markup = g_strdup_printf("<big><big><b><u>%s</u></b></big></big>",
+                             data->hostname.c_str());
+    GtkWidget *hostname_frame = gtk_frame_new(markup);
+    g_free(markup);
+    gtk_frame_set_label_align(GTK_FRAME(hostname_frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(hostname_frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(hostname_frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), hostname_frame, FALSE, FALSE, 0);
+
+
+    /* distro section */
+
+    unsigned table_size = 2;
+    if (data->mate_version != "")
+        table_size++;
+    distro_table = add_section(GTK_BOX(vbox), "???", table_size, 1, &distro_frame);
+
+    unsigned table_count = 0;
+
+    distro_release_label = gtk_label_new("???");
+    gtk_label_set_selectable(GTK_LABEL(distro_release_label), TRUE);
+    gtk_widget_set_can_focus(distro_release_label, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (distro_release_label), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), distro_release_label,
+        0, table_count, 1, 1);
+    table_count++;
+    data->set_distro_labels(gtk_frame_get_label_widget(GTK_FRAME(distro_frame)), distro_release_label);
+
+    markup = g_strdup_printf(_("Kernel %s"), data->kernel.c_str());
+    header = gtk_label_new(markup);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    g_free(markup);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), header,
+        0, table_count, 1, 1);
+    table_count++;
+
+    if (data->mate_version != "")
+    {
+        markup = g_strdup_printf(_("MATE %s"), data->mate_version.c_str());
+        header = gtk_label_new(markup);
+        gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+        gtk_widget_set_can_focus(header, FALSE);
+        g_free(markup);
+        gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+        gtk_grid_attach(
+            GTK_GRID(distro_table), header,
+            0, table_count, 1, 1);
+        table_count++;<--- Variable 'table_count' is assigned a value that is never used.
+    }
+
+    /* hardware section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("Hardware"));
+    hardware_table = add_section(GTK_BOX(vbox), markup, 1, 3, NULL);
+    g_free(markup);
+
+    markup = g_format_size_full(data->memory_bytes, G_FORMAT_SIZE_IEC_UNITS);
+    add_row(GTK_GRID(hardware_table), _("Memory:"), markup, 0);
+    g_free(markup);
+
+    add_row(GTK_GRID(hardware_table), _("Processor:"),
+            data->processors.c_str(), 1);
+    add_row(GTK_GRID(hardware_table), _("Graphics:"),
+            data->graphics.c_str(), 2);
+
+    /* disk space section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("System Status"));
+    disk_space_table = add_section(GTK_BOX(vbox), markup, 1, 2, NULL);
+    g_free(markup);
+
+    markup = g_format_size(data->free_space_bytes);
+    add_row(GTK_GRID(disk_space_table), _("Available disk space:"), markup, 0);
+    g_free(markup);
+
+    return hbox;
+}
+
+
+
+namespace procman
+{
+    void build_sysinfo_ui()
+    {
+        static GtkWidget* ui;
+
+        if (!ui) {
+            ProcData* procdata = ProcData::get_instance();
+            ui = procman_create_sysinfo_view();
+            GtkBox* box = GTK_BOX(gtk_notebook_get_nth_page(GTK_NOTEBOOK(procdata->notebook),
+                                                            PROCMAN_TAB_SYSINFO));
+            gtk_box_pack_start(box, ui, TRUE, TRUE, 0);
+            gtk_widget_show_all(ui);
+        }
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/49.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/49.html new file mode 100644 index 00000000..598373c6 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/49.html @@ -0,0 +1,1557 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gprintf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibtop/proctime.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procstate.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <stddef.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <cstring><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "util.h"
+#include "procman.h"
+
+gchar *
+procman_format_date_for_display(time_t time_raw)
+{
+    gchar *result = NULL;
+    const char *format;
+    GDateTime *date_time, *today;
+    GTimeSpan date_age;
+
+    date_time = g_date_time_new_from_unix_local (time_raw);
+    today = g_date_time_new_now_local ();
+
+    date_age = g_date_time_difference (today, date_time);
+    if (date_age < G_TIME_SPAN_DAY) {
+        format = _("Today %l:%M %p");
+    } else if (date_age < 2 * G_TIME_SPAN_DAY) {
+        format = _("Yesterday %l:%M %p");
+    } else if (date_age < 7 * G_TIME_SPAN_DAY) {
+        format = _("%a %l:%M %p");
+    } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
+        format = _("%b %d %l:%M %p");
+    } else {
+	format = _("%b %d %Y");
+    }
+
+    g_date_time_unref (today);
+    result = g_date_time_format (date_time, format);
+    g_date_time_unref (date_time);
+
+    return result;
+}
+
+const char*
+format_process_state(guint state)
+{
+    const char *status;
+
+    switch (state)
+        {
+        case GLIBTOP_PROCESS_RUNNING:
+            status = _("Running");
+            break;
+
+        case GLIBTOP_PROCESS_STOPPED:
+            status = _("Stopped");
+            break;
+
+        case GLIBTOP_PROCESS_ZOMBIE:
+            status = _("Zombie");
+            break;
+
+        case GLIBTOP_PROCESS_UNINTERRUPTIBLE:
+            status = _("Uninterruptible");
+            break;
+
+        default:
+            status = _("Sleeping");
+            break;
+        }
+
+    return status;
+}
+
+
+
+static char *
+mnemonic_safe_process_name(const char *process_name)
+{
+    const char *p;
+    GString *name;
+
+    name = g_string_new ("");
+
+    for(p = process_name; *p; ++p)
+    {
+        g_string_append_c (name, *p);
+
+        if(*p == '_')
+            g_string_append_c (name, '_');
+    }
+
+    return g_string_free (name, FALSE);
+}
+
+
+
+static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
+{
+    *q = *r / d;
+    *r = *r % d;
+    return *q != 0;
+}
+
+
+/*
+ * @param d: duration in centiseconds
+ * @type d: unsigned
+ */
+gchar *
+procman::format_duration_for_display(unsigned centiseconds)
+{
+    unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
+
+    (void)(divide(&seconds, &centiseconds, 100)
+           && divide(&minutes, &seconds, 60)
+           && divide(&hours, &minutes, 60)
+           && divide(&days, &hours, 24)
+           && divide(&weeks, &days, 7));
+
+    if (weeks)
+        /* xgettext: weeks, days */
+        return g_strdup_printf(_("%uw%ud"), weeks, days);
+
+    if (days)
+        /* xgettext: days, hours (0 -> 23) */
+        return g_strdup_printf(_("%ud%02uh"), days, hours);
+
+    if (hours)
+        /* xgettext: hours (0 -> 23), minutes, seconds */
+        return g_strdup_printf(_("%u:%02u:%02u"), hours, minutes, seconds);
+
+    /* xgettext: minutes, seconds, centiseconds */
+    return g_strdup_printf(_("%u:%02u.%02u"), minutes, seconds, centiseconds);
+}
+
+
+
+GtkWidget*
+procman_make_label_for_mmaps_or_ofiles(const char *format,
+                                       const char *process_name,
+                                       unsigned pid)
+{
+    GtkWidget *label;
+    char *name, *title;
+
+    name = mnemonic_safe_process_name (process_name);
+    title = g_strdup_printf(format, name, pid);
+    label = gtk_label_new_with_mnemonic (title);
+    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+
+    g_free (title);
+    g_free (name);
+
+    return label;
+}
+
+gchar *
+procman::get_nice_level (gint nice)
+{
+    if (nice < -7)
+        return _("Very High");
+    else if (nice < -2)
+        return _("High");
+    else if (nice < 3)
+        return _("Normal");
+    else if (nice < 7)
+        return _("Low");
+    else
+        return _("Very Low");
+}
+
+
+gboolean
+load_symbols(const char *module, ...)
+{
+    GModule *mod;
+    gboolean found_all = TRUE;
+    va_list args;
+
+    mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
+
+    if (!mod)
+        return FALSE;
+
+    procman_debug("Found %s", module);
+
+    va_start(args, module);
+
+    while (1) {
+        const char *name;
+        void **symbol;
+
+        name = va_arg(args, char*);
+
+        if (!name)
+            break;
+
+        symbol = va_arg(args, void**);
+
+        if (g_module_symbol(mod, name, symbol)) {
+            procman_debug("Loaded %s from %s", name, module);
+        }
+        else {
+            procman_debug("Could not load %s from %s", name, module);
+            found_all = FALSE;
+            break;
+        }
+    }
+
+    va_end(args);
+
+
+    if (found_all)
+        g_module_make_resident(mod);
+    else
+        g_module_close(mod);
+
+    return found_all;
+}
+
+
+static gboolean
+is_debug_enabled(void)
+{
+    static gboolean init;
+    static gboolean enabled;
+
+    if (!init) {
+        enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL;
+        init = TRUE;
+    }
+
+    return enabled;
+}
+
+
+#if GLIB_CHECK_VERSION(2,61,2)
+static gint64
+get_relative_time(void)
+{
+    static unsigned long start_time;
+    gint64 tv;
+
+    if (G_UNLIKELY(!start_time)) {
+        glibtop_proc_time buf;
+        glibtop_get_proc_time(&buf, getpid());
+        start_time = buf.start_time;
+    }
+
+    tv = g_get_real_time ();
+    return tv - (gint64) start_time;
+}
+#else
+static double
+get_relative_time(void)
+{
+    static unsigned long start_time;
+    GTimeVal tv;
+
+    if (G_UNLIKELY(!start_time)) {
+        glibtop_proc_time buf;
+        glibtop_get_proc_time(&buf, getpid());
+        start_time = buf.start_time;
+    }
+
+    g_get_current_time(&tv);
+    return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
+}
+#endif
+
+static guint64
+get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
+                             const guint index)
+{
+    GValue value = { 0 };
+    gtk_tree_model_get_value(model, first, index, &value);
+
+    guint64 size;
+    switch (G_VALUE_TYPE(&value)) {
+        case G_TYPE_UINT:
+            size = g_value_get_uint(&value);
+            break;
+        case G_TYPE_ULONG:
+            size = g_value_get_ulong(&value);
+            break;
+        case G_TYPE_UINT64:
+            size = g_value_get_uint64(&value);
+            break;
+        default:
+            g_assert_not_reached();
+    }
+
+    g_value_unset(&value);
+    return size;
+}
+
+void
+procman_debug_real(const char *file, int line, const char *func,
+                   const char *format, ...)
+{
+    va_list args;
+    char *msg;
+
+    if (G_LIKELY(!is_debug_enabled()))
+        return;
+
+    va_start(args, format);
+    msg = g_strdup_vprintf(format, args);
+    va_end(args);
+
+#if GLIB_CHECK_VERSION(2,61,2)
+    g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
+#else
+    g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
+#endif
+    g_free(msg);
+}
+
+
+
+namespace procman
+{
+    void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                    GtkTreeModel *model, GtkTreeIter *iter,
+                                    gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+            case G_TYPE_UINT64:
+                size = g_value_get_uint64(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
+        g_object_set(renderer, "text", str, NULL);
+        g_free(str);
+    }
+
+    /*
+      Same as above but handles size == 0 as not available
+     */
+    void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                       GtkTreeModel *model, GtkTreeIter *iter,
+                                       gpointer user_data)
+    {
+     	const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+          case G_TYPE_UINT64:
+              size = g_value_get_uint64(&value);
+              break;
+
+          default:
+              g_assert_not_reached();
+        }
+
+	g_value_unset(&value);
+
+        if (size == 0) {
+            char *str = g_strdup_printf ("<i>%s</i>", _("N/A"));
+            g_object_set(renderer, "markup", str, NULL);
+            g_free(str);
+        }
+	else {
+            char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
+            g_object_set(renderer, "text", str, NULL);
+            g_free(str);
+        }
+    }
+
+    void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                     GtkTreeModel *model, GtkTreeIter *iter,
+                                     gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+            case G_TYPE_UINT64:
+                size = g_value_get_uint64(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        char *str = g_format_size(size);
+        g_object_set(renderer, "text", str, NULL);
+        g_free(str);
+    }
+
+    /*
+      Same as above but handles size == 0 as not available
+     */
+    void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                        GtkTreeModel *model, GtkTreeIter *iter,
+                                        gpointer user_data)
+    {
+     	const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+          case G_TYPE_UINT64:
+              size = g_value_get_uint64(&value);
+              break;
+
+          default:
+              g_assert_not_reached();
+        }
+
+	g_value_unset(&value);
+
+        if (size == 0) {
+            char *str = g_strdup_printf ("<i>%s</i>", _("N/A"));
+            g_object_set(renderer, "markup", str, NULL);
+            g_free(str);
+        }
+	else {
+            char *str = g_format_size(size);
+            g_object_set(renderer, "text", str, NULL);
+            g_free(str);
+        }
+    }
+
+    void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                                GtkTreeModel *model, GtkTreeIter *iter,
+                                gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+            case G_TYPE_UINT64:
+                size = g_value_get_uint64(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        if (size == 0) {
+            char *str = g_strdup_printf ("<i>%s</i>", _("N/A"));
+            g_object_set(renderer, "markup", str, NULL);
+            g_free(str);
+        }
+        else {
+            char *str = g_format_size(size);
+            char *formatted_str = g_strdup_printf(_("%s/s"), str);
+            g_object_set(renderer, "text", formatted_str, NULL);
+            g_free(formatted_str);
+            g_free(str);
+        }
+
+    }
+
+    void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                                 GtkTreeModel *model, GtkTreeIter *iter,
+                                 gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        unsigned time;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+            time = g_value_get_ulong(&value);
+            break;
+
+            case G_TYPE_UINT64:
+                time = g_value_get_uint64(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        time = 100 * time / ProcData::get_instance()->frequency;
+        char *str = format_duration_for_display(time);
+        g_object_set(renderer, "text", str, NULL);
+        g_free(str);
+    }
+
+
+    void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                             GtkTreeModel *model, GtkTreeIter *iter,
+                             gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        time_t time;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                time = g_value_get_ulong(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        gchar *str = procman_format_date_for_display(time);
+        g_object_set(renderer, "text", str, NULL);
+        g_free(str);
+    }
+
+    void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                               GtkTreeModel *model, GtkTreeIter *iter,
+                               gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint state;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_UINT:
+                state = g_value_get_uint(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        const char *str = format_process_state(state);
+        g_object_set(renderer, "text", str, NULL);
+    }
+
+    void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                             GtkTreeModel *model, GtkTreeIter *iter,
+                             gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        gint priority = g_value_get_int(&value);
+
+        g_value_unset(&value);
+
+        g_object_set(renderer, "text", procman::get_nice_level(priority), NULL);
+
+    }
+
+    gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
+                            GtkTreeIter* second, gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+        GValue value1 = { 0 };
+        GValue value2 = { 0 };
+        gtk_tree_model_get_value(model, first, index, &value1);
+        gtk_tree_model_get_value(model, second, index, &value2);
+        gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
+        g_value_unset(&value1);
+        g_value_unset(&value2);
+        return result;
+    }
+
+    gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
+                            GtkTreeIter* second, gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size1, size2;
+        size1 = get_size_from_column(model, first, index);
+        size2 = get_size_from_column(model, second, index);
+
+        if ( size2 > size1 )
+            return 1;
+        else if ( size2 < size1 )
+            return -1;
+        return 0;
+    }
+
+    template<>
+    void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
+    {
+        char* current_value;
+
+        gtk_tree_model_get(model, iter, column, &current_value, -1);
+
+        if (g_strcmp0(current_value, new_value) != 0)
+            gtk_tree_store_set(GTK_TREE_STORE(model), iter, column, new_value, -1);
+
+        g_free(current_value);
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/5.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/5.html new file mode 100644 index 00000000..111df8f5 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/5.html @@ -0,0 +1,435 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
#ifndef _PROCMAN_SMOOTH_REFRESH
+#define _PROCMAN_SMOOTH_REFRESH
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+using std::string;
+
+class SmoothRefresh
+{
+  public:
+
+    /*
+      smooth_refresh_new
+
+      @config_interval : pointer to config_interval so we can observe
+      config_interval changes.
+
+      @return : initialized SmoothRefresh
+    */
+    SmoothRefresh(GSettings *a_settings);
+
+    ~SmoothRefresh();
+
+    /*
+      smooth_refresh_reset
+
+      Resets state and re-read config_interval
+    */
+    void reset();
+
+    /*
+      smooth_refresh_get
+
+      Computes the new refresh_interval so that CPU usage is lower than
+      SMOOTH_REFRESH_PCPU.
+
+      @new_interval : where the new refresh_interval is stored.
+
+      @return : TRUE is refresh_interval has changed. The new refresh_interval
+      is stored in @new_interval. Else FALSE;
+    */
+    bool get(guint &new_interval);
+
+    static const string KEY;
+    static const bool KEY_DEFAULT_VALUE;
+
+  private:
+
+    unsigned get_own_cpu_usage();
+
+    static void status_changed(GSettings *settings,
+                               const gchar *key,
+                               gpointer user_data);
+
+    void load_settings_value(const gchar *key);
+
+    /*
+      fuzzy logic:
+      - decrease refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_LO
+      - increase refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_HI
+
+    */
+
+    enum
+    {
+        PCPU_HI = 22,
+        PCPU_LO = 18
+    };
+
+    /*
+      -self : procman's PID (so we call getpid() only once)
+
+      -interval : current refresh interval
+
+      -config_interval : pointer to the configuration refresh interval.
+      Used to watch configuration changes
+
+      -interval >= -config_interval
+
+      -last_pcpu : to avoid spikes, the last CPU%. See PCPU_{LO,HI}
+
+      -last_total_time:
+      -last_cpu_time: Save last cpu and process times to compute CPU%
+    */
+
+    GSettings *settings;
+    bool active;
+    guint connection;
+    guint interval;
+    unsigned  last_pcpu;
+    guint64 last_total_time;
+    guint64 last_cpu_time;
+};
+
+#endif /* _PROCMAN_SMOOTH_REFRESH */
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/50.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/50.html new file mode 100644 index 00000000..70b6b8df --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/50.html @@ -0,0 +1,275 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+int main(int argc, char* argv[])<--- Parameter 'argv' can be declared as const array
+{
+    gchar **argv_modified = g_new0 (gchar *, (size_t)(argc + 1));
+    memcpy (argv_modified, argv, (size_t)(argc) * sizeof (char*));
+    argv_modified[0] = COMMAND;
+    int errsv = 0;
+
+    if (execvp (COMMAND, argv_modified) == -1) {
+        errsv = errno;
+    }
+
+    g_free (argv_modified);
+    return errsv;
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/6.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/6.html new file mode 100644 index 00000000..7792f2fa --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/6.html @@ -0,0 +1,385 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
// -*- c++ -*-
+
+#ifndef _PROCMAN_PRETTYTABLE_H_
+#define _PROCMAN_PRETTYTABLE_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk-pixbuf/gdk-pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/refptr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdkmm/pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/filemonitor.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <map><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef HAVE_WNCK
+extern "C" {
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+}
+#endif
+
+#include "iconthemewrapper.h"
+
+class ProcInfo;
+
+using std::string;
+
+class PrettyTable
+{
+ public:
+    PrettyTable();
+    ~PrettyTable();
+
+    void set_icon(ProcInfo &);
+
+private:
+
+#ifdef HAVE_WNCK
+    static void on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_opened'
+    static void on_application_closed(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_closed'
+
+    void register_application(pid_t pid, Glib::RefPtr<Gdk::Pixbuf> icon);
+    void unregister_application(pid_t pid);
+#endif
+
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_theme(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_default(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_gio(const ProcInfo &);
+#ifdef HAVE_WNCK
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_wnck(const ProcInfo &);
+#endif
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_name(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_for_kernel(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_dummy(const ProcInfo &);
+
+    bool get_default_icon_name(const string &cmd, string &name);
+    void file_monitor_event (Glib::RefPtr<Gio::File>,
+                             Glib::RefPtr<Gio::File>,
+                             Gio::FileMonitorEvent);
+    void init_gio_app_cache ();
+
+    typedef std::map<string, Glib::RefPtr<Gdk::Pixbuf> > IconCache;
+    typedef std::map<pid_t, Glib::RefPtr<Gdk::Pixbuf> > IconsForPID;
+    typedef std::map<string, Glib::RefPtr<Gio::AppInfo> > AppCache;
+    typedef std::map<string, Glib::RefPtr<Gio::FileMonitor> > DesktopDirMonitors;
+
+    IconsForPID apps;
+    IconCache defaults;
+    DesktopDirMonitors monitors;
+    AppCache gio_apps;
+    procman::IconThemeWrapper theme;
+};
+
+#endif /* _PROCMAN_PRETTYTABLE_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/7.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/7.html new file mode 100644 index 00000000..e4d2cec9 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/7.html @@ -0,0 +1,287 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
#ifndef H_PROCMAN_ICONTHEMEWRAPPER_H_1185707711
+#define H_PROCMAN_ICONTHEMEWRAPPER_H_1185707711
+
+#include <glibmm/refptr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/ustring.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtkmm/icontheme.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdkmm/pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+namespace procman
+{
+    class IconThemeWrapper
+    {
+      public:
+        // returns 0 instead of raising an exception
+        Glib::RefPtr<Gdk::Pixbuf>
+            load_icon(const Glib::ustring& icon_name, int size) const;
+        Glib::RefPtr<Gdk::Pixbuf>
+            load_gicon(const Glib::RefPtr<Gio::Icon>& gicon, int size, Gtk::IconLookupFlags flags) const;
+
+        const IconThemeWrapper* operator->() const
+        { return this; }
+    };
+}
+
+#endif // H_PROCMAN_ICONTHEMEWRAPPER_H_1185707711
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/8.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/8.html new file mode 100644 index 00000000..f0a0b119 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/8.html @@ -0,0 +1,385 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
/*
+ * Mate system monitor color pickers
+ * Copyright (C) 2007 Karl Lattimer <karl@qdh.org.uk>
+ * Copyright (C) 2012-2021 MATE Developers
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with the software; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GSM_COLOR_BUTTON_H__
+#define __GSM_COLOR_BUTTON_H__
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+/* The GtkColorSelectionButton widget is a simple color picker in a button.
+ * The button displays a sample of the currently selected color. When
+ * the user clicks on the button, a color selection dialog pops up.
+ * The color picker emits the "color_set" signal when the color is set.
+ */
+#define GSM_TYPE_COLOR_BUTTON            (gsm_color_button_get_type ())
+G_DECLARE_DERIVABLE_TYPE (GSMColorButton, gsm_color_button, GSM, COLOR_BUTTON, GtkDrawingArea)
+
+/* Widget types */
+enum
+{
+    GSMCP_TYPE_CPU,
+    GSMCP_TYPE_PIE,
+    GSMCP_TYPE_NETWORK_IN,
+    GSMCP_TYPE_NETWORK_OUT,
+    GSMCP_TYPES
+};
+
+struct _GSMColorButtonClass
+{
+    GtkWidgetClass parent_class;
+
+    void (*color_set) (GSMColorButton * cp);
+
+    /* Padding for future expansion */
+    void (*_gtk_reserved1) (void);
+    void (*_gtk_reserved2) (void);
+    void (*_gtk_reserved3) (void);
+    void (*_gtk_reserved4) (void);
+};
+
+GtkWidget *gsm_color_button_new (const GdkRGBA * color, guint type);
+void gsm_color_button_set_color (GSMColorButton * color_button, const GdkRGBA * color);
+void gsm_color_button_set_fraction (GSMColorButton * color_button, const gdouble fraction);
+void gsm_color_button_set_cbtype (GSMColorButton * color_button, guint type);
+void gsm_color_button_get_color (GSMColorButton * color_button, GdkRGBA * color);
+gdouble gsm_color_button_get_fraction (GSMColorButton * color_button);
+guint gsm_color_button_get_cbtype (GSMColorButton * color_button);
+void gsm_color_button_set_title (GSMColorButton * color_button, const gchar * title);
+const gchar* gsm_color_button_get_title(GSMColorButton* color_button);
+
+G_END_DECLS
+#endif /* __GSM_COLOR_BUTTON_H__ */
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/9.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/9.html new file mode 100644 index 00000000..0b6fb092 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/9.html @@ -0,0 +1,305 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
/* Procman - main window
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef _PROCMAN_INTERFACE_H_
+#define _PROCMAN_INTERFACE_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+void            create_main_window (ProcData *data);
+void            update_sensitivity (ProcData *data);
+void            block_priority_changed_handlers(ProcData *data, bool block);
+void            do_popup_menu(ProcData *data, GdkEventButton *event);
+GtkWidget *     make_title_label (const char *text);
+
+#endif /* _PROCMAN_INTERFACE_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/index.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/index.html new file mode 100644 index 00000000..12e0179e --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/index.html @@ -0,0 +1,663 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
src/argv.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibmm/optionentry.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/argv.h
4missingIncludeSysteminformationInclude file: <glibmm/optiongroup.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/callbacks.cpp
21missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <giomm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/callbacks.h
24missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/cgroups.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <cstring> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27variableScope398styleThe scope of the variable 'paren_offset' can be reduced.
27variableScope398styleThe scope of the variable 'off' can be reduced.
27variableScope398styleThe scope of the variable 'tmp_size' can be reduced.
55cstyleCast398styleC-style pointer casting
src/cgroups.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/defaulttable.h
4missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibmm/refptr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glibmm/regex.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/disks.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <mntent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <giomm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <giomm/themedicon.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <glibtop/mountlist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <glibtop/fsusage.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
202redundantAssignment563styleVariable 'res' is reassigned a value before the old one has been used.
src/gsm_color_button.c
23missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <cairo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <librsvg/rsvg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
522constParameterPointer398styleParameter 'color' can be declared as pointer to const
648variableScope398styleThe scope of the variable 'color_chooser' can be reduced.
723constParameterCallback398styleParameter 'event' can be declared as pointer to const. However it seems that 'gsm_color_button_pressed' is a callback function, if 'event' is declared with const you might also need to cast function pointer(s).
src/gsm_color_button.h
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gdk/gdk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/iconthemewrapper.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <gtkmm/icontheme.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <giomm/error.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/iconthemewrapper.h
4missingIncludeSysteminformationInclude file: <glibmm/refptr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibmm/ustring.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <gtkmm/icontheme.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <gdkmm/pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/interface.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
452cstyleCast398styleC-style pointer casting
454cstyleCast398styleC-style pointer casting
src/interface.h
24missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/load-graph.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <gdkmm/pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <dirent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <glibtop.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
16missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <glibtop/mem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
18missingIncludeSysteminformationInclude file: <glibtop/swap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
19missingIncludeSysteminformationInclude file: <glibtop/netload.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
20missingIncludeSysteminformationInclude file: <glibtop/netlist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
21missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <algorithm> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41shadowVariable398styleLocal variable 'n' shadows outer variable
164shadowVariable398styleLocal variable 'i' shadows outer variable
836constParameterPointer398styleParameter 'graph' can be declared as pointer to const
842constParameterPointer398styleParameter 'graph' can be declared as pointer to const
848constParameterPointer398styleParameter 'graph' can be declared as pointer to const
src/load-graph.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36noExplicitConstructor398styleStruct 'LoadGraph' has a constructor with 1 argument that is not explicit.
src/lsof.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <gtkmm/messagedialog.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibmm/regex.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glibtop/procopenfiles.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <sys/wait.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <set> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <sstream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <iterator> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <glibmm/regex.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
164shadowVariable398styleLocal variable 'count' shadows outer variable
src/lsof.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/memmaps.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glibtop/procmap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibtop/mountlist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <map> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <sstream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <iomanip> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <stdexcept> not found. Please note: Cppcheck does not need standard library headers to get proper results.
269shadowVariable398styleLocal variable 'iter' shadows outer variable
src/memmaps.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/msm-resources.c
1missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9unusedStructMember563styleunion member 'Anonymous0::alignment' is never used.
9unusedStructMember563styleunion member 'Anonymous0::ptr' is never used.
src/openfiles.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibtop/procopenfiles.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <netdb.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <sys/socket.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <netinet/in.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <arpa/inet.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
73nullPointerRedundantCheck476warningEither the condition 'res' is redundant or there is possible null pointer dereference: res.
205shadowVariable398styleLocal variable 'openfiles' shadows outer variable
247variableScope398styleThe scope of the variable 'column' can be reduced.
248variableScope398styleThe scope of the variable 'cell' can be reduced.
src/openfiles.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/prettytable.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <libwnck/libwnck.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <dirent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <gdk-pixbuf/gdk-pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <glibtop/procstate.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <giomm/error.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <giomm/file.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
16missingIncludeSysteminformationInclude file: <glibmm/miscutils.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <iostream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
19missingIncludeSysteminformationInclude file: <vector> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/prettytable.h
6missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <gdk-pixbuf/gdk-pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <glibmm/refptr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <gdkmm/pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <giomm/filemonitor.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <map> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
18missingIncludeSysteminformationInclude file: <libwnck/libwnck.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_opened'
40unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_closed'
src/procactions.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <sys/time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <sys/resource.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procdialogs.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
294noExplicitConstructor398styleClass 'SpinButtonUpdater' has a constructor with 1 argument that is not explicit.
415shadowVariable398styleLocal variable 'column' shadows outer variable
475cstyleCast398styleC-style pointer casting
498cstyleCast398styleC-style pointer casting
513cstyleCast398styleC-style pointer casting
src/procdialogs.h
23missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman-app.cpp
1missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
2missingIncludeSysteminformationInclude file: <glibtop.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glibtop/close.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibtop/sysinfo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
348uninitMemberVar398warningMember variable 'ProcmanApp::procdata' is not initialized in the constructor.
src/procman-app.h
4missingIncludeSysteminformationInclude file: <gtkmm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman.cpp
21missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gtkmm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34uninitMemberVarPrivate398warningMember variable 'ProcData::uimanager' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::action_group' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::statusbar' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::loadavg' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::endprocessbutton' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::popup_menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::disk_list' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::notebook' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::config' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::selection' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::settings' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::app' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::frequency' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::smooth_refresh' is not initialized in the constructor.
112shadowVariable398styleLocal variable 'order' shadows outer variable
162shadowVariable398styleLocal variable 'order' shadows outer variable
src/procman.h
23missingIncludeSysteminformationInclude file: <glibmm/refptr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <cairo-gobject.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gdk-pixbuf/gdk-pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <map> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
103uninitMemberVar398warningMember variable 'MutableProcInfo::cgroup_name' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::unit' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::session' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::seat' is not initialized in the constructor.
173noExplicitConstructor398styleClass 'ProcInfo' has a constructor with 1 argument that is not explicit.
src/procman_gksu.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman_gksu.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman_pkexec.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman_pkexec.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procproperties.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glibtop/procmem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glibtop/procmap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glibtop/procstate.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
208variableScope398styleThe scope of the variable 'column' can be reduced.
209variableScope398styleThe scope of the variable 'cell' can be reduced.
src/procproperties.h
25missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/proctable.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <cairo-gobject.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gprintf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glibtop.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <glibtop/loadavg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <glibtop/proclist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <glibtop/procio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <glibtop/procstate.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <glibtop/procmem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <glibtop/procmap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <glibtop/proctime.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <glibtop/procuid.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <glibtop/procargs.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <glibtop/prockernel.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
40missingIncludeSysteminformationInclude file: <glibtop/mem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <glibtop/swap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
42missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
43missingIncludeSysteminformationInclude file: <pwd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
44missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
46missingIncludeSysteminformationInclude file: <set> not found. Please note: Cppcheck does not need standard library headers to get proper results.
47missingIncludeSysteminformationInclude file: <list> not found. Please note: Cppcheck does not need standard library headers to get proper results.
50missingIncludeSysteminformationInclude file: <systemd/sd-login.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
64missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
920shadowVariable398styleLocal variable 'arguments' shadows outer variable
929shadowVariable398styleLocal variable 'tooltip' shadows outer variable
1016shadowVariable398styleLocal variable 'it' shadows outer variable
1022shadowVariable398styleLocal variable 'it' shadows outer variable
1052constVariablePointer398styleVariable 'parent' can be declared as pointer to const
1068shadowVariable398styleLocal variable 'it' shadows outer variable
1073shadowVariable398styleLocal variable 'it' shadows outer variable
src/proctable.h
24missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/selection.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/selection.h
4missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <vector> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/selinux.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
21varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
src/selinux.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/settings-keys.h
4missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/smooth_refresh.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <glibtop.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <glibtop/proctime.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <algorithm> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/smooth_refresh.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
22noExplicitConstructor398styleClass 'SmoothRefresh' has a constructor with 1 argument that is not explicit.
src/sysinfo.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibmm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <libxml/parser.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <libxml/xpath.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <libxml/xpathInternals.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <glibtop/fsusage.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <glibtop/mountlist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <glibtop/mem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <glibtop/sysinfo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
18missingIncludeSysteminformationInclude file: <netdb.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
19missingIncludeSysteminformationInclude file: <sys/socket.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
20missingIncludeSysteminformationInclude file: <sys/wait.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
21missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
22missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <exception> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <vector> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <fstream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <sstream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <sys/utsname.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
126unusedPrivateFunction398styleUnused private function: 'SysInfo::get_os_type'
233cstyleCast398styleC-style pointer casting
343cstyleCast398styleC-style pointer casting
509uninitMemberVar398warningMember variable 'LSBSysInfo::lsb_fd' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::name' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::release' is not initialized in the constructor.
515missingOverridestyleThe function 'set_distro_labels' overrides a function in a base class but is not marked with a 'override' specifier.
570shadowVariable398styleLocal variable 'release' shadows outer variable
615unusedPrivateFunction398styleUnused private function: 'LSBSysInfo::sync_lsb_release'
626variableScope398styleThe scope of the variable 'codename' can be reduced.
626shadowVariable398styleLocal variable 'release' shadows outer variable
690stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
697stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
701stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
736variableScope398styleThe scope of the variable 'len' can be reduced.
738stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
1001unreadVariable563styleVariable 'table_count' is assigned a value that is never used.
src/util.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib/gprintf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <glibtop/proctime.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <glibtop/procstate.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <stddef.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <cstring> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/util.h
6missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
123constParameterPointer398styleParameter 'new_value' can be declared as pointer to const
tools/msm_execute_helper.c
1missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
2missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6constParameter398styleParameter 'argv' can be declared as const array
+
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/stats.html b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/stats.html new file mode 100644 index 00000000..a2e83e06 --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/stats.html @@ -0,0 +1,201 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+

Top 10 files for warning severity, total findings: 24
+   15  src/procman.cpp
+   4   src/procman.h
+   3   src/sysinfo.cpp
+   1   src/procman-app.cpp
+   1   src/openfiles.cpp
+

+

Top 10 files for portability severity, total findings: 1
+   1  src/selinux.cpp
+

+

Top 10 files for performance severity, total findings: 4
+   4  src/sysinfo.cpp
+

+

Top 10 files for style severity, total findings: 55
+   10  src/sysinfo.cpp
+   7   src/proctable.cpp
+   5   src/procdialogs.cpp
+   5   src/load-graph.cpp
+   4   src/cgroups.cpp
+   3   src/openfiles.cpp
+   3   src/gsm_color_button.c
+   2   src/procproperties.cpp
+   2   src/procman.cpp
+   2   src/prettytable.h
+

+

Top 10 files for information severity, total findings: 269
+   26  src/proctable.cpp
+   24  src/sysinfo.cpp
+   18  src/load-graph.cpp
+   14  src/prettytable.cpp
+   12  src/gsm_color_button.c
+   11  src/procman.h
+   11  src/lsof.cpp
+   10  src/util.cpp
+   10  src/memmaps.cpp
+   10  src/interface.cpp
+

+ +
+ +
+ + diff --git a/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/style.css b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/style.css new file mode 100644 index 00000000..3897bfaf --- /dev/null +++ b/2023-10-16-145255-4773-cppcheck@382528349dca_fix-build/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-10-16-150431-6168-1@71c61020bc59_master/index.html b/2023-10-16-150431-6168-1@71c61020bc59_master/index.html new file mode 100644 index 00000000..96743b18 --- /dev/null +++ b/2023-10-16-150431-6168-1@71c61020bc59_master/index.html @@ -0,0 +1,136 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@d5d13e604a03
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 16.0.6 (Fedora 16.0.6-3.fc38) +
Date:Mon Oct 16 15:04:31 2023
+

Bug Summary

+ + + + + + + +
Bug TypeQuantityDisplay?
All Bugs14
Logic error
Use of identical expressions1
Unused code
Dead assignment1
Unreachable code12
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
Unused codeDead assignmentrootdir/src/disks.cppget_mount_opt2011View Report
Unused codeUnreachable coderootdir/src/procman-app.cppon_command_line3811View Report
Unused codeUnreachable coderootdir/src/util.cppio_rate_cell_data_func4941View Report
Unused codeUnreachable coderootdir/src/util.cppstatus_cell_data_func5911View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_gicon421View Report
Unused codeUnreachable coderootdir/src/util.cppduration_cell_data_func5351View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_na_cell_data_func3841View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_na_cell_data_func4561View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_cell_data_func4221View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_icon131View Report
Unused codeUnreachable coderootdir/src/util.cpptime_cell_data_func5641View Report
Unused codeUnreachable coderootdir/src/procman-app.cpptimeouts_changed_cb1511View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_cell_data_func3501View Report
Logic errorUse of identical expressionsusr/include/sigc++-2.0/sigc++/visit_each.hoperator()981View Report
+ + diff --git a/2023-10-16-150431-6168-1@71c61020bc59_master/report-22e004.html b/2023-10-16-150431-6168-1@71c61020bc59_master/report-22e004.html new file mode 100644 index 00000000..73e1c50c --- /dev/null +++ b/2023-10-16-150431-6168-1@71c61020bc59_master/report-22e004.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 381, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-150431-6168-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
This statement is never executed
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2023-10-16-150431-6168-1@71c61020bc59_master/report-491eb3.html b/2023-10-16-150431-6168-1@71c61020bc59_master/report-491eb3.html new file mode 100644 index 00000000..c0adf505 --- /dev/null +++ b/2023-10-16-150431-6168-1@71c61020bc59_master/report-491eb3.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 494, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-150431-6168-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-16-150431-6168-1@71c61020bc59_master/report-4d889d.html b/2023-10-16-150431-6168-1@71c61020bc59_master/report-4d889d.html new file mode 100644 index 00000000..3b7307d5 --- /dev/null +++ b/2023-10-16-150431-6168-1@71c61020bc59_master/report-4d889d.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 591, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-150431-6168-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-16-150431-6168-1@71c61020bc59_master/report-633ebf.html b/2023-10-16-150431-6168-1@71c61020bc59_master/report-633ebf.html new file mode 100644 index 00000000..c548b78f --- /dev/null +++ b/2023-10-16-150431-6168-1@71c61020bc59_master/report-633ebf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 42, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-150431-6168-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
This statement is never executed
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2023-10-16-150431-6168-1@71c61020bc59_master/report-6c54e6.html b/2023-10-16-150431-6168-1@71c61020bc59_master/report-6c54e6.html new file mode 100644 index 00000000..cde9fe19 --- /dev/null +++ b/2023-10-16-150431-6168-1@71c61020bc59_master/report-6c54e6.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 535, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-150431-6168-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-16-150431-6168-1@71c61020bc59_master/report-6c8186.html b/2023-10-16-150431-6168-1@71c61020bc59_master/report-6c8186.html new file mode 100644 index 00000000..0a6d83af --- /dev/null +++ b/2023-10-16-150431-6168-1@71c61020bc59_master/report-6c8186.html @@ -0,0 +1,886 @@ + + + +/usr/include/sigc++-2.0/sigc++/visit_each.h + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:usr/include/sigc++-2.0/sigc++/visit_each.h
Warning:line 98, column 64
identical expressions on both sides of logical operator
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-150431-6168-1 -x c++ procman.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright 2002, The libsigc++ Development Team
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18#ifndef _SIGC_VISIT_EACH_HPP_
19#define _SIGC_VISIT_EACH_HPP_
20
21#include <sigc++/type_traits.h>
22#include <type_traits>
23
24namespace sigc {
25
26#ifndef DOXYGEN_SHOULD_SKIP_THIS
27namespace internal {
28
29//This should really be an inner class of limit_derived_target, without the T_limit template type,
30//But the SUN CC 5.7 (not earlier versions) compiler finds it ambiguous when we specify a particular specialization of it.
31//and does not seem to allow us to tell it explicitly that it's an inner class.
32template <bool I_derived, class T_type, class T_limit>
33struct with_type;
34
35//Specialization for I_derived = false
36template <class T_type, class T_limit> struct
37with_type<false, T_type, T_limit>
38{
39 static void execute_(const T_type&, const T_limit&) {}
40};
41
42//Specialization for I_derived = true
43template <class T_type, class T_limit>
44struct with_type<true, T_type, T_limit>
45{
46 static void execute_(const T_type& _A_type, const T_limit& _A_action)
47 { _A_action.action_(_A_type); }
48};
49
50
51/// Helper struct for visit_each_type().
52template <class T_target, class T_action>
53struct limit_derived_target
54{
55 typedef limit_derived_target<T_target, T_action> T_self;
56
57 template <class T_type>
58 void operator()(const T_type& _A_type) const
59 {
60 with_type<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
61 }
62
63 limit_derived_target(const T_action& _A_action)
64 : action_(_A_action)
65 {}
66
67 T_action action_;
68};
69
70// Specialization for T_target pointer types, to provide a slightly different execute_() implementation.
71
72template <bool I_derived, class T_type, class T_limit>
73struct with_type_pointer;
74
75//Specialization for I_derived = false
76template <class T_type, class T_limit>
77struct with_type_pointer<false, T_type, T_limit>
78{
79 static void execute_(const T_type&, const T_limit&) {}
80};
81
82//Specialization for I_derived = true
83template <class T_type, class T_limit>
84struct with_type_pointer<true, T_type, T_limit>
85{
86 static void execute_(const T_type& _A_type, const T_limit& _A_action)
87 { _A_action.action_(&_A_type); }
88};
89
90template <class T_target, class T_action>
91struct limit_derived_target<T_target*, T_action>
92{
93 typedef limit_derived_target<T_target*, T_action> T_self;
94
95 template <class T_type>
96 void operator()(const T_type& _A_type) const
97 {
98 with_type_pointer<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
identical expressions on both sides of logical operator
99 }
100
101 limit_derived_target(const T_action& _A_action)
102 : action_(_A_action)
103 {}
104
105 T_action action_;
106};
107
108} /* namespace internal */
109#endif // DOXYGEN_SHOULD_SKIP_THIS
110
111// struct visitor was introduced as a result of https://bugzilla.gnome.org/show_bug.cgi?id=724496
112// The advantage of using specializations of a template struct instead of overloads of
113// a template function is described by Herb Sutter in http://www.gotw.ca/publications/mill17.htm
114// In libsigc++ the main reason for using this technique is that we can avoid using ADL
115// (argument-dependent lookup), and therefore there is no risk that a visit_each() overload
116// in e.g. Boost is selected by mistake.
117
118/** sigc::visitor<T_functor>::do_visit_each() performs a functor on each of the targets of a functor.
119 * All unknown types just call @a _A_action on them.
120 * Add specializations that specialize the @a T_functor argument for your own
121 * functor types, so that subobjects get visited. This is needed to enable
122 * auto-disconnection support for your functor types.
123 *
124 * @par Example:
125 * @code
126 * namespace some_ns
127 * {
128 * struct some_functor
129 * {
130 * void operator()() {}
131 * some_possibly_sigc_trackable_derived_type some_data_member;
132 * some_other_functor_type some_other_functor;
133 * };
134 * }
135 *
136 * namespace sigc
137 * {
138 * template <>
139 * struct visitor<some_ns::some_functor>
140 * {
141 * template <class T_action>
142 * static void do_visit_each(const T_action& _A_action,
143 * const some_ns::some_functor& _A_target)
144 * {
145 * sigc::visit_each(_A_action, _A_target.some_data_member);
146 * sigc::visit_each(_A_action, _A_target.some_other_functor);
147 * }
148 * };
149 * }
150 * @endcode
151 *
152 * @ingroup sigcfunctors
153 */
154template <class T_functor>
155struct visitor
156{
157 template <class T_action>
158 static void do_visit_each(const T_action& _A_action, const T_functor& _A_functor)
159 {
160 _A_action(_A_functor);
161 }
162};
163
164/** This function performs a functor on each of the targets of a functor.
165 *
166 * @ingroup sigcfunctors
167 */
168template <class T_action, class T_functor>
169void visit_each(const T_action& _A_action, const T_functor& _A_functor)
170{ sigc::visitor<T_functor>::do_visit_each(_A_action, _A_functor); }
171
172/** This function performs a functor on each of the targets
173 * of a functor limited to a restricted type.
174 *
175 * @ingroup sigcfunctors
176 */
177template <class T_type, class T_action, class T_functor>
178void visit_each_type(const T_action& _A_action, const T_functor& _A_functor)
179{
180 typedef internal::limit_derived_target<T_type, T_action> type_limited_action;
181
182 type_limited_action limited_action(_A_action);
183
184 //specifying the types of the template specialization prevents disconnection of bound trackable references (such as with std::ref()),
185 //probably because the visit_each<> specializations take various different template types,
186 //in various sequences, and we are probably specifying only a subset of them with this.
187 //
188 //But this is required by the AIX (and maybe IRIX MipsPro and Tru64) compilers.
189 //I guess that std::ref() therefore does not work on those platforms. murrayc
190 // sigc::visit_each<type_limited_action, T_functor>(limited_action, _A_functor);
191
192 //g++ (even slightly old ones) is our primary platform, so we could use the non-crashing version.
193 //However, the explicit version also fixes a crash in a slightly more common case: http://bugzilla.gnome.org/show_bug.cgi?id=169225
194 //Users (and distributors) of libsigc++ on AIX (and maybe IRIX MipsPro and Tru64) do
195 //need to use the version above instead, to allow compilation.
196
197 //Added 2014-03-20: The preceding comment probably does not apply any more,
198 //now when the visit_each<>() overloads have been replaced by visitor<> specializations.
199 //It's probably safe to add explicit template parameters on calls to visit_each(),
200 //visit_each_type() and visitor::do_visit_each(), if necessary.
201
202 sigc::visit_each(limited_action, _A_functor);
203}
204
205} /* namespace sigc */
206#endif
diff --git a/2023-10-16-150431-6168-1@71c61020bc59_master/report-77634b.html b/2023-10-16-150431-6168-1@71c61020bc59_master/report-77634b.html new file mode 100644 index 00000000..44fd70ac --- /dev/null +++ b/2023-10-16-150431-6168-1@71c61020bc59_master/report-77634b.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 384, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-150431-6168-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-16-150431-6168-1@71c61020bc59_master/report-7bbc8c.html b/2023-10-16-150431-6168-1@71c61020bc59_master/report-7bbc8c.html new file mode 100644 index 00000000..201f8545 --- /dev/null +++ b/2023-10-16-150431-6168-1@71c61020bc59_master/report-7bbc8c.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 456, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-150431-6168-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-16-150431-6168-1@71c61020bc59_master/report-7ce786.html b/2023-10-16-150431-6168-1@71c61020bc59_master/report-7ce786.html new file mode 100644 index 00000000..ac762f2e --- /dev/null +++ b/2023-10-16-150431-6168-1@71c61020bc59_master/report-7ce786.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 422, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-150431-6168-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-16-150431-6168-1@71c61020bc59_master/report-802eaf.html b/2023-10-16-150431-6168-1@71c61020bc59_master/report-802eaf.html new file mode 100644 index 00000000..24f8e7ca --- /dev/null +++ b/2023-10-16-150431-6168-1@71c61020bc59_master/report-802eaf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 13, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-150431-6168-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
This statement is never executed
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2023-10-16-150431-6168-1@71c61020bc59_master/report-8e6c9c.html b/2023-10-16-150431-6168-1@71c61020bc59_master/report-8e6c9c.html new file mode 100644 index 00000000..b01081e1 --- /dev/null +++ b/2023-10-16-150431-6168-1@71c61020bc59_master/report-8e6c9c.html @@ -0,0 +1,1200 @@ + + + +disks.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/disks.cpp
Warning:line 201, column 13
Value stored to 'res' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name disks.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-150431-6168-1 -x c++ disks.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#ifdef __linux__1
4#include <mntent.h>
5#endif // __linux__
6
7#include <giomm.h>
8#include <giomm/themedicon.h>
9#include <gtk/gtk.h>
10#include <glibtop/mountlist.h>
11#include <glibtop/fsusage.h>
12#include <glib/gi18n.h>
13
14#include "procman.h"
15#include "disks.h"
16#include "util.h"
17#include "interface.h"
18#include "iconthemewrapper.h"
19
20namespace
21{
22 const unsigned DISK_ICON_SIZE = 24;
23}
24
25enum DiskColumns
26{
27 /* string columns* */
28 DISK_DEVICE,
29 DISK_DIR,
30 DISK_TYPE,
31 DISK_SUBVOLUME,
32 DISK_TOTAL,
33 DISK_FREE,
34 DISK_AVAIL,
35 /* USED has to be the last column */
36 DISK_USED,
37 // then unvisible columns
38 /* Surface column */
39 DISK_ICON,
40 /* numeric columns */
41 DISK_USED_PERCENTAGE,
42 DISK_N_COLUMNS
43};
44
45
46
47static void
48fsusage_stats(const glibtop_fsusage *buf,
49 guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
50 gint *percentage)
51{
52 guint64 total = buf->blocks * buf->block_size;
53
54 if (!total) {
55 /* not a real device */
56 *btotal = *bfree = *bavail = *bused = 0ULL;
57 *percentage = 0;
58 } else {
59 int percent;
60 *btotal = total;
61 *bfree = buf->bfree * buf->block_size;
62 *bavail = buf->bavail * buf->block_size;
63 *bused = *btotal - *bfree;
64 /* percent = 100.0f * *bused / *btotal; */
65 percent = 100 * *bused / (*bused + *bavail);
66 *percentage = CLAMP(percent, 0, 100)(((percent) > (100)) ? (100) : (((percent) < (0)) ? (0)
: (percent)))
;
67 }
68}
69
70
71namespace
72{
73 string get_icon_for_path(const std::string& path)
74 {
75 using namespace Glib;
76 using namespace Gio;
77
78 // FIXME: I don't know whether i should use Volume or Mount or UnixMount
79 // all i need an icon name.
80 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
81
82 std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
83
84 for (size_t i = 0; i != mounts.size(); ++i) {
85 if (mounts[i]->get_name() != path)
86 continue;
87
88 RefPtr<Icon> icon = mounts[i]->get_icon();
89 RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
90
91 if (themed_icon) {
92 char* name = 0;
93 // FIXME: not wrapped yet
94 g_object_get(G_OBJECT(themed_icon->gobj())((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((themed_icon->gobj())), (((GType) ((20) << (2)))
)))))
, "name", &name, NULL__null);
95 return make_string(name);
96 }
97 }
98
99 return "";
100 }
101}
102
103
104static Glib::RefPtr<Gdk::Pixbuf>
105get_icon_for_device(const char *mountpoint)
106{
107 procman::IconThemeWrapper icon_theme;
108 string icon_name = get_icon_for_path(mountpoint);
109 if (icon_name == "")
110 // FIXME: defaults to a safe value
111 icon_name = "drive-harddisk"; // get_icon_for_path("/");
112 return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
113}
114
115
116static gboolean
117find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
118 GtkTreeIter *result)
119{
120 GtkTreeIter iter;
121 gboolean found = FALSE(0);
122
123 if (gtk_tree_model_get_iter_first(model, &iter)) {
124 do {
125 char *dir;
126
127 gtk_tree_model_get(model, &iter,
128 DISK_DIR, &dir,
129 -1);
130
131 if (dir && !strcmp(dir, mountpoint)) {
132 *result = iter;
133 found = TRUE(!(0));
134 }
135
136 g_free(dir);
137
138 } while (!found && gtk_tree_model_iter_next(model, &iter));
139 }
140
141 return found;
142}
143
144
145
146static void
147remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
148{
149 GtkTreeIter iter;
150
151 if (!gtk_tree_model_get_iter_first(model, &iter))
152 return;
153
154 while (true) {
155 char *dir;
156 guint i;
157 gboolean found = FALSE(0);
158
159 gtk_tree_model_get(model, &iter,
160 DISK_DIR, &dir,
161 -1);
162
163 for (i = 0; i != n; ++i) {
164 if (!strcmp(dir, entries[i].mountdir)) {
165 found = TRUE(!(0));
166 break;
167 }
168 }
169
170 g_free(dir);
171
172 if (!found) {
173 if (!gtk_list_store_remove(GTK_LIST_STORE(model)((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_list_store_get_type ()))))))
, &iter))
174 break;
175 else
176 continue;
177 }
178
179 if (!gtk_tree_model_iter_next(model, &iter))
180 break;
181 }
182}
183
184#ifdef __linux__1
185static char *
186get_mount_opt(const glibtop_mountentry *entry, const char* opt)
187{
188 char *opt_value = NULL__null;
189 const struct mntent *mnt;
190 FILE *fp;
191
192 if (!(fp = setmntent(MOUNTED"/etc/mtab", "r"))) {
193 goto out;
194 }
195
196 while ((mnt = getmntent(fp))) {
197 if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
198 (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
199 char *res;
200
201 res = hasmntopt(mnt, "subvol");
Value stored to 'res' is never read
202 if ((res = hasmntopt(mnt, "subvol")) != NULL__null) {
203 char **strs = g_strsplit_set(res, "=", 2);
204
205 if (g_strv_length(strs) == 2) {
206 char *value = strs[1];
207 if (g_strcmp0 (value,"/root") == 0)
208 opt_value = g_strdup("/")g_strdup_inline ("/");
209 else
210 opt_value = g_strdup(strs[1])g_strdup_inline (strs[1]);
211 g_strfreev(strs);
212 }
213 }
214 break;
215 }
216 }
217
218 endmntent(fp);
219
220 out:
221 return opt_value;
222}
223#endif // __linux__
224
225
226static void
227add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
228{
229 Glib::RefPtr<Gdk::Pixbuf> pixbuf;
230 cairo_surface_t *surface;
231 GtkTreeIter iter;
232 glibtop_fsusage usage;
233 guint64 bused, bfree, bavail, btotal;
234 gint percentage;
235#ifdef __linux__1
236 char *subvol = NULL__null;
237#endif // __linux__
238
239 glibtop_get_fsusage(&usage, entry->mountdir);
240
241 if (not show_all_fs and usage.blocks == 0) {
242 if (find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
243 gtk_list_store_remove(list, &iter);
244 return;
245 }
246
247 fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
248#ifdef __linux__1
249 subvol = get_mount_opt(entry, "subvol");
250#endif // __linux__
251 pixbuf = get_icon_for_device(entry->mountdir);
252 surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL__null);
253
254 /* if we can find a row with the same mountpoint, we get it but we
255 still need to update all the fields.
256 This makes selection persistent.
257 */
258 if (!find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
259 gtk_list_store_append(list, &iter);
260
261 gtk_list_store_set(list, &iter,
262 DISK_ICON, surface,
263 DISK_DEVICE, entry->devname,
264 DISK_DIR, entry->mountdir,
265 DISK_TYPE, entry->type,
266#ifdef __linux__1
267
268 DISK_SUBVOLUME, subvol != NULL__null ? subvol : "",
269#else
270 DISK_SUBVOLUME, "",
271#endif // __linux__
272 DISK_USED_PERCENTAGE, percentage,
273 DISK_TOTAL, btotal,
274 DISK_FREE, bfree,
275 DISK_AVAIL, bavail,
276 DISK_USED, bused,
277 -1);
278#ifdef __linux__1
279 g_free (subvol);
280#endif // __linux__
281}
282
283
284
285int
286cb_update_disks(gpointer data)
287{
288 ProcData *const procdata = static_cast<ProcData*>(data);
289
290 GtkListStore *list;
291 glibtop_mountentry * entries;
292 glibtop_mountlist mountlist;
293 guint i;
294
295 list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)))((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_tree_view_get_model(((((GtkTreeView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((procdata->disk_list)), ((gtk_tree_view_get_type
()))))))))), ((gtk_list_store_get_type ()))))))
;
296
297 entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
298
299 remove_old_disks(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entries, mountlist.number);
300
301 for (i = 0; i < mountlist.number; i++)
302 add_disk(list, &entries[i], procdata->config.show_all_fs);
303
304 g_free(entries);
305
306 return TRUE(!(0));
307}
308
309
310static void
311cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
312{
313 ProcData * const procdata = static_cast<ProcData*>(user_data);
314
315 procman_save_tree_state(procdata->settings,
316 GTK_WIDGET(treeview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_widget_get_type ()))))))
,
317 "disktreenew");
318}
319
320
321static void
322open_dir(GtkTreeView *tree_view,
323 GtkTreePath *path,
324 GtkTreeViewColumn *column,
325 gpointer user_data)
326{
327 GtkTreeIter iter;
328 GtkTreeModel *model;
329 char *dir, *url;
330
331 model = gtk_tree_view_get_model(tree_view);
332
333 if (!gtk_tree_model_get_iter(model, &iter, path)) {
334 char *p;
335 p = gtk_tree_path_to_string(path);
336 g_warning("Cannot get iter for path '%s'\n", p);
337 g_free(p);
338 return;
339 }
340
341 gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
342
343 url = g_strdup_printf("file://%s", dir);
344
345 GError* error = 0;
346 if (!g_app_info_launch_default_for_uri(url, NULL__null, &error)) {
347 g_warning("Cannot open '%s' : %s\n", url, error->message);
348 g_error_free(error);
349 }
350
351 g_free(url);
352 g_free(dir);
353}
354
355static guint timeout_id = 0;
356static GtkTreeViewColumn *current_column;
357
358static gboolean
359save_column_width (gpointer data)
360{
361 gint width;
362 gchar *key;
363 int id;
364 GSettings *settings;
365
366 settings = g_settings_get_child (G_SETTINGS (data)((((GSettings*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((g_settings_get_type ()))))))
, "disktreenew");
367 id = gtk_tree_view_column_get_sort_column_id (current_column);
368 width = gtk_tree_view_column_get_width (current_column);
369
370 key = g_strdup_printf ("col-%d-width", id);
371 g_settings_set_int(settings, key, width);
372 g_free (key);
373
374 if (timeout_id) {
375 g_source_remove (timeout_id);
376 timeout_id = 0;
377 }
378
379 return FALSE(0);
380}
381
382static void
383cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
384{
385 current_column = GTK_TREE_VIEW_COLUMN(widget)((((GtkTreeViewColumn*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((widget)), ((gtk_tree_view_column_get_type (
)))))))
;
386
387 if (timeout_id)
388 g_source_remove (timeout_id);
389
390 timeout_id = g_timeout_add (250, save_column_width, data);
391}
392
393void
394create_disk_view(ProcData *procdata, GtkBuilder *builder)
395{
396 GtkWidget *scrolled;
397 GtkWidget *disk_tree;
398 GtkListStore *model;
399 GtkTreeViewColumn *col;
400 GtkCellRenderer *cell;
401 guint i;
402
403 const gchar * const titles[] = {
404 N_("Device")("Device"),
405 N_("Directory")("Directory"),
406 N_("Type")("Type"),
407 N_("SubVolume")("SubVolume"),
408 N_("Total")("Total"),
409 N_("Free")("Free"),
410 N_("Available")("Available"),
411 N_("Used")("Used")
412 };
413
414 scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "disks_scrolled"))), ((
gtk_widget_get_type ()))))))
;
415
416 model = gtk_list_store_new(DISK_N_COLUMNS, /* n columns */
417 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DEVICE */
418 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DIR */
419 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_TYPE */
420 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_SUBVOLUME */
421 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_TOTAL */
422 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_FREE */
423 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_AVAIL */
424 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_USED */
425 CAIRO_GOBJECT_TYPE_SURFACEcairo_gobject_surface_get_type (), /* DISK_ICON */
426 G_TYPE_INT((GType) ((6) << (2)))); /* DISK_USED_PERCENTAGE */
427
428 disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_model_get_type ()))))))
);
429 g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("row-activated"), (((GCallback) (open_dir))), (__null
), __null, (GConnectFlags) 0)
;
430 procdata->disk_list = disk_tree;
431 gtk_container_add(GTK_CONTAINER(scrolled)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((scrolled)), ((gtk_container_get_type ()))))))
, disk_tree);
432 g_object_unref(G_OBJECT(model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
);
433
434 /* icon + device */
435
436 col = gtk_tree_view_column_new();
437 cell = gtk_cell_renderer_pixbuf_new();
438 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
439 gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
440 NULL__null);
441
442 cell = gtk_cell_renderer_text_new();
443 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
444 gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
445 NULL__null);
446 gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE])gettext (titles[DISK_DEVICE]));
447 gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
448 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
449 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
450 gtk_tree_view_column_set_min_width (col, 30);
451 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
452 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
453 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
454
455 /* sizes - used */
456
457 for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
458 cell = gtk_cell_renderer_text_new();
459 col = gtk_tree_view_column_new();
460 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
461 gtk_tree_view_column_set_title(col, _(titles[i])gettext (titles[i]));
462 gtk_tree_view_column_set_sort_column_id(col, i);
463 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
464 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
465 gtk_tree_view_column_set_min_width (col, 30);
466 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
467 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
468 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
469
470 switch (i) {
471 case DISK_TOTAL:
472 case DISK_FREE:
473 case DISK_AVAIL:
474 g_object_set(cell, "xalign", 1.0f, NULL__null);
475 gtk_tree_view_column_set_cell_data_func(col, cell,
476 &procman::storage_size_cell_data_func,
477 GUINT_TO_POINTER(i)((gpointer) (gulong) (i)),
478 NULL__null);
479 break;
480
481 default:
482 gtk_tree_view_column_set_attributes(col, cell,
483 "text", i,
484 NULL__null);
485 break;
486 }
487 }
488
489 /* used + percentage */
490
491 col = gtk_tree_view_column_new();
492 cell = gtk_cell_renderer_text_new();
493 g_object_set(cell, "xalign", 1.0f, NULL__null);
494 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
495 gtk_tree_view_column_set_cell_data_func(col, cell,
496 &procman::storage_size_cell_data_func,
497 GUINT_TO_POINTER(DISK_USED)((gpointer) (gulong) (DISK_USED)),
498 NULL__null);
499
500 cell = gtk_cell_renderer_progress_new();
501 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
502 gtk_tree_view_column_set_attributes(col, cell, "value",
503 DISK_USED_PERCENTAGE, NULL__null);
504 gtk_tree_view_column_set_title(col, _(titles[DISK_USED])gettext (titles[DISK_USED]));
505 gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
506 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
507 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
508 gtk_tree_view_column_set_min_width (col, 150);
509 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
510 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
511 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
512
513 /* numeric sort */
514
515 procman_get_tree_state(procdata->settings, disk_tree,
516 "disktreenew");
517
518 g_signal_connect (G_OBJECT(disk_tree), "columns-changed",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
519 G_CALLBACK(cb_disk_columns_changed), procdata)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
;
520}
diff --git a/2023-10-16-150431-6168-1@71c61020bc59_master/report-c673b5.html b/2023-10-16-150431-6168-1@71c61020bc59_master/report-c673b5.html new file mode 100644 index 00000000..67fec022 --- /dev/null +++ b/2023-10-16-150431-6168-1@71c61020bc59_master/report-c673b5.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 564, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-150431-6168-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-16-150431-6168-1@71c61020bc59_master/report-d507c5.html b/2023-10-16-150431-6168-1@71c61020bc59_master/report-d507c5.html new file mode 100644 index 00000000..2c16b090 --- /dev/null +++ b/2023-10-16-150431-6168-1@71c61020bc59_master/report-d507c5.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 151, column 9
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-150431-6168-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
This statement is never executed
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2023-10-16-150431-6168-1@71c61020bc59_master/report-e8ff80.html b/2023-10-16-150431-6168-1@71c61020bc59_master/report-e8ff80.html new file mode 100644 index 00000000..2f44022a --- /dev/null +++ b/2023-10-16-150431-6168-1@71c61020bc59_master/report-e8ff80.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 350, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/librsvg-2.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-16-150431-6168-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 76 > (61)) || (2 == (2
) && 76 == (61) && 5 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2023-10-16-150431-6168-1@71c61020bc59_master/scanview.css b/2023-10-16-150431-6168-1@71c61020bc59_master/scanview.css new file mode 100644 index 00000000..cf8a5a6a --- /dev/null +++ b/2023-10-16-150431-6168-1@71c61020bc59_master/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/2023-10-16-150431-6168-1@71c61020bc59_master/sorttable.js b/2023-10-16-150431-6168-1@71c61020bc59_master/sorttable.js new file mode 100644 index 00000000..32faa078 --- /dev/null +++ b/2023-10-16-150431-6168-1@71c61020bc59_master/sorttable.js @@ -0,0 +1,492 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse',''); + cell.className = cell.className.replace('sorttable_sorted',''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j=0; j 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } + else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } + else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i=0; i=0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a,b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); + if (isNaN(bb)) bb = 0; + return aa-bb; + }, + sort_alpha: function(a,b) { + if (a[0]==b[0]) return 0; + if (a[0] 0 ) { + var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for(var i = t; i > b; --i) { + if ( comp_func(list[i], list[i-1]) < 0 ) { + var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write(" + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/optionentry.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+
+#include "argv.h"
+
+namespace procman
+{
+    OptionGroup::OptionGroup()
+        : Glib::OptionGroup("", ""),
+          show_system_tab(false),
+          show_processes_tab(false),
+          show_resources_tab(false),
+          show_file_systems_tab(false)
+    {
+        Glib::OptionEntry sys_tab;
+        sys_tab.set_long_name("show-system-tab");
+        sys_tab.set_short_name('s');
+        sys_tab.set_description(_("Show the System tab"));
+
+        Glib::OptionEntry proc_tab;
+        proc_tab.set_long_name("show-processes-tab");
+        proc_tab.set_short_name('p');
+        proc_tab.set_description(_("Show the Processes tab"));
+
+        Glib::OptionEntry res_tab;
+        res_tab.set_long_name("show-resources-tab");
+        res_tab.set_short_name('r');
+        res_tab.set_description(_("Show the Resources tab"));
+
+        Glib::OptionEntry fs_tab;
+        fs_tab.set_long_name("show-file-systems-tab");
+        fs_tab.set_short_name('f');
+        fs_tab.set_description(_("Show the File Systems tab"));
+
+        this->add_entry(sys_tab, this->show_system_tab);
+        this->add_entry(proc_tab, this->show_processes_tab);
+        this->add_entry(res_tab, this->show_resources_tab);
+        this->add_entry(fs_tab, this->show_file_systems_tab);
+    }
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/1.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/1.html new file mode 100644 index 00000000..9abf2d68 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/1.html @@ -0,0 +1,279 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
#ifndef H_PROCMAN_ARGV_1205873424
+#define H_PROCMAN_ARGV_1205873424
+
+#include <glibmm/optiongroup.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+namespace procman
+{
+    class OptionGroup
+        : public Glib::OptionGroup
+    {
+      public:
+        OptionGroup();
+
+        bool show_system_tab;
+        bool show_processes_tab;
+        bool show_resources_tab;
+        bool show_file_systems_tab;
+    };
+}
+
+#endif // H_PROCMAN_ARGV_1205873424
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/10.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/10.html new file mode 100644 index 00000000..4d43bbc7 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/10.html @@ -0,0 +1,391 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
/* Procman - tree view
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef _PROCMAN_PROCTABLE_H_
+#define _PROCMAN_PROCTABLE_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+enum
+{
+    COL_NAME = 0,
+    COL_USER,
+    COL_STATUS,
+    COL_VMSIZE,
+    COL_MEMRES,
+    COL_MEMWRITABLE,
+    COL_MEMSHARED,
+    COL_MEMXSERVER,
+    COL_CPU,
+    COL_CPU_TIME,
+    COL_START_TIME,
+    COL_NICE,
+    COL_PID,
+    COL_SECURITYCONTEXT,
+    COL_ARGS,
+    COL_MEM,
+    COL_WCHAN,
+    COL_CGROUP,
+    COL_UNIT,
+    COL_SESSION,
+    COL_SEAT,
+    COL_OWNER,
+    COL_DISK_WRITE_TOTAL,
+    COL_DISK_READ_TOTAL,
+    COL_DISK_WRITE_CURRENT,
+    COL_DISK_READ_CURRENT,
+    COL_PRIORITY,
+    COL_SURFACE,
+    COL_POINTER,
+    COL_TOOLTIP,
+    NUM_COLUMNS
+};
+
+GtkWidget*      proctable_new (ProcData *data);
+void            proctable_update_table (ProcData *data);
+void            proctable_update (ProcData *data);
+void            proctable_clear_tree (ProcData *data);
+void            proctable_free_table (ProcData *data);
+
+GSList*         proctable_get_columns_order(GtkTreeView *treeview);
+void            proctable_set_columns_order(GtkTreeView *treeview, GSList *order);
+
+char*           make_loadavg_string(void);
+
+void            get_last_selected (GtkTreeModel *model, GtkTreePath *path,
+                                   GtkTreeIter *iter, gpointer data);
+
+#endif /* _PROCMAN_PROCTABLE_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/11.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/11.html new file mode 100644 index 00000000..cd51236f --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/11.html @@ -0,0 +1,499 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
// -*- mode: c++ -*-
+
+#ifndef H_MATE_SYSTEM_MONITOR_UTIL_1123178725
+#define H_MATE_SYSTEM_MONITOR_UTIL_1123178725
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+using std::string;
+
+/* check if logind is running */
+#define LOGIND_RUNNING() (access("/run/systemd/seats/", F_OK) >= 0)
+
+GtkWidget*
+procman_make_label_for_mmaps_or_ofiles(const char *format,
+                                       const char *process_name,
+                                       unsigned pid);
+
+gboolean
+load_symbols(const char *module, ...) G_GNUC_NULL_TERMINATED;
+
+gchar *
+procman_format_date_for_display(time_t time_raw);
+
+const char*
+format_process_state(guint state);
+
+void
+procman_debug_real(const char *file, int line, const char *func,
+                   const char *format, ...) G_GNUC_PRINTF(4, 5);
+
+#define procman_debug(FMT, ...) procman_debug_real(__FILE__, __LINE__, __func__, FMT, ##__VA_ARGS__)
+
+inline string make_string(char *c_str)
+{
+    if (!c_str) {
+        procman_debug("NULL string");
+        return string();
+    }
+
+    string s(c_str);
+    g_free(c_str);
+    return s;
+}
+
+namespace procman
+{
+    gchar* format_duration_for_display(unsigned centiseconds);
+
+    void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                    GtkTreeModel *model, GtkTreeIter *iter,
+                                    gpointer user_data);
+
+    void io_rate_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                GtkTreeModel *model, GtkTreeIter *iter,
+                                gpointer user_data);
+
+    void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                       GtkTreeModel *model, GtkTreeIter *iter,
+                                       gpointer user_data);
+
+    void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                     GtkTreeModel *model, GtkTreeIter *iter,
+                                     gpointer user_data);
+
+    void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                        GtkTreeModel *model, GtkTreeIter *iter,
+                                        gpointer user_data);
+
+    void duration_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                   GtkTreeModel *model, GtkTreeIter *iter,
+                   gpointer user_data);
+
+    void time_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                             GtkTreeModel *model, GtkTreeIter *iter,
+                             gpointer user_data);
+
+    void status_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                               GtkTreeModel *model, GtkTreeIter *iter,
+                               gpointer user_data);
+    void priority_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                               GtkTreeModel *model, GtkTreeIter *iter,
+                               gpointer user_data);
+    gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
+                            GtkTreeIter* second, gpointer user_data);
+    gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
+                            GtkTreeIter* second, gpointer user_data);
+
+    template<typename T>
+    void poison(T &t, char c)
+    {
+        memset(&t, c, sizeof t);
+    }
+
+    //
+    // Stuff to update a tree_store in a smart way
+    //
+
+    template<typename T>
+    void tree_store_update(GtkTreeModel* model, GtkTreeIter* iter, int column, const T& new_value)
+    {
+        T current_value;
+
+        gtk_tree_model_get(model, iter, column, &current_value, -1);
+
+        if (current_value != new_value)
+            gtk_tree_store_set(GTK_TREE_STORE(model), iter, column, new_value, -1);
+    }
+
+    // undefined
+    // catch every thing about pointers
+    // just to make sure i'm not doing anything wrong
+    template<typename T>
+    void tree_store_update(GtkTreeModel* model, GtkTreeIter* iter, int column, T* new_value);
+
+    // specialized versions for strings
+    template<>
+    void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value);
+
+    template<>
+    inline void tree_store_update<char>(GtkTreeModel* model, GtkTreeIter* iter, int column, char* new_value)<--- Parameter 'new_value' can be declared as pointer to const
+    {
+         tree_store_update<const char>(model, iter, column, new_value);
+    }
+
+    gchar* get_nice_level (gint nice);
+}
+
+#endif /* H_MATE_SYSTEM_MONITOR_UTIL_1123178725 */
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/12.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/12.html new file mode 100644 index 00000000..5c3897fb --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/12.html @@ -0,0 +1,341 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
/* Procman - dialogs
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef _PROCDIALOGS_H_
+#define _PROCDIALOGS_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+/* These are the actual range of settable values. Values outside this range
+   are scaled back to these limits. So show these limits in the slider
+*/
+#ifdef __linux__
+#define RENICE_VAL_MIN -20
+#define RENICE_VAL_MAX 19
+#else /* ! linux */
+#define RENICE_VAL_MIN -20
+#define RENICE_VAL_MAX 20
+#endif
+
+typedef enum
+{
+    PROCMAN_ACTION_RENICE,
+    PROCMAN_ACTION_KILL
+} ProcmanActionType;
+
+void                    procdialog_create_kill_dialog (ProcData *data, int signal);
+void                    procdialog_create_renice_dialog (ProcData *data);
+gboolean                procdialog_create_root_password_dialog (ProcmanActionType type,
+                                                                ProcData *procdata,
+                                                                gint pid, gint extra_value);
+void                    procdialog_create_memmaps_dialog (ProcData *data);
+void                    procdialog_create_preferences_dialog (ProcData *data);
+
+#endif
+
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/13.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/13.html new file mode 100644 index 00000000..07b0403f --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/13.html @@ -0,0 +1,255 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
1
+2
+3
+4
+5
+6
+7
+8
+9
#ifndef _PROCMAN_MEMMAPS_H_
+#define _PROCMAN_MEMMAPS_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+void            create_memmaps_dialog (ProcData *procdata);
+
+#endif /* _PROCMAN_MEMMAPS_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/14.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/14.html new file mode 100644 index 00000000..b5c26f21 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/14.html @@ -0,0 +1,257 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
#ifndef _OPENFILES_H_
+#define _OPENFILES_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+void            create_openfiles_dialog (ProcData *procdata);
+
+#endif
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/15.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/15.html new file mode 100644 index 00000000..119b30ea --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/15.html @@ -0,0 +1,299 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
/* Process properties dialog
+ * Copyright (C) 2010 Krishnan Parthasarathi <krishnan.parthasarathi@gmail.com>
+ *                    Robert Ancell <robert.ancell@canonical.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef _PROCPROPERTIES_H_
+#define _PROCPROPERTIES_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+void create_procproperties_dialog (ProcData *procdata);
+
+#endif
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/16.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/16.html new file mode 100644 index 00000000..553dbda6 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/16.html @@ -0,0 +1,489 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
#ifndef _PROCMAN_LOAD_GRAPH_H_
+#define _PROCMAN_LOAD_GRAPH_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+enum
+{
+    LOAD_GRAPH_CPU,
+    LOAD_GRAPH_MEM,
+    LOAD_GRAPH_NET
+};
+
+enum {
+    CPU_TOTAL,
+    CPU_USED,
+    N_CPU_STATES
+};
+
+struct LoadGraphLabels
+{
+    GtkWidget *cpu[GLIBTOP_NCPU];
+    GtkWidget *memory;
+    GtkWidget *swap;
+    GtkWidget *net_in;
+    GtkWidget *net_in_total;
+    GtkWidget *net_out;
+    GtkWidget *net_out_total;
+};
+
+struct LoadGraph {
+
+    static const unsigned NUM_POINTS = 60 + 2;
+    static const unsigned GRAPH_MIN_HEIGHT = 40;
+
+    LoadGraph(guint type);
+    ~LoadGraph();
+
+    unsigned num_bars() const;
+    void clear_background();
+
+    double fontsize;
+    double rmargin;
+    double indent;
+
+    guint n;
+    gint type;
+    guint speed;
+    guint draw_width, draw_height;
+    guint render_counter;
+    guint frames_per_unit;
+    guint graph_dely;
+    guint real_draw_height;
+    double graph_delx;
+    guint graph_buffer_offset;
+
+    std::vector<GdkRGBA> colors;
+
+    std::vector<float> data_block;
+    gfloat* data[NUM_POINTS];
+
+    GtkWidget *main_widget;
+    GtkWidget *disp;
+
+    cairo_pattern_t *background;
+
+    guint timer_index;
+
+    gboolean draw;
+
+    LoadGraphLabels labels;
+    GtkWidget *mem_color_picker;
+    GtkWidget *swap_color_picker;
+
+    /* union { */
+        struct {
+            guint now; /* 0 -> current, 1 -> last
+                    now ^ 1 each time */
+            /* times[now], times[now ^ 1] is last */
+            guint64 times[2][GLIBTOP_NCPU][N_CPU_STATES];
+        } cpu;
+
+        struct {
+            guint64 last_in, last_out;
+#if GLIB_CHECK_VERSION(2,61,2)
+            gint64 time;
+#else
+            GTimeVal time;
+#endif
+            guint64 max;
+            unsigned values[NUM_POINTS];
+            size_t cur;
+        } net;
+    /* }; */
+};
+
+/* Force a drawing update */
+void
+load_graph_queue_draw (LoadGraph *g);
+
+/* Start load graph. */
+void
+load_graph_start (LoadGraph *g);
+
+/* Stop load graph. */
+void
+load_graph_stop (LoadGraph *g);
+
+/* Change load graph speed and restart it if it has been previously started */
+void
+load_graph_change_speed (LoadGraph *g,
+                         guint new_speed);
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+#endif /* _PROCMAN_LOAD_GRAPH_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/17.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/17.html new file mode 100644 index 00000000..40d7d2b5 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/17.html @@ -0,0 +1,255 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
1
+2
+3
+4
+5
+6
+7
+8
+9
#ifndef H_PROCMAN_LSOF_1161179202
+#define H_PROCMAN_LSOF_1161179202
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+void procman_lsof(ProcData *data);
+
+#endif /* H_PROCMAN_LSOF_1161179202 */
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/18.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/18.html new file mode 100644 index 00000000..6cfdc63e --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/18.html @@ -0,0 +1,645 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <cstring><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "cgroups.h"
+#include "util.h"
+
+gboolean
+cgroups_enabled(void)
+{
+    static gboolean initialized = FALSE;
+    static gboolean has_cgroups;
+
+    if (!initialized) {
+        initialized = TRUE;
+        has_cgroups = g_file_test("/proc/cgroups", G_FILE_TEST_EXISTS);
+    }
+
+    return has_cgroups;
+}
+
+static void
+append_cgroup_name(char *line, gchar **current_cgroup_name)
+{
+    gchar *controller, *path, *tmp, *path_plus_space;
+    int paren_offset, off, tmp_size;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return;
+
+    *(path - 1) = '\0';
+    g_strdelimit(controller, ",", '/');
+
+    if ((std::strcmp(path, "/") == 0) || (std::strncmp(controller, "name=", 5) == 0))
+        return;
+
+    if (*current_cgroup_name == NULL) {
+        *current_cgroup_name = g_strdup_printf("%s (%s)", path, controller);
+        return;
+    }
+
+    /* add a space to the end of the path string */
+    path_plus_space = g_strdup_printf("%s ", path);
+
+    if ((tmp = g_strstr_len(*current_cgroup_name, -1, path_plus_space))) {
+        tmp_size = strlen(*current_cgroup_name) + strlen(controller) + 1;
+        paren_offset = g_strstr_len(tmp + strlen(path), -1, ")") - *current_cgroup_name;
+        *(*current_cgroup_name + paren_offset) = '\0';
+        tmp = (gchar *)g_strnfill(tmp_size, '\0');
+        off = g_strlcat(tmp, *current_cgroup_name, tmp_size);
+        *(tmp + off) = '/';
+        off++;
+        off += g_strlcat(tmp + off, controller, tmp_size);
+        *(tmp + off) = ')';
+        off++;
+        g_strlcat(tmp + off, *current_cgroup_name + paren_offset + 1, tmp_size);
+    } else
+        tmp = g_strdup_printf("%s, %s(%s)", *current_cgroup_name, path_plus_space, controller);
+
+    g_free(path_plus_space);
+    g_free(*current_cgroup_name);
+    *current_cgroup_name = tmp;
+}
+
+static int
+check_cgroup_changed(gchar *line, gchar *current_cgroup_set)
+{
+    /* check if line is contained in current_cgroup_set */
+    gchar *controller, *path, *tmp, *found, *close_paren, *open_paren;
+    int ret = 0;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return 1;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return 1;
+
+    *(path - 1) = '\0';
+
+    if (std::strncmp(controller, "name=", 5) == 0)
+        goto out;
+
+    /* if there are multiple controllers just report string has changed */
+    if (g_strstr_len(controller, -1, ",")) {
+        ret = 1;
+        goto out;
+    }
+
+    if (!current_cgroup_set) {
+        if (std::strcmp(path, "/") != 0)
+            ret = 1;
+        goto out;
+    }
+
+    /* special case for root cgroup */
+    tmp = current_cgroup_set;
+    if (std::strcmp(path, "/") == 0) {
+        while ((found = g_strstr_len(tmp, -1, controller))) {
+            close_paren = g_strstr_len(found, -1, ")");
+            open_paren = g_strstr_len(found, -1, "(");
+            if (close_paren) {
+                if (!open_paren || (close_paren < open_paren)) {
+                    ret = 1;
+                    goto out;
+                }
+            }
+            tmp = found + strlen(controller);
+        }
+        goto out;
+    }
+
+    tmp = current_cgroup_set;
+    while ((found = g_strstr_len(tmp, -1, path))) {
+            found = found + strlen(path);
+            close_paren = g_strstr_len(found, -1, ")");
+            if (*found == ' ') {
+                if (g_strstr_len(found + 1, close_paren - found, controller))
+                    goto out;
+            }
+            tmp = close_paren + 1;
+    }
+    ret = 1;
+out:
+    *(path - 1) = ':';
+    return ret;
+}
+
+void
+get_process_cgroup_info(ProcInfo *info)
+{
+    gchar *path;
+    gchar *cgroup_name = NULL;
+    int cgroups_changed = 0;
+    gchar *text;
+    char **lines;
+    int i;
+
+    if (!cgroups_enabled())
+        return;
+
+    /* read out of /proc/pid/cgroup */
+    path = g_strdup_printf("/proc/%d/cgroup", info->pid);
+    if (!path)
+        return;
+    if(!g_file_get_contents(path, &text, NULL, NULL))
+        goto out;
+    lines = g_strsplit(text, "\n", -1);
+    g_free(text);
+    if (!lines)
+        goto out;
+
+    for (i = 0; lines[i] != NULL; i++) {
+        if (lines[i][0] == '\0')
+            continue;
+        if (check_cgroup_changed(lines[i], info->cgroup_name)) {
+            cgroups_changed = 1;
+            break;
+        }
+    }
+
+    if (cgroups_changed) {
+        for (i = 0; lines[i] != NULL; i++) {
+            if (lines[i][0] == '\0')
+                continue;
+            append_cgroup_name(lines[i], &cgroup_name);
+        }
+        if (info->cgroup_name)
+            g_free(info->cgroup_name);
+        if (!cgroup_name)
+            info->cgroup_name = g_strdup("");
+        else
+            info->cgroup_name = cgroup_name;
+    }
+
+    g_strfreev(lines);
+out:
+    g_free(path);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/19.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/19.html new file mode 100644 index 00000000..f9dfbcbd --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/19.html @@ -0,0 +1,261 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
#ifndef PROCMAN_CGROUP_H_20111103
+#define PROCMAN_CGROUP_H_20111103
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+void get_process_cgroup_info (ProcInfo *info);
+
+gboolean cgroups_enabled (void);
+
+#endif /* PROCMAN_CGROUP_H_20111103 */
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/2.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/2.html new file mode 100644 index 00000000..ddc7b909 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/2.html @@ -0,0 +1,1289 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
/* Procman - callbacks
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <giomm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "callbacks.h"
+#include "interface.h"
+#include "proctable.h"
+#include "util.h"
+#include "procactions.h"
+#include "procman.h"
+#include "procdialogs.h"
+#include "memmaps.h"
+#include "openfiles.h"
+#include "procproperties.h"
+#include "load-graph.h"
+#include "disks.h"
+#include "lsof.h"
+#include "sysinfo.h"
+
+void
+cb_kill_sigstop(GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    /* no confirmation */
+    kill_process (procdata, SIGSTOP);
+}
+
+
+
+
+void
+cb_kill_sigcont(GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    /* no confirmation */
+    kill_process (procdata, SIGCONT);
+}
+
+
+
+
+static void
+kill_process_helper(ProcData *procdata, int sig)
+{
+    if (procdata->config.show_kill_warning)
+        procdialog_create_kill_dialog (procdata, sig);
+    else
+        kill_process (procdata, sig);
+}
+
+
+void
+cb_edit_preferences (GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdialog_create_preferences_dialog (procdata);
+}
+
+
+void
+cb_renice (GtkAction *action, GtkRadioAction *current, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    gint selected = gtk_radio_action_get_current_value(current);
+
+    if (selected == CUSTOM_PRIORITY)
+    {
+       procdialog_create_renice_dialog (procdata);
+    } else {
+       gint new_nice_value = 0;
+       switch (selected) {
+           case VERY_HIGH_PRIORITY: new_nice_value = -20; break;
+           case HIGH_PRIORITY: new_nice_value = -5; break;
+           case NORMAL_PRIORITY: new_nice_value = 0; break;
+           case LOW_PRIORITY: new_nice_value = 5; break;
+           case VERY_LOW_PRIORITY: new_nice_value = 19; break;
+       }
+       renice(procdata, new_nice_value);
+    }
+}
+
+
+void
+cb_end_process (GtkAction *action, gpointer data)
+{
+    kill_process_helper(static_cast<ProcData*>(data), SIGTERM);
+}
+
+
+void
+cb_kill_process (GtkAction *action, gpointer data)
+{
+    kill_process_helper(static_cast<ProcData*>(data), SIGKILL);
+}
+
+
+void
+cb_show_memory_maps (GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    create_memmaps_dialog (procdata);
+}
+
+void
+cb_show_open_files (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    create_openfiles_dialog (procdata);
+}
+
+void
+cb_show_process_properties (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    create_procproperties_dialog (procdata);
+}
+
+void
+cb_show_lsof(GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    procman_lsof(procdata);
+}
+
+
+void
+cb_about (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    const gchar * const authors[] = {
+        "Adam Erdman <hekel@archlinux.info>",
+        "Alexander Pyhalov <apyhalov@gmail.com>",
+        "Andreas Nilsson <nisses.mail@home.se>",
+        "Benoît Dejean <bdejean@gmail.com>",
+        "Chris Kühl <chrisk@openismus.com>",
+        "Clement Lefebvre <clement.lefebvre@linuxmint.com>",
+        "Elias Aebi <user142@hotmail.com>",
+        "Erik Johnsson",
+        "Jorgen Scheibengruber",
+        "Karl Lattimer",
+        "Kevin Vandersloot",
+        "Laurent Napias <tamplan@free.fr>",
+        "Marcel Dijkstra <marcel.dykstra@gmail.com>",
+        "Martin Wimpress <martin@mate-desktop.org>",
+        "Matias De lellis <mati86dl@gmail.com>",
+        "Mike Gabriel <mike.gabriel@das-netzwerkteam.de>",
+        "Nelson Marques <nmo.marques@gmail.com>",
+        "Obata Akio https://github.com/obache",
+        "Pablo Barciela <scow@riseup.net>",
+        "Paolo Borelli",
+        "Perberos <perberos@gmail.com>",
+        "Piotr DrÄ…g <piotrdrag@gmail.com>",
+        "Robert Buj <robert.buj@gmail.com>",
+        "Sander Sweers <infirit@gmail.com>",
+        "Scott Balneaves <sbalneav@alburg.net>",
+        "Soong Noonien https://github.com/SoongNoonien",
+        "Stefano Karapetsas <stefano@karapetsas.com>",
+        "Steve Zesch <stevezesch2@gmail.com>",
+        "Victor Kareh <vkareh@redhat.com>",
+        "Vlad Orlov <monsta@inbox.ru>",
+        "Wolfgang Ulbrich <mate@raveit.de>",
+        "Wu Xiaotian <yetist@gmail.com>",
+        "Yaakov Selkowitz <yselkowitz@users.sourceforge.net>",
+        "Youri Mouton <youri@NetBSD.org>",
+        NULL
+    };
+
+    const gchar * const documenters[] = {
+        "Bill Day",
+        "Sun Microsystems",
+        NULL
+    };
+
+    const gchar * const artists[] = {
+        "Baptiste Mille-Mathias",
+        NULL
+    };
+
+    const gchar * license[] = {
+        N_("System Monitor is free software; you can redistribute it and/or modify "
+        "it under the terms of the GNU General Public License as published by "
+        "the Free Software Foundation; either version 2 of the License, or "
+        "(at your option) any later version."),
+        N_("System Monitor is distributed in the hope that it will be useful, "
+        "but WITHOUT ANY WARRANTY; without even the implied warranty of "
+        "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the "
+        "GNU General Public License for more details."),
+        N_("You should have received a copy of the GNU General Public License "
+        "along with System Monitor; if not, write to the Free Software Foundation, Inc., "
+        "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA")
+    };
+
+    gchar *license_trans;
+    license_trans = g_strjoin ("\n\n", _(license[0]), _(license[1]), _(license[2]), NULL);
+
+    gtk_show_about_dialog (
+        GTK_WINDOW (procdata->app),
+        "program-name",       _("System Monitor"),
+        "version",            VERSION,
+        "title",              _("About System Monitor"),
+        "comments",           _("View current processes and monitor system state"),
+        "copyright",          _("Copyright \xc2\xa9 2001-2004 Kevin Vandersloot\n"
+                                "Copyright \xc2\xa9 2005-2007 Benoît Dejean\n"
+                                "Copyright \xc2\xa9 2011-2020 MATE developers"),
+        "logo-icon-name",     "utilities-system-monitor",
+        "authors",            authors,
+        "artists",            artists,
+        "documenters",        documenters,
+        "translator-credits", _("translator-credits"),
+        "license",            license_trans,
+        "wrap-license",       TRUE,
+        "website",            PACKAGE_URL,
+        NULL
+        );
+
+    g_free (license_trans);
+}
+
+
+void
+cb_help_contents (GtkAction *action, gpointer data)
+{
+    GError* error = 0;
+    if (!g_app_info_launch_default_for_uri("help:mate-system-monitor", NULL, &error)) {
+        g_warning("Could not display help : %s", error->message);
+        g_error_free(error);
+    }
+}
+
+
+void
+cb_app_exit (GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    cb_app_delete (NULL, NULL, procdata);
+    gtk_widget_destroy (procdata->app);
+}
+
+
+gboolean
+cb_app_delete (GtkWidget *window, GdkEventAny *event, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procman_save_config (procdata);
+    if (procdata->timeout)
+        g_source_remove (procdata->timeout);
+    if (procdata->disk_timeout)
+        g_source_remove (procdata->disk_timeout);
+
+    procdata->terminating = TRUE;
+
+    return FALSE;
+}
+
+
+
+void
+cb_end_process_button_pressed (GtkButton *button, gpointer data)
+{
+    kill_process_helper(static_cast<ProcData*>(data), SIGTERM);
+}
+
+
+static void change_settings_color(GSettings *settings, const char *key,
+                   GSMColorButton *cp)
+{
+    GdkRGBA c;
+    char *color;
+
+    gsm_color_button_get_color(cp, &c);
+    color = gdk_rgba_to_string (&c);
+    g_settings_set_string (settings, key, color);
+    g_free (color);
+}
+
+
+void
+cb_cpu_color_changed (GSMColorButton *cp, gpointer data)
+{
+    char key[80];
+    gint i = GPOINTER_TO_INT (data);
+    GSettings *settings = g_settings_new (GSM_GSETTINGS_SCHEMA);
+
+    g_snprintf(key, sizeof key, "cpu-color%d", i);
+
+    change_settings_color(settings, key, cp);
+}
+
+void
+cb_mem_color_changed (GSMColorButton *cp, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    change_settings_color(procdata->settings, "mem-color", cp);
+}
+
+
+void
+cb_swap_color_changed (GSMColorButton *cp, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    change_settings_color(procdata->settings, "swap-color", cp);
+}
+
+void
+cb_net_in_color_changed (GSMColorButton *cp, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    change_settings_color(procdata->settings, "net-in-color", cp);
+}
+
+void
+cb_net_out_color_changed (GSMColorButton *cp, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    change_settings_color(procdata->settings, "net-out-color", cp);
+}
+
+void
+cb_row_selected (GtkTreeSelection *selection, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->selection = selection;
+
+    procdata->selected_process = NULL;
+
+    /* get the most recent selected process and determine if there are
+    ** no selected processes
+    */
+    gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                         &procdata->selected_process);
+    if (procdata->selected_process) {
+        gint value;
+        gint nice = procdata->selected_process->nice;
+        if (nice < -7)
+            value = VERY_HIGH_PRIORITY;
+        else if (nice < -2)
+            value = HIGH_PRIORITY;
+        else if (nice < 3)
+            value = NORMAL_PRIORITY;
+        else if (nice < 7)
+            value = LOW_PRIORITY;
+        else
+            value = VERY_LOW_PRIORITY;
+
+        GtkRadioAction* normal = GTK_RADIO_ACTION(gtk_action_group_get_action(procdata->action_group, "Normal"));
+        block_priority_changed_handlers(procdata, TRUE);
+        gtk_radio_action_set_current_value(normal, value);
+        block_priority_changed_handlers(procdata, FALSE);
+
+    }
+    update_sensitivity(procdata);
+}
+
+
+gboolean
+cb_tree_button_pressed (GtkWidget *widget,
+            GdkEventButton *event,
+            gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
+        do_popup_menu (procdata, event);
+
+    return FALSE;
+}
+
+
+gboolean
+cb_tree_popup_menu (GtkWidget *widget, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    do_popup_menu (procdata, NULL);
+
+    return TRUE;
+}
+
+
+void
+cb_switch_page (GtkNotebook *nb, GtkWidget *page,
+        gint num, gpointer data)
+{
+    cb_change_current_page (nb, num, data);
+}
+
+void
+cb_change_current_page (GtkNotebook *nb, gint num, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->config.current_tab = num;
+
+
+    if (num == PROCMAN_TAB_PROCESSES) {
+
+        cb_timeout (procdata);
+
+        if (!procdata->timeout)
+            procdata->timeout = g_timeout_add (
+                procdata->config.update_interval,
+                cb_timeout, procdata);
+
+        update_sensitivity(procdata);
+    }
+    else {
+        if (procdata->timeout) {
+            g_source_remove (procdata->timeout);
+            procdata->timeout = 0;
+        }
+
+        update_sensitivity(procdata);
+    }
+
+
+    if (num == PROCMAN_TAB_RESOURCES) {
+        load_graph_start (procdata->cpu_graph);
+        load_graph_start (procdata->mem_graph);
+        load_graph_start (procdata->net_graph);
+    }
+    else {
+        load_graph_stop (procdata->cpu_graph);
+        load_graph_stop (procdata->mem_graph);
+        load_graph_stop (procdata->net_graph);
+    }
+
+
+    if (num == PROCMAN_TAB_DISKS) {
+
+        cb_update_disks (procdata);
+
+        if(!procdata->disk_timeout) {
+            procdata->disk_timeout =
+                g_timeout_add (procdata->config.disks_update_interval,
+                           cb_update_disks,
+                           procdata);
+        }
+    }
+    else {
+        if(procdata->disk_timeout) {
+            g_source_remove (procdata->disk_timeout);
+            procdata->disk_timeout = 0;
+        }
+    }
+
+    if (num == PROCMAN_TAB_SYSINFO) {
+        procman::build_sysinfo_ui();
+    }
+}
+
+
+
+gint
+cb_user_refresh (GtkAction*, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    proctable_update (procdata);
+    return FALSE;
+}
+
+
+gint
+cb_timeout (gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    guint new_interval;
+
+    if (!procdata->terminating) {
+        proctable_update (procdata);
+
+        if (procdata->smooth_refresh->get(new_interval))
+        {
+            procdata->timeout = g_timeout_add(new_interval,
+                                              cb_timeout,
+                                              procdata);
+            return FALSE;
+        }
+    }
+    return TRUE;
+}
+
+
+void
+cb_radio_processes(GtkAction *action, GtkRadioAction *current, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->config.whose_process = gtk_radio_action_get_current_value(current);
+
+    g_settings_set_int (procdata->settings, "view-as",
+                  procdata->config.whose_process);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/20.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/20.html new file mode 100644 index 00000000..14abdda6 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/20.html @@ -0,0 +1,1277 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __linux__
+#include <mntent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif // __linux__
+
+#include <giomm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/themedicon.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mountlist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/fsusage.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "disks.h"
+#include "util.h"
+#include "interface.h"
+#include "iconthemewrapper.h"
+
+namespace
+{
+  const unsigned DISK_ICON_SIZE = 24;
+}
+
+enum DiskColumns
+{
+    /* string columns* */
+    DISK_DEVICE,
+    DISK_DIR,
+    DISK_TYPE,
+    DISK_SUBVOLUME,
+    DISK_TOTAL,
+    DISK_FREE,
+    DISK_AVAIL,
+    /* USED has to be the last column */
+    DISK_USED,
+    // then unvisible columns
+    /* Surface column */
+    DISK_ICON,
+    /* numeric columns */
+    DISK_USED_PERCENTAGE,
+    DISK_N_COLUMNS
+};
+
+
+
+static void
+fsusage_stats(const glibtop_fsusage *buf,
+              guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
+              gint *percentage)
+{
+    guint64 total = buf->blocks * buf->block_size;
+
+    if (!total) {
+        /* not a real device */
+        *btotal = *bfree = *bavail = *bused = 0ULL;
+        *percentage = 0;
+    } else {
+        int percent;
+        *btotal = total;
+        *bfree = buf->bfree * buf->block_size;
+        *bavail = buf->bavail * buf->block_size;
+        *bused = *btotal - *bfree;
+        /* percent = 100.0f * *bused / *btotal; */
+        percent = 100 * *bused / (*bused + *bavail);
+        *percentage = CLAMP(percent, 0, 100);
+    }
+}
+
+
+namespace
+{
+    string get_icon_for_path(const std::string& path)
+    {
+        using namespace Glib;
+        using namespace Gio;
+
+        // FIXME: I don't know whether i should use Volume or Mount or UnixMount
+        // all i need an icon name.
+        RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+        std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
+
+        for (size_t i = 0; i != mounts.size(); ++i) {
+            if (mounts[i]->get_name() != path)
+                continue;
+
+            RefPtr<Icon> icon = mounts[i]->get_icon();
+            RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
+
+            if (themed_icon) {
+                char* name = 0;
+                // FIXME: not wrapped yet
+                g_object_get(G_OBJECT(themed_icon->gobj()), "name", &name, NULL);
+                return make_string(name);
+            }
+        }
+
+        return "";
+    }
+}
+
+
+static Glib::RefPtr<Gdk::Pixbuf>
+get_icon_for_device(const char *mountpoint)
+{
+    procman::IconThemeWrapper icon_theme;
+    string icon_name = get_icon_for_path(mountpoint);
+    if (icon_name == "")
+        // FIXME: defaults to a safe value
+        icon_name = "drive-harddisk"; // get_icon_for_path("/");
+    return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
+}
+
+
+static gboolean
+find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
+                   GtkTreeIter *result)
+{
+    GtkTreeIter iter;
+    gboolean found = FALSE;
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        do {
+            char *dir;
+
+            gtk_tree_model_get(model, &iter,
+                               DISK_DIR, &dir,
+                               -1);
+
+            if (dir && !strcmp(dir, mountpoint)) {
+                *result = iter;
+                found = TRUE;
+            }
+
+            g_free(dir);
+
+        } while (!found && gtk_tree_model_iter_next(model, &iter));
+    }
+
+    return found;
+}
+
+
+
+static void
+remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
+{
+    GtkTreeIter iter;
+
+    if (!gtk_tree_model_get_iter_first(model, &iter))
+        return;
+
+    while (true) {
+        char *dir;
+        guint i;
+        gboolean found = FALSE;
+
+        gtk_tree_model_get(model, &iter,
+                           DISK_DIR, &dir,
+                           -1);
+
+        for (i = 0; i != n; ++i) {
+            if (!strcmp(dir, entries[i].mountdir)) {
+                found = TRUE;
+                break;
+            }
+        }
+
+        g_free(dir);
+
+        if (!found) {
+            if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                break;
+            else
+                continue;
+        }
+
+        if (!gtk_tree_model_iter_next(model, &iter))
+            break;
+    }
+}
+
+#ifdef __linux__
+static char *
+get_mount_opt(const glibtop_mountentry *entry, const char* opt)
+{
+    char *opt_value = NULL;
+    const struct mntent *mnt;
+    FILE *fp;
+
+    if (!(fp = setmntent(MOUNTED, "r"))) {
+        goto out;
+    }
+
+    while ((mnt = getmntent(fp))) {
+        if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
+            (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
+            char *res;
+
+            res = hasmntopt(mnt, "subvol");<--- res is assigned
+            if ((res = hasmntopt(mnt, "subvol")) != NULL) {<--- res is overwritten
+                char **strs = g_strsplit_set(res, "=", 2);
+
+                if (g_strv_length(strs) == 2) {
+                    char *value = strs[1];
+                    if (g_strcmp0 (value,"/root") == 0)
+                       opt_value = g_strdup("/");
+                    else
+                        opt_value = g_strdup(strs[1]);
+                    g_strfreev(strs);
+                }
+            }
+            break;
+        }
+    }
+
+    endmntent(fp);
+
+  out:
+     return opt_value;
+}
+#endif // __linux__
+
+
+static void
+add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
+{
+    Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+    cairo_surface_t *surface;
+    GtkTreeIter iter;
+    glibtop_fsusage usage;
+    guint64 bused, bfree, bavail, btotal;
+    gint percentage;
+#ifdef __linux__
+    char *subvol = NULL;
+#endif // __linux__
+
+    glibtop_get_fsusage(&usage, entry->mountdir);
+
+    if (not show_all_fs and usage.blocks == 0) {
+        if (find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+            gtk_list_store_remove(list, &iter);
+        return;
+    }
+
+    fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
+#ifdef __linux__
+    subvol = get_mount_opt(entry, "subvol");
+#endif // __linux__
+    pixbuf = get_icon_for_device(entry->mountdir);
+    surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL);
+
+    /* if we can find a row with the same mountpoint, we get it but we
+       still need to update all the fields.
+       This makes selection persistent.
+    */
+    if (!find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+        gtk_list_store_append(list, &iter);
+
+    gtk_list_store_set(list, &iter,
+                       DISK_ICON, surface,
+                       DISK_DEVICE, entry->devname,
+                       DISK_DIR, entry->mountdir,
+                       DISK_TYPE, entry->type,
+#ifdef __linux__
+
+                       DISK_SUBVOLUME, subvol != NULL ? subvol : "",
+#else
+                       DISK_SUBVOLUME, "",
+#endif // __linux__
+                       DISK_USED_PERCENTAGE, percentage,
+                       DISK_TOTAL, btotal,
+                       DISK_FREE, bfree,
+                       DISK_AVAIL, bavail,
+                       DISK_USED, bused,
+                       -1);
+#ifdef __linux__
+    g_free (subvol);
+#endif // __linux__
+}
+
+
+
+int
+cb_update_disks(gpointer data)
+{
+    ProcData *const procdata = static_cast<ProcData*>(data);
+
+    GtkListStore *list;
+    glibtop_mountentry * entries;
+    glibtop_mountlist mountlist;
+    guint i;
+
+    list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)));
+
+    entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
+
+    remove_old_disks(GTK_TREE_MODEL(list), entries, mountlist.number);
+
+    for (i = 0; i < mountlist.number; i++)
+        add_disk(list, &entries[i], procdata->config.show_all_fs);
+
+    g_free(entries);
+
+    return TRUE;
+}
+
+
+static void
+cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "disktreenew");
+}
+
+
+static void
+open_dir(GtkTreeView       *tree_view,
+         GtkTreePath       *path,
+         GtkTreeViewColumn *column,
+         gpointer           user_data)
+{
+    GtkTreeIter iter;
+    GtkTreeModel *model;
+    char *dir, *url;
+
+    model = gtk_tree_view_get_model(tree_view);
+
+    if (!gtk_tree_model_get_iter(model, &iter, path)) {
+        char *p;
+        p = gtk_tree_path_to_string(path);
+        g_warning("Cannot get iter for path '%s'\n", p);
+        g_free(p);
+        return;
+    }
+
+    gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
+
+    url = g_strdup_printf("file://%s", dir);
+
+    GError* error = 0;
+    if (!g_app_info_launch_default_for_uri(url, NULL, &error)) {
+        g_warning("Cannot open '%s' : %s\n", url, error->message);
+        g_error_free(error);
+    }
+
+    g_free(url);
+    g_free(dir);
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "disktreenew");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+void
+create_disk_view(ProcData *procdata, GtkBuilder *builder)
+{
+    GtkWidget *scrolled;
+    GtkWidget *disk_tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *col;
+    GtkCellRenderer *cell;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Device"),
+        N_("Directory"),
+        N_("Type"),
+        N_("SubVolume"),
+        N_("Total"),
+        N_("Free"),
+        N_("Available"),
+        N_("Used")
+    };
+
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"));
+
+    model = gtk_list_store_new(DISK_N_COLUMNS,             /* n columns */
+                               G_TYPE_STRING,              /* DISK_DEVICE */
+                               G_TYPE_STRING,              /* DISK_DIR */
+                               G_TYPE_STRING,              /* DISK_TYPE */
+                               G_TYPE_STRING,              /* DISK_SUBVOLUME */
+                               G_TYPE_UINT64,              /* DISK_TOTAL */
+                               G_TYPE_UINT64,              /* DISK_FREE */
+                               G_TYPE_UINT64,              /* DISK_AVAIL */
+                               G_TYPE_UINT64,              /* DISK_USED */
+                               CAIRO_GOBJECT_TYPE_SURFACE, /* DISK_ICON */
+                               G_TYPE_INT);                /* DISK_USED_PERCENTAGE */
+
+    disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL);
+    procdata->disk_list = disk_tree;
+    gtk_container_add(GTK_CONTAINER(scrolled), disk_tree);
+    g_object_unref(G_OBJECT(model));
+
+    /* icon + device */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
+                                        NULL);
+
+    cell = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
+                                        NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 30);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* sizes - used */
+
+    for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_min_width (col, 30);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+        switch (i) {
+            case DISK_TOTAL:
+            case DISK_FREE:
+            case DISK_AVAIL:
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+        default:
+            gtk_tree_view_column_set_attributes(col, cell,
+                                                "text", i,
+                                                NULL);
+            break;
+        }
+    }
+
+    /* used + percentage */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_text_new();
+    g_object_set(cell, "xalign", 1.0f, NULL);
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_cell_data_func(col, cell,
+                                            &procman::storage_size_cell_data_func,
+                                            GUINT_TO_POINTER(DISK_USED),
+                                            NULL);
+
+    cell = gtk_cell_renderer_progress_new();
+    gtk_tree_view_column_pack_start(col, cell, TRUE);
+    gtk_tree_view_column_set_attributes(col, cell, "value",
+                                        DISK_USED_PERCENTAGE, NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_USED]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 150);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* numeric sort */
+
+    procman_get_tree_state(procdata->settings, disk_tree,
+                   "disktreenew");
+
+    g_signal_connect (G_OBJECT(disk_tree), "columns-changed",
+                      G_CALLBACK(cb_disk_columns_changed), procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/21.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/21.html new file mode 100644 index 00000000..36328855 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/21.html @@ -0,0 +1,2141 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
+852
+853
+854
+855
+856
+857
+858
+859
+860
+861
+862
+863
+864
+865
+866
+867
+868
+869
+870
+871
+872
+873
+874
+875
+876
+877
+878
+879
+880
+881
+882
+883
+884
+885
+886
+887
+888
+889
+890
+891
+892
+893
+894
+895
+896
+897
+898
+899
+900
+901
+902
+903
+904
+905
+906
+907
+908
+909
+910
+911
+912
+913
+914
+915
+916
+917
+918
+919
+920
+921
+922
+923
+924
+925
+926
+927
+928
+929
+930
+931
+932
+933
+934
+935
+936
+937
+938
+939
+940
+941
+942
+943
+944
+945
+946
/*
+ * Mate system monitor color pickers
+ * Copyright (C) 2007 Karl Lattimer <karl@qdh.org.uk>
+ * Copyright (C) 2012-2021 MATE Developers
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with the software; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkkeysyms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <cairo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <librsvg/rsvg.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm_color_button.h"
+
+typedef struct {
+    GtkWidget *cc_dialog;		/* Color chooser dialog */
+
+    gchar *title;            /* Title for the color selection window */
+
+    GdkRGBA color;
+
+    gdouble fraction;        /* Only used by GSMCP_TYPE_PIE */
+    guint type;
+    cairo_surface_t *image_buffer;
+    gdouble highlight;
+    gboolean button_down;
+    gboolean in_button;
+} GSMColorButtonPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GSMColorButton, gsm_color_button, GTK_TYPE_DRAWING_AREA)
+
+/* Properties */
+enum
+{
+    PROP_0,
+    PROP_PERCENTAGE,
+    PROP_TITLE,
+    PROP_COLOR,
+    PROP_TYPE
+};
+
+/* Signals */
+enum
+{
+    COLOR_SET,
+    LAST_SIGNAL
+};
+
+#define GSMCP_MIN_WIDTH 15
+#define GSMCP_MIN_HEIGHT 15
+
+static void gsm_color_button_finalize (GObject * object);
+static void gsm_color_button_set_property (GObject * object, guint param_id,
+                                           const GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_get_property (GObject * object, guint param_id,
+                                           GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_realize (GtkWidget * widget);
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width);
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height);
+static void gsm_color_button_size_allocate (GtkWidget * widget,
+                                            GtkAllocation * allocation);
+static void gsm_color_button_unrealize (GtkWidget * widget);
+static void gsm_color_button_state_changed (GtkWidget * widget,
+                                            GtkStateType previous_state);
+static void gsm_color_button_style_set (GtkWidget * widget,
+                                        GtkStyle * previous_style);
+static gint gsm_color_button_pressed (GtkWidget * widget,
+                                      GdkEventButton * event);
+static gint gsm_color_button_released (GtkWidget * widget,
+                                       GdkEventButton * event);
+static gboolean gsm_color_button_enter_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+static gboolean gsm_color_button_leave_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+/* source side drag signals */
+static void gsm_color_button_drag_begin (GtkWidget * widget,
+                                         GdkDragContext * context,
+                                         gpointer data);
+static void gsm_color_button_drag_data_get (GtkWidget * widget,
+                                            GdkDragContext * context,
+                                            GtkSelectionData * selection_data,
+                                            guint info, guint time,
+                                            GSMColorButton * color_button);
+
+/* target side drag signals */
+static void gsm_color_button_drag_data_received (GtkWidget * widget,
+                                                 GdkDragContext * context,
+                                                 gint x,
+                                                 gint y,
+                                                 GtkSelectionData *
+                                                 selection_data, guint info,
+                                                 guint32 time,
+                                                 GSMColorButton *
+                                                 color_button);
+
+static guint color_button_signals[LAST_SIGNAL] = { 0 };
+
+static const GtkTargetEntry drop_types[] = { {"application/x-color", 0, 0} };
+
+static void
+gsm_color_button_class_init (GSMColorButtonClass * klass)
+{
+    GObjectClass *gobject_class;
+    GtkWidgetClass *widget_class;
+
+    gobject_class = G_OBJECT_CLASS (klass);
+    widget_class = GTK_WIDGET_CLASS (klass);
+
+    gobject_class->get_property = gsm_color_button_get_property;
+    gobject_class->set_property = gsm_color_button_set_property;
+    gobject_class->finalize = gsm_color_button_finalize;
+    widget_class->state_changed = gsm_color_button_state_changed;
+    widget_class->get_preferred_width = gsm_color_button_get_preferred_width;
+    widget_class->get_preferred_height = gsm_color_button_get_preferred_height;
+    widget_class->size_allocate = gsm_color_button_size_allocate;
+    widget_class->realize = gsm_color_button_realize;
+    widget_class->unrealize = gsm_color_button_unrealize;
+    widget_class->style_set = gsm_color_button_style_set;
+    widget_class->button_release_event = gsm_color_button_released;
+    widget_class->button_press_event = gsm_color_button_pressed;<--- You might need to cast the function pointer here
+    widget_class->enter_notify_event = gsm_color_button_enter_notify;
+    widget_class->leave_notify_event = gsm_color_button_leave_notify;
+
+    klass->color_set = NULL;
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_PERCENTAGE,
+                                     g_param_spec_double ("fraction",
+                                                          _("Fraction"),
+                                     // TRANSLATORS: description of the pie color picker's (mem, swap) filled percentage property
+                                                          _("Percentage full for pie color pickers"),
+                                                          0, 1, 0.5,
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TITLE,
+                                     g_param_spec_string ("title",
+                                                          _("Title"),
+                                                          _("The title of the color selection dialog"),
+                                                          _("Pick a Color"),
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_COLOR,
+                                     g_param_spec_boxed ("color",
+                                                         _("Current Color"),
+                                                         _("The selected color"),
+                                                         GDK_TYPE_RGBA,
+                                                         G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TYPE,
+                                     g_param_spec_uint ("type", _("Type"),
+                                                        _("Type of color picker"),
+                                                        0, 4, 0,
+                                                        G_PARAM_READWRITE));
+
+    color_button_signals[COLOR_SET] = g_signal_new ("color_set",
+                                                    G_TYPE_FROM_CLASS
+                                                    (gobject_class),
+                                                    G_SIGNAL_RUN_FIRST,
+                                                    G_STRUCT_OFFSET
+                                                    (GSMColorButtonClass,
+                                                    color_set), NULL, NULL,
+                                                    g_cclosure_marshal_VOID__VOID,
+                                                    G_TYPE_NONE, 0);
+
+}
+
+static cairo_surface_t *
+fill_image_buffer_from_file (cairo_t *cr, const char *filePath)
+{
+    GError *error = NULL;
+    RsvgHandle *handle;
+    cairo_surface_t *tmp_surface;
+    cairo_t *tmp_cr;
+
+    handle = rsvg_handle_new_from_file (filePath, &error);
+
+    if (handle == NULL) {
+        g_warning("rsvg_handle_new_from_file(\"%s\") failed: %s",
+              filePath, (error ? error->message : "unknown error"));
+    if (error)
+          g_error_free(error);
+    return NULL;
+    }
+
+    tmp_surface = cairo_surface_create_similar (cairo_get_target (cr),
+                                                CAIRO_CONTENT_COLOR_ALPHA,
+                                                32, 32);
+    tmp_cr = cairo_create (tmp_surface);
+    rsvg_handle_render_cairo (handle, tmp_cr);
+    cairo_destroy (tmp_cr);
+    g_object_unref (handle);
+    return tmp_surface;
+}
+
+static void
+render (GtkWidget * widget)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GdkRGBA *color;
+    GdkRGBA tmp_color = priv->color;
+    color = &tmp_color;
+    cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
+    cairo_path_t *path = NULL;
+    gint width, height;
+    gdouble radius, arc_start, arc_end;
+    gdouble highlight_factor;
+
+    if (priv->highlight > 0) {
+        highlight_factor = 0.125 * priv->highlight;
+
+    if (color->red + highlight_factor > 1.0)
+        color->red = 1.0;
+    else
+        color->red = color->red + highlight_factor;
+
+    if (color->blue + highlight_factor > 1.0)
+        color->blue = 1.0;
+    else
+      color->blue = color->blue + highlight_factor;
+
+    if (color->green + highlight_factor > 1.0)
+        color->green = 1.0;
+    else
+        color->green = color->green + highlight_factor;
+    }
+    gdk_cairo_set_source_rgba (cr, color);
+
+    width = gdk_window_get_width(gtk_widget_get_window(widget));
+    height = gdk_window_get_height(gtk_widget_get_window(widget));
+
+    switch (priv->type)
+        {
+        case GSMCP_TYPE_CPU:
+            //gtk_widget_set_size_request (widget, GSMCP_MIN_WIDTH, GSMCP_MIN_HEIGHT);
+            cairo_paint (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1);
+            cairo_stroke (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.4);
+            cairo_rectangle (cr, 1.5, 1.5, width - 3, height - 3);
+            cairo_stroke (cr);
+            break;
+        case GSMCP_TYPE_PIE:
+            if (width < 32)        // 32px minimum size
+                gtk_widget_set_size_request (widget, 32, 32);
+            if (width < height)
+                radius = width / 2;
+            else
+                radius = height / 2;
+
+            arc_start = -G_PI_2 + 2 * G_PI * priv->fraction;
+            arc_end = -G_PI_2;
+
+            cairo_set_line_width (cr, 1);
+
+            // Draw external stroke and fill
+            if (priv->fraction < 0.01) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_end);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    arc_end, arc_start);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_start);
+            }
+            cairo_fill_preserve (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.7);
+            cairo_stroke (cr);
+
+            // Draw internal highlight
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.45);
+            cairo_set_line_width (cr, 1);
+
+            if (priv->fraction < 0.03) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_end - (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    arc_end - (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+            }
+            cairo_stroke (cr);
+
+            // Draw external shape
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.2);
+            cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 1.25, 0,
+                G_PI * 2);
+            cairo_stroke (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_IN:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                    fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/download.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 8.5, 1.5);
+            cairo_line_to (cr, 23.5, 1.5);
+            cairo_line_to (cr, 23.5, 11.5);
+            cairo_line_to (cr, 29.5, 11.5);
+            cairo_line_to (cr, 16.5, 27.5);
+            cairo_line_to (cr, 15.5, 27.5);
+            cairo_line_to (cr, 2.5, 11.5);
+            cairo_line_to (cr, 8.5, 11.5);
+            cairo_line_to (cr, 8.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_OUT:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/upload.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 16.5, 1.5);
+            cairo_line_to (cr, 29.5, 17.5);
+            cairo_line_to (cr, 23.5, 17.5);
+            cairo_line_to (cr, 23.5, 27.5);
+            cairo_line_to (cr, 8.5, 27.5);
+            cairo_line_to (cr, 8.5, 17.5);
+            cairo_line_to (cr, 2.5, 17.5);
+            cairo_line_to (cr, 15.5, 1.5);
+            cairo_line_to (cr, 16.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        }
+    cairo_destroy (cr);
+}
+
+/* Handle exposure events for the color picker's drawing area */
+static gboolean draw (GtkWidget * widget, cairo_t * cr, gpointer data)
+{
+    render (GTK_WIDGET (data));
+
+    return FALSE;
+}
+
+static void
+gsm_color_button_realize (GtkWidget * widget)
+{
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->realize (widget);
+    render (widget);
+}
+
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width)
+{
+    g_return_if_fail (widget != NULL && minimum_width != NULL && natural_width != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_width = GSMCP_MIN_WIDTH;
+    *natural_width = GSMCP_MIN_WIDTH;
+}
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height)
+{
+    g_return_if_fail (widget != NULL && minimum_height != NULL && natural_height != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_height = GSMCP_MIN_HEIGHT;
+    *natural_height = GSMCP_MIN_HEIGHT;
+}
+
+static void
+gsm_color_button_size_allocate (GtkWidget * widget,
+                                GtkAllocation * allocation)
+{
+    g_return_if_fail (widget != NULL || allocation != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    gtk_widget_set_allocation (widget, allocation);
+
+    if (gtk_widget_get_realized (widget))
+    {
+        gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y,
+                                allocation->width, allocation->height);
+    }
+}
+
+static void
+gsm_color_button_unrealize (GtkWidget * widget)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->unrealize (widget);
+}
+
+static void
+gsm_color_button_style_set (GtkWidget * widget, GtkStyle * previous_style)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->style_set (widget,
+                                                                 previous_style);
+
+}
+
+static void
+gsm_color_button_state_changed (GtkWidget * widget,
+                                GtkStateType previous_state)
+{
+}
+
+static void
+gsm_color_button_drag_data_received (GtkWidget * widget,
+                                     GdkDragContext * context,
+                                     gint x,
+                                     gint y,
+                                     GtkSelectionData * selection_data,
+                                     guint info,
+                                     guint32 time,
+                                     GSMColorButton * color_button)
+{
+    gint length;
+    guint16 *dropped;
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    length = gtk_selection_data_get_length (selection_data);
+
+    if (length < 0)
+        return;
+
+    /* We accept drops with the wrong format, since the KDE color
+     * chooser incorrectly drops application/x-color with format 8.
+     */
+    if (length != 8)
+    {
+        g_warning (_("Received invalid color data\n"));
+        return;
+    }
+
+    dropped = (guint16 *) gtk_selection_data_get_data (selection_data);
+
+    priv->color.red =   ((double) dropped[0]) / 65535.0;
+    priv->color.green = ((double) dropped[1]) / 65535.0;
+    priv->color.blue =  ((double) dropped[2]) / 65535.0;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+    g_object_freeze_notify (G_OBJECT (color_button));
+    g_object_notify (G_OBJECT (color_button), "color");
+    g_object_thaw_notify (G_OBJECT (color_button));
+}
+
+static void
+set_color_icon (GdkDragContext * context, GdkRGBA * color)<--- Parameter 'color' can be declared as pointer to const
+{
+    GdkPixbuf *pixbuf;
+    guint32 pixel;
+
+    pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 48, 32);
+
+    pixel = ((guint32)(color->red * 0xff) << 24) |
+            ((guint32)(color->green * 0xff) << 16) |
+            ((guint32)(color->blue * 0xff) << 8);
+
+    gdk_pixbuf_fill (pixbuf, pixel);
+
+    gtk_drag_set_icon_pixbuf (context, pixbuf, -2, -2);
+    g_object_unref (pixbuf);
+}
+
+static void
+gsm_color_button_drag_begin (GtkWidget * widget,
+                             GdkDragContext * context, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = data;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    set_color_icon (context, &priv->color);
+}
+
+static void
+gsm_color_button_drag_data_get (GtkWidget * widget,
+                                GdkDragContext * context,
+                                GtkSelectionData * selection_data,
+                                guint info,
+                                guint time, GSMColorButton * color_button)
+{
+    guint16 dropped[4];
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    dropped[0] = (guint16) (65535.0 * priv->color.red);
+    dropped[1] = (guint16) (65535.0 * priv->color.green);
+    dropped[2] = (guint16) (65535.0 * priv->color.blue);
+    dropped[3] = 65535;        // This widget doesn't care about alpha
+
+    gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data),
+                            16, (guchar *) dropped, 8);
+}
+
+static void
+gsm_color_button_init (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = 0;
+    priv->color.green = 0;
+    priv->color.blue = 0;
+    priv->fraction = 0.5;
+    priv->type = GSMCP_TYPE_CPU;
+    priv->image_buffer = NULL;
+    priv->title = g_strdup (_("Pick a Color"));     /* default title */
+    priv->in_button = FALSE;
+    priv->button_down = FALSE;
+
+    gtk_drag_dest_set (GTK_WIDGET (color_button),
+                       GTK_DEST_DEFAULT_MOTION |
+                       GTK_DEST_DEFAULT_HIGHLIGHT |
+                       GTK_DEST_DEFAULT_DROP, drop_types, 1, GDK_ACTION_COPY);
+    gtk_drag_source_set (GTK_WIDGET (color_button),
+                         GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
+                         drop_types, 1, GDK_ACTION_COPY);
+    g_signal_connect (color_button, "drag_begin",
+                      G_CALLBACK (gsm_color_button_drag_begin), color_button);
+    g_signal_connect (color_button, "drag_data_received",
+                      G_CALLBACK (gsm_color_button_drag_data_received),
+                      color_button);
+    g_signal_connect (color_button, "drag_data_get",
+                      G_CALLBACK (gsm_color_button_drag_data_get),
+                      color_button);
+
+    gtk_widget_add_events (GTK_WIDGET(color_button), GDK_ENTER_NOTIFY_MASK
+                              | GDK_LEAVE_NOTIFY_MASK);
+
+    gtk_widget_set_tooltip_text (GTK_WIDGET(color_button), _("Click to set graph colors"));
+
+    g_signal_connect (color_button, "draw", G_CALLBACK (draw), color_button);
+}
+
+static void
+gsm_color_button_finalize (GObject * object)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    if (priv->cc_dialog != NULL)
+        gtk_widget_destroy (priv->cc_dialog);
+    priv->cc_dialog = NULL;
+
+    g_free (priv->title);
+    priv->title = NULL;
+
+    cairo_surface_destroy (priv->image_buffer);
+    priv->image_buffer = NULL;
+
+    G_OBJECT_CLASS (gsm_color_button_parent_class)->finalize (object);
+}
+
+GtkWidget *
+gsm_color_button_new (const GdkRGBA * color, guint type)
+{
+    return g_object_new (GSM_TYPE_COLOR_BUTTON, "color", color, "type", type,
+                         NULL);
+}
+
+static void
+dialog_response (GtkWidget * widget, GtkResponseType response, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GtkColorChooser *color_chooser;
+
+    if (response == GTK_RESPONSE_OK) {
+        color_chooser = GTK_COLOR_CHOOSER (priv->cc_dialog);
+
+        gtk_color_chooser_get_rgba (color_chooser, &priv->color);
+
+        gtk_widget_hide (priv->cc_dialog);
+
+        gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+        g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+        g_object_freeze_notify (G_OBJECT (color_button));
+        g_object_notify (G_OBJECT (color_button), "color");
+        g_object_thaw_notify (G_OBJECT (color_button));
+    }
+    else  /* (response == GTK_RESPONSE_CANCEL) */
+        gtk_widget_hide (priv->cc_dialog);
+}
+
+static gboolean
+dialog_destroy (GtkWidget * widget, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->cc_dialog = NULL;
+
+    return FALSE;
+}
+
+static gint
+gsm_color_button_clicked (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    /* if dialog already exists, make sure it's shown and raised */
+    if (!priv->cc_dialog)
+    {
+        /* Create the dialog and connects its buttons */
+        GtkWidget *cc_dialog;
+        GtkWidget *parent;
+
+        parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));
+        if (!gtk_widget_is_toplevel (parent))
+            parent = NULL;
+
+        cc_dialog = gtk_color_chooser_dialog_new (priv->title, GTK_WINDOW (parent));
+
+        gtk_window_set_modal (GTK_WINDOW (cc_dialog), TRUE);
+
+        g_signal_connect (cc_dialog, "response",
+                          G_CALLBACK (dialog_response), color_button);
+
+        g_signal_connect (cc_dialog, "destroy",
+                          G_CALLBACK (dialog_destroy), color_button);
+
+        priv->cc_dialog = cc_dialog;
+    }
+
+    gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (priv->cc_dialog),
+                                &priv->color);
+
+    gtk_window_present (GTK_WINDOW (priv->cc_dialog));
+
+    return 0;
+}
+
+static gint
+gsm_color_button_pressed (GtkWidget * widget, GdkEventButton * event)<--- Parameter 'event' can be declared as pointer to const
+{
+    if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) )
+    {
+	GSMColorButtonPrivate *priv;
+        GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+	priv = gsm_color_button_get_instance_private (color_button);
+	priv->button_down = TRUE;
+    }
+  return 0;
+}
+
+static gint
+gsm_color_button_released (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    if (priv->button_down && priv->in_button)
+        gsm_color_button_clicked (widget, event);
+    priv->button_down = FALSE;
+    return 0;
+}
+
+static gboolean
+gsm_color_button_enter_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 1.0;
+    priv->in_button = TRUE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+static gboolean
+gsm_color_button_leave_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 0;
+    priv->in_button = FALSE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+guint
+gsm_color_button_get_cbtype (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->type;
+}
+
+void
+gsm_color_button_set_cbtype (GSMColorButton * color_button, guint type)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->type = type;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "type");
+}
+
+gdouble
+gsm_color_button_get_fraction (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->fraction;
+}
+
+void
+gsm_color_button_set_fraction (GSMColorButton * color_button,
+                               gdouble fraction)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->fraction = fraction;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "fraction");
+}
+
+void
+gsm_color_button_get_color (GSMColorButton * color_button, GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    color->red = priv->color.red;
+    color->green = priv->color.green;
+    color->blue = priv->color.blue;
+    color->alpha = priv->color.alpha;
+}
+
+void
+gsm_color_button_set_color (GSMColorButton * color_button,
+                            const GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    g_return_if_fail (color != NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = color->red;
+    priv->color.green = color->green;
+    priv->color.blue = color->blue;
+    priv->color.alpha = color->alpha;
+
+    gtk_widget_queue_draw (GTK_WIDGET (color_button));
+
+    g_object_notify (G_OBJECT (color_button), "color");
+}
+
+void
+gsm_color_button_set_title (GSMColorButton * color_button,
+                            const gchar * title)
+{
+    gchar *old_title;
+    GSMColorButtonPrivate *priv;
+
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    old_title = priv->title;
+    priv->title = g_strdup (title);
+    g_free (old_title);
+
+    if (priv->cc_dialog)
+        gtk_window_set_title (GTK_WINDOW (priv->cc_dialog),
+                              priv->title);
+
+    g_object_notify (G_OBJECT (color_button), "title");
+}
+
+const gchar* gsm_color_button_get_title(GSMColorButton* color_button)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_val_if_fail(GSM_IS_COLOR_BUTTON(color_button), NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->title;
+}
+
+static void
+gsm_color_button_set_property (GObject * object,
+                               guint param_id,
+                               const GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            gsm_color_button_set_fraction (color_button,
+                                           g_value_get_double (value));
+            break;
+        case PROP_TITLE:
+            gsm_color_button_set_title (color_button, g_value_get_string (value));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_set_color (color_button, g_value_get_boxed (value));
+            break;
+        case PROP_TYPE:
+            gsm_color_button_set_cbtype (color_button, g_value_get_uint (value));
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+static void
+gsm_color_button_get_property (GObject * object,
+                               guint param_id,
+                               GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+    GdkRGBA color;
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            g_value_set_double (value,
+                                gsm_color_button_get_fraction (color_button));
+            break;
+        case PROP_TITLE:
+            g_value_set_string (value, gsm_color_button_get_title (color_button));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_get_color (color_button, &color);
+                                        g_value_set_boxed (value, &color);
+            break;
+        case PROP_TYPE:
+            g_value_set_uint (value, gsm_color_button_get_cbtype (color_button));
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/22.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/22.html new file mode 100644 index 00000000..9c8cf9ea --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/22.html @@ -0,0 +1,351 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtkmm/icontheme.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/error.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "iconthemewrapper.h"
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
+{
+    gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
+    try
+    {
+      return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
+    }
+    catch (Gtk::IconThemeError &error)
+    {
+        if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
+            g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+    catch (Gio::Error &error)
+    {
+        g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+}
+
+Glib::RefPtr<Gdk::Pixbuf>
+procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
+                                      int size, Gtk::IconLookupFlags flags) const
+{
+    Gtk::IconInfo icon_info;
+    gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
+    icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
+
+    if (!icon_info) {
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+
+    try
+    {
+        return icon_info.load_icon();
+    }
+    catch (Gtk::IconThemeError &error)
+    {
+        if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
+            g_error("Cannot load gicon from theme: %s", error.what().c_str());
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+    catch (Gio::Error &error)
+    {
+        g_debug("Could not load gicon: %s", error.what().c_str());
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/23.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/23.html new file mode 100644 index 00000000..3f522db0 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/23.html @@ -0,0 +1,1599 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
/* Procman - main window
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkkeysyms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "callbacks.h"
+#include "interface.h"
+#include "proctable.h"
+#include "procactions.h"
+#include "load-graph.h"
+#include "util.h"
+#include "disks.h"
+#include "sysinfo.h"
+#include "gsm_color_button.h"
+
+static void    cb_toggle_tree (GtkAction *action, gpointer data);
+static void    cb_proc_goto_tab (gint tab);
+
+static const GtkActionEntry menu_entries[] =
+{
+    // xgettext: noun, top level menu.
+    // "File" did not make sense for system-monitor
+    { "Monitor", NULL, N_("_Monitor") },
+    { "Edit", NULL, N_("_Edit") },
+    { "View", NULL, N_("_View") },
+    { "Help", NULL, N_("_Help") },
+
+    { "Lsof", "edit-find", N_("Search for _Open Files"), "<control>O",
+      N_("Search for open files"), G_CALLBACK(cb_show_lsof) },
+    { "Quit", "application-exit", N_("_Quit"), "<control>Q",
+      N_("Quit the program"), G_CALLBACK (cb_app_exit) },
+
+
+    { "StopProcess", NULL, N_("_Stop Process"), "<control>S",
+      N_("Stop process"), G_CALLBACK(cb_kill_sigstop) },
+    { "ContProcess", NULL, N_("_Continue Process"), "<control>C",
+      N_("Continue process if stopped"), G_CALLBACK(cb_kill_sigcont) },
+
+    { "EndProcess", NULL, N_("_End Process"), "<control>E",
+      N_("Force process to finish normally"), G_CALLBACK (cb_end_process) },
+    { "KillProcess", NULL, N_("_Kill Process"), "<control>K",
+      N_("Force process to finish immediately"), G_CALLBACK (cb_kill_process) },
+    { "ChangePriority", NULL, N_("_Change Priority"), NULL,
+      N_("Change the order of priority of process"), NULL },
+    { "Preferences", "preferences-desktop", N_("_Preferences"), NULL,
+      N_("Configure the application"), G_CALLBACK (cb_edit_preferences) },
+
+    { "Refresh", "view-refresh", N_("_Refresh"), "<control>R",
+      N_("Refresh the process list"), G_CALLBACK(cb_user_refresh) },
+
+    { "MemoryMaps", NULL, N_("_Memory Maps"), "<control>M",
+      N_("Open the memory maps associated with a process"), G_CALLBACK (cb_show_memory_maps) },
+    // Translators: this means 'Files that are open' (open is no verb here
+    { "OpenFiles", NULL, N_("Open _Files"), "<control>F",
+      N_("View the files opened by a process"), G_CALLBACK (cb_show_open_files) },
+    { "ProcessProperties", NULL, N_("_Properties"), NULL,
+      N_("View additional information about a process"), G_CALLBACK (cb_show_process_properties) },
+
+
+    { "HelpContents", "help-browser", N_("_Contents"), "F1",
+      N_("Open the manual"), G_CALLBACK (cb_help_contents) },
+    { "About", "help-about", N_("_About"), NULL,
+      N_("About this application"), G_CALLBACK (cb_about) }
+};
+
+static const GtkToggleActionEntry toggle_menu_entries[] =
+{
+    { "ShowDependencies", NULL, N_("_Dependencies"), "<control>D",
+      N_("Show parent/child relationship between processes"),
+      G_CALLBACK (cb_toggle_tree), TRUE },
+};
+
+
+static const GtkRadioActionEntry radio_menu_entries[] =
+{
+  { "ShowActiveProcesses", NULL, N_("_Active Processes"), NULL,
+    N_("Show active processes"), ACTIVE_PROCESSES },
+  { "ShowAllProcesses", NULL, N_("A_ll Processes"), NULL,
+    N_("Show all processes"), ALL_PROCESSES },
+  { "ShowMyProcesses", NULL, N_("M_y Processes"), NULL,
+    N_("Show only user-owned processes"), MY_PROCESSES }
+};
+
+static const GtkRadioActionEntry priority_menu_entries[] =
+{
+    { "VeryHigh", NULL, N_("Very High"), NULL,
+      N_("Set process priority to very high"), VERY_HIGH_PRIORITY },
+    { "High", NULL, N_("High"), NULL,
+      N_("Set process priority to high"), HIGH_PRIORITY },
+    { "Normal", NULL, N_("Normal"), NULL,
+      N_("Set process priority to normal"), NORMAL_PRIORITY },
+    { "Low", NULL, N_("Low"), NULL,
+      N_("Set process priority to low"), LOW_PRIORITY },
+    { "VeryLow", NULL, N_("Very Low"), NULL,
+      N_("Set process priority to very low"), VERY_LOW_PRIORITY },
+    { "Custom", NULL, N_("Custom"), NULL,
+      N_("Set process priority manually"), CUSTOM_PRIORITY }
+};
+
+
+static const char ui_info[] =
+    "  <menubar name=\"MenuBar\">"
+    "    <menu name=\"MonitorMenu\" action=\"Monitor\">"
+    "      <menuitem name=\"MonitorLsofMenu\" action=\"Lsof\" />"
+    "      <menuitem name=\"MonitorQuitMenu\" action=\"Quit\" />"
+    "    </menu>"
+    "    <menu name=\"EditMenu\" action=\"Edit\">"
+    "      <menuitem name=\"EditStopProcessMenu\" action=\"StopProcess\" />"
+    "      <menuitem name=\"EditContProcessMenu\" action=\"ContProcess\" />"
+    "      <separator />"
+    "      <menuitem name=\"EditEndProcessMenu\" action=\"EndProcess\" />"
+    "      <menuitem name=\"EditKillProcessMenu\" action=\"KillProcess\" />"
+    "      <separator />"
+    "      <menu name=\"EditChangePriorityMenu\" action=\"ChangePriority\" >"
+    "        <menuitem action=\"VeryHigh\" />"
+    "        <menuitem action=\"High\" />"
+    "        <menuitem action=\"Normal\" />"
+    "        <menuitem action=\"Low\" />"
+    "        <menuitem action=\"VeryLow\" />"
+    "        <separator />"
+    "        <menuitem action=\"Custom\"/>"
+    "      </menu>"
+    "      <separator />"
+    "      <menuitem name=\"EditPreferencesMenu\" action=\"Preferences\" />"
+    "    </menu>"
+    "    <menu name=\"ViewMenu\" action=\"View\">"
+    "      <menuitem name=\"ViewActiveProcesses\" action=\"ShowActiveProcesses\" />"
+    "      <menuitem name=\"ViewAllProcesses\" action=\"ShowAllProcesses\" />"
+    "      <menuitem name=\"ViewMyProcesses\" action=\"ShowMyProcesses\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewDependenciesMenu\" action=\"ShowDependencies\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewMemoryMapsMenu\" action=\"MemoryMaps\" />"
+    "      <menuitem name=\"ViewOpenFilesMenu\" action=\"OpenFiles\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewProcessPropertiesMenu\" action=\"ProcessProperties\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewRefresh\" action=\"Refresh\" />"
+    "    </menu>"
+    "    <menu name=\"HelpMenu\" action=\"Help\">"
+    "      <menuitem name=\"HelpContentsMenu\" action=\"HelpContents\" />"
+    "      <menuitem name=\"HelpAboutMenu\" action=\"About\" />"
+    "    </menu>"
+    "  </menubar>"
+    "  <popup name=\"PopupMenu\" action=\"Popup\">"
+    "    <menuitem action=\"StopProcess\" />"
+    "    <menuitem action=\"ContProcess\" />"
+    "    <separator />"
+    "    <menuitem action=\"EndProcess\" />"
+    "    <menuitem action=\"KillProcess\" />"
+    "    <separator />"
+    "    <menu name=\"ChangePriorityMenu\" action=\"ChangePriority\" >"
+    "      <menuitem action=\"VeryHigh\" />"
+    "      <menuitem action=\"High\" />"
+    "      <menuitem action=\"Normal\" />"
+    "      <menuitem action=\"Low\" />"
+    "      <menuitem action=\"VeryLow\" />"
+    "      <separator />"
+    "      <menuitem action=\"Custom\"/>"
+    "    </menu>"
+    "    <separator />"
+    "    <menuitem action=\"MemoryMaps\" />"
+    "    <menuitem action=\"OpenFiles\" />"
+    "    <separator />"
+    "    <menuitem action=\"ProcessProperties\" />"
+
+    "  </popup>";
+
+
+static void
+create_proc_view(ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *proctree;
+    GtkWidget *scrolled;
+    char* string;
+
+    /* create the processes tab */
+    string = make_loadavg_string ();
+    procdata->loadavg = GTK_WIDGET (gtk_builder_get_object (builder, "load_avg_label"));
+    gtk_label_set_text (GTK_LABEL (procdata->loadavg), string);
+    g_free (string);
+
+    proctree = proctable_new (procdata);
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "processes_scrolled"));
+
+    gtk_container_add (GTK_CONTAINER (scrolled), proctree);
+
+    procdata->endprocessbutton = GTK_WIDGET (gtk_builder_get_object (builder, "endprocessbutton"));
+    g_signal_connect (G_OBJECT (procdata->endprocessbutton), "clicked",
+                      G_CALLBACK (cb_end_process_button_pressed), procdata);
+
+    /* create popup_menu for the processes tab */
+    procdata->popup_menu = gtk_ui_manager_get_widget (procdata->uimanager, "/PopupMenu");
+}
+
+
+GtkWidget *
+make_title_label (const char *text)
+{
+    GtkWidget *label;
+    char *full;
+
+    full = g_strdup_printf ("<span weight=\"bold\">%s</span>", text);
+    label = gtk_label_new (full);
+    g_free (full);
+
+    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+
+    return label;
+}
+
+
+static void
+create_sys_view (ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *cpu_graph_box, *mem_graph_box, *net_graph_box;
+    GtkWidget *label,*cpu_label;
+    GtkWidget *table;
+    GtkWidget *color_picker;
+    GtkWidget *picker_alignment;
+    LoadGraph *cpu_graph, *mem_graph, *net_graph;
+
+    gint i;
+    gchar *title_text;
+    gchar *label_text;
+    gchar *title_template;
+
+    // Translators: color picker title, %s is CPU, Memory, Swap, Receiving, Sending
+    title_template = g_strdup(_("Pick a Color for '%s'"));
+
+    /* The CPU BOX */
+
+    cpu_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_graph_box"));
+
+    cpu_graph = new LoadGraph(LOAD_GRAPH_CPU);
+    gtk_box_pack_start (GTK_BOX (cpu_graph_box),
+                        load_graph_get_widget(cpu_graph),
+                        TRUE,
+                        TRUE,
+                         0);
+
+    GtkWidget* flowbox = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_flow_box"));
+    gtk_box_reorder_child (GTK_BOX (cpu_graph_box), flowbox, 1);
+    for (i=0;i<procdata->config.num_cpus; i++) {
+        GtkWidget *temp_hbox;
+
+        temp_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
+        gtk_container_add (GTK_CONTAINER (flowbox), temp_hbox);
+
+        color_picker = gsm_color_button_new (&cpu_graph->colors.at(i), GSMCP_TYPE_CPU);
+        g_signal_connect (G_OBJECT (color_picker), "color_set",
+                          G_CALLBACK (cb_cpu_color_changed), GINT_TO_POINTER (i));
+        gtk_box_pack_start (GTK_BOX (temp_hbox), color_picker, FALSE, TRUE, 0);
+        gtk_widget_set_size_request(GTK_WIDGET(color_picker), 32, -1);
+        if(procdata->config.num_cpus == 1) {
+            label_text = g_strdup (_("CPU"));
+        } else {
+            label_text = g_strdup_printf (_("CPU%d"), i+1);
+        }
+        title_text = g_strdup_printf(title_template, label_text);
+        label = gtk_label_new (label_text);
+        gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+        g_free(title_text);
+        gtk_box_pack_start (GTK_BOX (temp_hbox), label, FALSE, FALSE, 6);
+        g_free (label_text);
+
+        cpu_label = gtk_label_new (NULL);
+        gtk_label_set_width_chars (GTK_LABEL (cpu_label), 7);
+        gtk_label_set_xalign (GTK_LABEL (cpu_label), 0.0);
+
+        gtk_box_pack_start (GTK_BOX (temp_hbox), cpu_label, TRUE, TRUE, 0);
+        load_graph_get_labels(cpu_graph)->cpu[i] = cpu_label;
+
+    }
+
+    procdata->cpu_graph = cpu_graph;
+
+    /** The memory box */
+    mem_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "mem_graph_box"));
+
+    mem_graph = new LoadGraph(LOAD_GRAPH_MEM);
+    gtk_box_pack_start (GTK_BOX (mem_graph_box),
+                        load_graph_get_widget(mem_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "mem_table"));
+
+    color_picker = load_graph_get_mem_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_mem_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Memory"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 0, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->memory;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 1, 1, 1, 1);
+
+    color_picker = load_graph_get_swap_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_swap_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Swap"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 2, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->swap;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 3, 1, 1, 1);
+
+    procdata->mem_graph = mem_graph;
+
+    /* The net box */
+    net_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "net_graph_box"));
+
+    net_graph = new LoadGraph(LOAD_GRAPH_NET);
+    gtk_box_pack_start (GTK_BOX (net_graph_box),
+                        load_graph_get_widget(net_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "net_table"));
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(0), GSMCP_TYPE_NETWORK_IN);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_in_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Receiving"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "receiving_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_in;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_in_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 1, 1, 1);
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(1), GSMCP_TYPE_NETWORK_OUT);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_out_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Sending"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "sending_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_out;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_out_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 1, 1, 1);
+
+    procdata->net_graph = net_graph;
+    g_free(title_template);
+}
+
+static void
+menu_item_select_cb (GtkMenuItem *proxy,
+                     ProcData *procdata)
+{
+    GtkAction *action;
+    char *message;
+
+    action = gtk_activatable_get_related_action (GTK_ACTIVATABLE(proxy));
+    g_assert(action);
+
+    g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
+    if (message)
+    {
+        gtk_statusbar_push (GTK_STATUSBAR (procdata->statusbar),
+                    procdata->tip_message_cid, message);
+        g_free (message);
+    }
+}
+
+static void
+menu_item_deselect_cb (GtkMenuItem *proxy,
+                       ProcData *procdata)
+{
+    gtk_statusbar_pop (GTK_STATUSBAR (procdata->statusbar),
+               procdata->tip_message_cid);
+}
+
+static void
+connect_proxy_cb (GtkUIManager *manager,
+                  GtkAction *action,
+                  GtkWidget *proxy,
+                  ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_connect (proxy, "select",
+                          G_CALLBACK (menu_item_select_cb), procdata);
+        g_signal_connect (proxy, "deselect",
+                          G_CALLBACK (menu_item_deselect_cb), procdata);
+    }
+}
+
+static void
+disconnect_proxy_cb (GtkUIManager *manager,
+                     GtkAction *action,
+                     GtkWidget *proxy,
+                     ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_select_cb)), procdata);
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_deselect_cb)), procdata);
+    }
+}
+
+void
+create_main_window (ProcData *procdata)
+{
+    gint i;
+    gint width, height, xpos, ypos;
+    GtkWidget *app;
+    GtkAction *action;
+    GtkWidget *menubar;
+    GtkWidget *main_box;
+    GtkWidget *notebook;
+    GtkBuilder *builder;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/interface.ui");
+
+    app = GTK_WIDGET (gtk_builder_get_object (builder, "main_window"));
+    main_box = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
+
+    GdkScreen* screen = gtk_widget_get_screen(app);
+    /* use visual, if available */
+    GdkVisual* visual = gdk_screen_get_rgba_visual(screen);
+    if (visual)
+        gtk_widget_set_visual(app, visual);
+
+    width = procdata->config.width;
+    height = procdata->config.height;
+    xpos = procdata->config.xpos;
+    ypos = procdata->config.ypos;
+    gtk_window_set_default_size (GTK_WINDOW (app), width, height);
+    gtk_window_move(GTK_WINDOW (app), xpos, ypos);
+
+    if (procdata->config.maximized) {
+        gtk_window_maximize(GTK_WINDOW(app));
+    }
+
+    /* create the menubar */
+    procdata->uimanager = gtk_ui_manager_new ();
+
+    /* show tooltips in the statusbar */
+    g_signal_connect (procdata->uimanager, "connect_proxy",
+                      G_CALLBACK (connect_proxy_cb), procdata);
+    g_signal_connect (procdata->uimanager, "disconnect_proxy",
+                      G_CALLBACK (disconnect_proxy_cb), procdata);
+
+    gtk_window_add_accel_group (GTK_WINDOW (app),
+                                gtk_ui_manager_get_accel_group (procdata->uimanager));
+
+    if (!gtk_ui_manager_add_ui_from_string (procdata->uimanager,
+                                            ui_info,
+                                            -1,
+                                            NULL)) {
+        g_error("building menus failed");
+    }
+
+    procdata->action_group = gtk_action_group_new ("ProcmanActions");
+    gtk_action_group_set_translation_domain (procdata->action_group, NULL);
+    gtk_action_group_add_actions (procdata->action_group,
+                                  menu_entries,
+                                  G_N_ELEMENTS (menu_entries),
+                                  procdata);
+    gtk_action_group_add_toggle_actions (procdata->action_group,
+                                         toggle_menu_entries,
+                                         G_N_ELEMENTS (toggle_menu_entries),
+                                         procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                        radio_menu_entries,
+                        G_N_ELEMENTS (radio_menu_entries),
+                        procdata->config.whose_process,
+                        G_CALLBACK(cb_radio_processes),
+                        procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                                        priority_menu_entries,
+                                        G_N_ELEMENTS (priority_menu_entries),
+                                        NORMAL_PRIORITY,
+                                        G_CALLBACK(cb_renice),
+                                        procdata);
+
+    gtk_ui_manager_insert_action_group (procdata->uimanager,
+                                        procdata->action_group,
+                                        0);
+
+    menubar = gtk_ui_manager_get_widget (procdata->uimanager, "/MenuBar");
+    gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0);
+    gtk_box_reorder_child (GTK_BOX (main_box), menubar, 0);
+
+    /* create the main notebook */
+    procdata->notebook = notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
+
+    create_proc_view(procdata, builder);
+    create_sys_view (procdata, builder);
+    create_disk_view (procdata, builder);
+
+    g_signal_connect (G_OBJECT (notebook), "switch-page",
+              G_CALLBACK (cb_switch_page), procdata);
+    g_signal_connect (G_OBJECT (notebook), "change-current-page",
+              G_CALLBACK (cb_change_current_page), procdata);
+
+    gtk_widget_show_all(notebook); // need to make page switch work
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab);
+    cb_change_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab, procdata);
+    g_signal_connect (G_OBJECT (app), "delete_event",
+                      G_CALLBACK (cb_app_delete),
+                      procdata);
+
+    GtkAccelGroup *accel_group;
+    GClosure *goto_tab_closure[4];
+    accel_group = gtk_accel_group_new ();
+    gtk_window_add_accel_group (GTK_WINDOW(app), accel_group);
+    for (i = 0; i < 4; ++i) {
+        goto_tab_closure[i] = g_cclosure_new_swap (G_CALLBACK (cb_proc_goto_tab),
+                                                   GINT_TO_POINTER (i), NULL);
+        gtk_accel_group_connect (accel_group, '0'+(i+1),
+                                 GDK_MOD1_MASK, GTK_ACCEL_VISIBLE,
+                                 goto_tab_closure[i]);
+    }
+
+    /* create the statusbar */
+    procdata->statusbar = GTK_WIDGET (gtk_builder_get_object (builder, "statusbar"));
+    procdata->tip_message_cid = gtk_statusbar_get_context_id
+        (GTK_STATUSBAR (procdata->statusbar), "tip_message");
+
+    action = gtk_action_group_get_action (procdata->action_group, "ShowDependencies");
+    gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+                      procdata->config.show_tree);
+
+    gtk_builder_connect_signals (builder, NULL);
+
+    gtk_widget_show_all(app);
+    procdata->app = app;
+
+    g_object_unref (G_OBJECT (builder));
+}
+
+void
+do_popup_menu (ProcData *procdata, GdkEventButton *event)
+{
+    gtk_menu_popup_at_pointer (GTK_MENU (procdata->popup_menu), NULL);
+}
+
+void
+update_sensitivity(ProcData *data)
+{
+    const char * const selected_actions[] = { "StopProcess",
+                                              "ContProcess",
+                                              "EndProcess",
+                                              "KillProcess",
+                                              "ChangePriority",
+                                              "MemoryMaps",
+                                              "OpenFiles",
+                                              "ProcessProperties" };
+
+    const char * const processes_actions[] = { "ShowActiveProcesses",
+                                               "ShowAllProcesses",
+                                               "ShowMyProcesses",
+                                               "ShowDependencies",
+                                               "Refresh"
+    };
+
+    size_t i;
+    gboolean processes_sensitivity, selected_sensitivity;
+    GtkAction *action;
+
+    processes_sensitivity = (data->config.current_tab == PROCMAN_TAB_PROCESSES);
+    selected_sensitivity = (processes_sensitivity && data->selection && gtk_tree_selection_count_selected_rows (data->selection) > 0);
+
+    if(data->endprocessbutton) {
+        /* avoid error on startup if endprocessbutton
+           has not been built yet */
+        gtk_widget_set_sensitive(data->endprocessbutton, selected_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(processes_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             processes_actions[i]);
+        gtk_action_set_sensitive(action, processes_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(selected_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             selected_actions[i]);
+        gtk_action_set_sensitive(action, selected_sensitivity);
+    }
+}
+
+void
+block_priority_changed_handlers(ProcData *data, bool block)
+{
+    gint i;
+    if (block) {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_block_by_func(action, (gpointer)cb_renice, data);
+        }
+    } else {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_unblock_by_func(action, (gpointer)cb_renice, data);
+        }
+    }
+}
+
+static void
+cb_toggle_tree (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GSettings *settings = procdata->settings;
+    gboolean show;
+
+    show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+    if (show == procdata->config.show_tree)
+        return;
+
+    g_settings_set_boolean (settings, "show-tree", show);
+}
+
+static void
+cb_proc_goto_tab (gint tab)
+{
+    ProcData *data = ProcData::get_instance ();
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (data->notebook), tab);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/24.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/24.html new file mode 100644 index 00000000..382ee6f5 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/24.html @@ -0,0 +1,1939 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gdkmm/pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dirent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibtop.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/swap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/netload.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/netlist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <algorithm><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "load-graph.h"
+#include "util.h"
+#include "gsm_color_button.h"
+
+void LoadGraph::clear_background()
+{
+    if (background) {
+        cairo_pattern_destroy (background);
+        this->background = NULL;
+    }
+}
+
+
+unsigned LoadGraph::num_bars() const
+{
+    unsigned n;<--- Shadow variable
+
+    // keep 100 % num_bars == 0
+    switch (static_cast<int>(this->draw_height / (fontsize + 14)))
+    {
+    case 0:
+    case 1:
+        n = 1;
+        break;
+    case 2:
+    case 3:
+        n = 2;
+        break;
+    case 4:
+        n = 4;
+        break;
+    default:
+        n = 5;
+    }
+
+    return n;
+}
+
+
+
+#define FRAME_WIDTH 4
+static void draw_background(LoadGraph *graph) {
+    GtkAllocation allocation;
+    cairo_t *cr;
+    guint i;<--- Shadowed declaration
+    unsigned num_bars;
+    g_autofree gchar *caption;
+    PangoLayout* layout;
+    PangoFontDescription* font_desc;
+    PangoRectangle extents;
+    cairo_surface_t *surface;
+    GdkRGBA fg, bg;
+
+    num_bars = graph->num_bars();
+    graph->graph_dely = (graph->draw_height - 15) / num_bars; /* round to int to avoid AA blur */
+    graph->real_draw_height = graph->graph_dely * num_bars;
+    graph->graph_delx = (graph->draw_width - 2.0 - graph->rmargin - graph->indent) / (LoadGraph::NUM_POINTS - 3);
+    graph->graph_buffer_offset = (int) (1.5 * graph->graph_delx) + FRAME_WIDTH ;
+
+    gtk_widget_get_allocation (graph->disp, &allocation);
+    surface = gdk_window_create_similar_surface (gtk_widget_get_window (graph->disp), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height);
+    cr = cairo_create (surface);
+
+    GtkStyleContext *context = gtk_widget_get_style_context (ProcData::get_instance()->notebook);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get_background_color (context, gtk_style_context_get_state (context), &bg);
+    gtk_style_context_get_color (context, gtk_style_context_get_state (context), &fg);
+    gtk_style_context_restore (context);
+
+    // set the background color
+    gdk_cairo_set_source_rgba (cr, &bg);
+    cairo_paint (cr);
+
+    layout = pango_cairo_create_layout (cr);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get (context,
+                           gtk_style_context_get_state (context),
+                           GTK_STYLE_PROPERTY_FONT,
+                           &font_desc, NULL);
+    gtk_style_context_restore (context);
+    pango_font_description_set_size (font_desc, 0.8 * graph->fontsize * PANGO_SCALE);
+    pango_layout_set_font_description (layout, font_desc);
+    pango_font_description_free (font_desc);
+
+    /* draw frame */
+    cairo_translate (cr, FRAME_WIDTH, FRAME_WIDTH);
+
+    /* Draw background rectangle */
+    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+    cairo_rectangle (cr, graph->rmargin + graph->indent, 0,
+                     graph->draw_width - graph->rmargin - graph->indent, graph->real_draw_height);
+    cairo_fill(cr);
+
+    cairo_set_line_width (cr, 1.0);
+    cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    for (i = 0; i <= num_bars; ++i) {
+        double y;
+
+        if (i == 0)
+            y = 0.5 + graph->fontsize / 2.0;
+        else if (i == num_bars)
+            y = i * graph->graph_dely + 0.5;
+        else
+            y = i * graph->graph_dely + graph->fontsize / 2.0;
+
+        gdk_cairo_set_source_rgba (cr, &fg);
+        if (graph->type == LOAD_GRAPH_NET) {
+            // operation orders matters so it's 0 if i == num_bars
+            guint64 rate = graph->net.max - (i * graph->net.max / num_bars);
+            caption = g_format_size_full (network_in_bits ? rate*8 : rate, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        } else {
+            // operation orders matters so it's 0 if i == num_bars
+            caption = g_strdup_printf("%d%%", 100 - i * (100 / num_bars));
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        }
+
+        if (i==0 || i==num_bars)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, graph->rmargin + graph->indent - 3, i * graph->graph_dely + 0.5);
+        cairo_line_to (cr, graph->draw_width - 0.5, i * graph->graph_dely + 0.5);
+        cairo_stroke (cr);
+    }
+
+    const unsigned total_seconds = graph->speed * (LoadGraph::NUM_POINTS - 2) / 1000;
+
+    for (unsigned int i = 0; i < 7; i++) {<--- Shadow variable
+        double x = (i) * (graph->draw_width - graph->rmargin - graph->indent) / 6;
+        if (i==0 || i==6)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, 0.5);
+        cairo_line_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, graph->real_draw_height + 4.5);
+        cairo_stroke(cr);
+        unsigned seconds = total_seconds - i * total_seconds / 6;
+        const char* format;
+        if (i == 0)
+            format = dngettext(GETTEXT_PACKAGE, "%u second", "%u seconds", seconds);
+        else
+            format = "%u";
+        caption = g_strdup_printf(format, seconds);
+        pango_layout_set_text (layout, caption, -1);
+        pango_layout_get_extents (layout, NULL, &extents);
+        cairo_move_to (cr, ((ceil(x) + 0.5) + graph->rmargin + graph->indent) - (1.0 * extents.width / PANGO_SCALE/2), graph->draw_height - 1.0 * extents.height / PANGO_SCALE);
+        gdk_cairo_set_source_rgba (cr, &fg);
+        pango_cairo_show_layout (cr, layout);
+    }
+    g_object_unref(layout);
+    cairo_stroke (cr);
+    cairo_destroy (cr);
+    graph->background = cairo_pattern_create_for_surface (surface);
+    cairo_surface_destroy (surface);
+}
+
+/* Redraws the backing buffer for the load graph and updates the window */
+void
+load_graph_queue_draw (LoadGraph *graph)
+{
+    /* repaint */
+    gtk_widget_queue_draw (graph->disp);
+}
+
+static int load_graph_update (gpointer user_data); // predeclare load_graph_update so we can compile ;)
+
+static gboolean
+load_graph_configure (GtkWidget *widget,
+                      GdkEventConfigure *event,
+                      gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    gtk_widget_get_allocation (widget, &allocation);
+    graph->draw_width = allocation.width - 2 * FRAME_WIDTH;
+    graph->draw_height = allocation.height - 2 * FRAME_WIDTH;
+
+    graph->clear_background();
+
+    load_graph_queue_draw (graph);
+
+    return TRUE;
+}
+
+static gboolean load_graph_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+    GdkWindow *window;
+
+    guint i, j;
+    gdouble sample_width, x_offset;
+
+    window = gtk_widget_get_window (graph->disp);
+
+    /* Number of pixels wide for one graph point */
+    sample_width = (float)(graph->draw_width - graph->rmargin - graph->indent) / (float)LoadGraph::NUM_POINTS;
+    /* General offset */
+    x_offset = graph->draw_width - graph->rmargin + (sample_width*2);
+
+    /* Subframe offset */
+    x_offset += graph->rmargin - ((sample_width / graph->frames_per_unit) * graph->render_counter);
+
+    /* draw the graph */
+    cairo_t* cr;
+
+    cr = gdk_cairo_create (window);
+
+    if (graph->background == NULL) {
+        draw_background(graph);
+    }
+    cairo_set_source (cr, graph->background);
+    cairo_paint (cr);
+
+    cairo_set_line_width (cr, 1);
+    cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+    cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+    cairo_rectangle (cr, graph->rmargin + graph->indent + FRAME_WIDTH + 1, FRAME_WIDTH - 1,
+             graph->draw_width - graph->rmargin - graph->indent - 1, graph->real_draw_height + FRAME_WIDTH - 1);
+    cairo_clip(cr);
+
+    for (j = 0; j < graph->n; ++j) {
+        cairo_move_to (cr, x_offset, (1.0f - graph->data[0][j]) * graph->real_draw_height);
+        gdk_cairo_set_source_rgba (cr, &(graph->colors [j]));
+
+        for (i = 1; i < LoadGraph::NUM_POINTS; ++i) {
+            if (graph->data[i][j] == -1.0f)
+                continue;
+            cairo_curve_to (cr,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i-1][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - (i * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f);
+        }
+        cairo_stroke (cr);
+
+    }
+
+    cairo_destroy (cr);
+
+    return TRUE;
+}
+
+static void
+get_load (LoadGraph *graph)
+{
+    guint i;
+    glibtop_cpu cpu;
+
+    glibtop_get_cpu (&cpu);
+
+#undef NOW
+#undef LAST
+#define NOW  (graph->cpu.times[graph->cpu.now])
+#define LAST (graph->cpu.times[graph->cpu.now ^ 1])
+
+    if (graph->n == 1) {
+        NOW[0][CPU_TOTAL] = cpu.total;
+        NOW[0][CPU_USED] = cpu.user + cpu.nice + cpu.sys;
+    } else {
+        for (i = 0; i < graph->n; i++) {
+            NOW[i][CPU_TOTAL] = cpu.xcpu_total[i];
+            NOW[i][CPU_USED] = cpu.xcpu_user[i] + cpu.xcpu_nice[i]
+                + cpu.xcpu_sys[i];
+        }
+    }
+
+    // on the first call, LAST is 0
+    // which means data is set to the average load since boot
+    // that value has no meaning, we just want all the
+    // graphs to be aligned, so the CPU graph needs to start
+    // immediately
+
+    for (i = 0; i < graph->n; i++) {
+        float load;
+        float total, used;
+        gchar *text;
+
+        total = NOW[i][CPU_TOTAL] - LAST[i][CPU_TOTAL];
+        used  = NOW[i][CPU_USED]  - LAST[i][CPU_USED];
+
+        load = used / MAX(total, 1.0f);
+        graph->data[0][i] = load;
+
+        /* Update label */
+        text = g_strdup_printf("%.1f%%", load * 100.0f);
+        gtk_label_set_text(GTK_LABEL(graph->labels.cpu[i]), text);
+        g_free(text);
+    }
+
+    graph->cpu.now ^= 1;
+
+#undef NOW
+#undef LAST
+}
+
+
+namespace
+{
+
+    void set_memory_label_and_picker(GtkLabel* label, GSMColorButton* picker,
+                                   guint64 used, guint64 total, double percent)
+    {
+        char* used_text;
+        char* total_text;
+        char* text;
+
+        used_text = g_format_size_full(used, G_FORMAT_SIZE_IEC_UNITS);
+        total_text = g_format_size_full(total, G_FORMAT_SIZE_IEC_UNITS);
+        if (total == 0) {
+            text = g_strdup(_("not available"));
+        } else {
+            // xgettext: 540MiB (53 %) of 1.0 GiB
+            text = g_strdup_printf(_("%s (%.1f%%) of %s"), used_text, 100.0 * percent, total_text);
+        }
+        gtk_label_set_text(label, text);
+        g_free(used_text);
+        g_free(total_text);
+        g_free(text);
+
+        if (picker)
+            gsm_color_button_set_fraction(picker, percent);
+    }
+}
+
+static void
+get_memory (LoadGraph *graph)
+{
+    float mempercent, swappercent;
+
+    glibtop_mem mem;
+    glibtop_swap swap;
+
+    glibtop_get_mem (&mem);
+    glibtop_get_swap (&swap);
+
+    /* There's no swap on LiveCD : 0.0f is better than NaN :) */
+    swappercent = (swap.total ? (float)swap.used / (float)swap.total : 0.0f);
+    mempercent  = (float)mem.user  / (float)mem.total;
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.memory),
+                                GSM_COLOR_BUTTON(graph->mem_color_picker),
+                                mem.user, mem.total, mempercent);
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.swap),
+                                GSM_COLOR_BUTTON(graph->swap_color_picker),
+                                swap.used, swap.total, swappercent);
+
+    graph->data[0][0] = mempercent;
+    graph->data[0][1] = swappercent;
+}
+
+/* Nice Numbers for Graph Labels after Paul Heckbert
+   nicenum: find a "nice" number approximately equal to x.
+   Round the number if round=1, take ceiling if round=0    */
+
+static double
+nicenum (double x, int round)
+{
+    int expv;				/* exponent of x */
+    double f;				/* fractional part of x */
+    double nf;				/* nice, rounded fraction */
+
+    expv = floor( log10(x) );
+    f = x/pow( 10.0, expv );		/* between 1 and 10 */
+    if (round) {
+        if ( f < 1.5 ) nf = 1.0;
+        else if ( f < 3.0 ) nf = 2.0;
+        else if ( f < 7.0 ) nf = 5.0;
+        else nf = 10.0;
+    } else {
+        if ( f <= 1.0 ) nf = 1.0;
+        else if ( f <= 2.0 ) nf = 2.0;
+        else if ( f <= 5.0 ) nf = 5.0;
+        else nf = 10.0;
+    }
+    return nf * pow(10.0, expv);
+}
+
+static void
+net_scale (LoadGraph *graph, guint64 din, guint64 dout)
+{
+    graph->data[0][0] = 1.0f * din / graph->net.max;
+    graph->data[0][1] = 1.0f * dout / graph->net.max;
+
+    guint64 dmax = std::max(din, dout);
+    graph->net.values[graph->net.cur] = dmax;
+    graph->net.cur = (graph->net.cur + 1) % LoadGraph::NUM_POINTS;
+
+    guint64 new_max;
+    // both way, new_max is the greatest value
+    if (dmax >= graph->net.max)
+        new_max = dmax;
+    else
+        new_max = *std::max_element(&graph->net.values[0],
+                                    &graph->net.values[LoadGraph::NUM_POINTS]);
+
+    //
+    // Round network maximum
+    //
+
+    const guint64 bak_max(new_max);
+
+    if (ProcData::get_instance()->config.network_in_bits) {
+        // nice number is for the ticks
+        unsigned ticks = graph->num_bars();
+
+        // gets messy at low values due to division by 8
+        guint64 bit_max = std::max( new_max*8, G_GUINT64_CONSTANT(10000) );
+
+        // our tick size leads to max
+        double d = nicenum(bit_max/ticks, 0);
+        bit_max = ticks * d;
+        new_max = bit_max / 8;
+
+        procman_debug("bak*8 %" G_GUINT64_FORMAT ", ticks %d, d %f"
+                      ", bit_max %" G_GUINT64_FORMAT ", new_max %" G_GUINT64_FORMAT,
+                      bak_max*8, ticks, d, bit_max, new_max );
+    } else {
+        // round up to get some extra space
+        // yes, it can overflow
+        new_max = 1.1 * new_max;
+        // make sure max is not 0 to avoid / 0
+        // default to 1 KiB
+        new_max = std::max(new_max, G_GUINT64_CONSTANT(1024));
+
+        // decompose new_max = coef10 * 2**(base10 * 10)
+        // where coef10 and base10 are integers and coef10 < 2**10
+        //
+        // e.g: ceil(100.5 KiB) = 101 KiB = 101 * 2**(1 * 10)
+        //      where base10 = 1, coef10 = 101, pow2 = 16
+
+        guint64 pow2 = std::floor(log2(new_max));
+        guint64 base10 = pow2 / 10.0;
+        guint64 coef10 = std::ceil(new_max / double(G_GUINT64_CONSTANT(1) << (base10 * 10)));
+        g_assert(new_max <= (coef10 * (G_GUINT64_CONSTANT(1) << (base10 * 10))));
+
+        // then decompose coef10 = x * 10**factor10
+        // where factor10 is integer and x < 10
+        // so we new_max has only 1 significant digit
+
+        guint64 factor10 = std::pow(10.0, std::floor(std::log10(coef10)));
+        coef10 = std::ceil(coef10 / double(factor10)) * factor10;
+
+        // then make coef10 divisible by num_bars
+        if (coef10 % graph->num_bars() != 0)
+            coef10 = coef10 + (graph->num_bars() - coef10 % graph->num_bars());
+        g_assert(coef10 % graph->num_bars() == 0);
+        new_max = coef10 * (G_GUINT64_CONSTANT(1) << guint64(base10 * 10));
+        procman_debug("bak %" G_GUINT64_FORMAT " new_max %" G_GUINT64_FORMAT
+                      "pow2 %" G_GUINT64_FORMAT " coef10 %" G_GUINT64_FORMAT,
+                      bak_max, new_max, pow2, coef10);
+    }
+
+    if (bak_max > new_max) {
+        procman_debug("overflow detected: bak=%" G_GUINT64_FORMAT
+                      " new=%" G_GUINT64_FORMAT,
+                      bak_max, new_max);
+        new_max = bak_max;
+    }
+
+    // if max is the same or has decreased but not so much, don't
+    // do anything to avoid rescaling
+    if ((0.8 * graph->net.max) < new_max && new_max <= graph->net.max)
+        return;
+
+    const double scale = 1.0f * graph->net.max / new_max;
+
+    for (size_t i = 0; i < LoadGraph::NUM_POINTS; i++) {
+        if (graph->data[i][0] >= 0.0f) {
+            graph->data[i][0] *= scale;
+            graph->data[i][1] *= scale;
+        }
+    }
+
+    procman_debug("rescale dmax = %" G_GUINT64_FORMAT
+                  " max = %" G_GUINT64_FORMAT
+                  " new_max = %" G_GUINT64_FORMAT,
+                  dmax, graph->net.max, new_max);
+
+    graph->net.max = new_max;
+
+    // force the graph background to be redrawn now that scale has changed
+    graph->clear_background();
+}
+
+static void
+get_net (LoadGraph *graph)
+{
+    glibtop_netlist netlist;
+    char **ifnames;
+    guint32 i;
+    guint64 in = 0, out = 0;
+#if GLIB_CHECK_VERSION(2,61,2)
+    gint64 time;
+#else
+    GTimeVal time;
+#endif
+    guint64 din, dout;
+
+    ifnames = glibtop_get_netlist(&netlist);
+
+    for (i = 0; i < netlist.number; ++i)
+    {
+        glibtop_netload netload;
+        glibtop_get_netload (&netload, ifnames[i]);
+
+        if (netload.if_flags & (1 << GLIBTOP_IF_FLAGS_LOOPBACK))
+            continue;
+
+        /* Skip interfaces without any IPv4/IPv6 address (or
+         those with only a LINK ipv6 addr) However we need to
+         be able to exclude these while still keeping the
+         value so when they get online (with NetworkManager
+         for example) we don't get a suddent peak.  Once we're
+         able to get this, ignoring down interfaces will be
+         possible too.  */
+        if (not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS6)
+             and netload.scope6 != GLIBTOP_IF_IN6_SCOPE_LINK)
+            and not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS)))
+            continue;
+
+        /* Don't skip interfaces that are down (GLIBTOP_IF_FLAGS_UP)
+           to avoid spikes when they are brought up */
+
+        in  += netload.bytes_in;
+        out += netload.bytes_out;
+    }
+
+    g_strfreev(ifnames);
+
+#if GLIB_CHECK_VERSION(2,61,2)
+    time = g_get_real_time ();
+
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time != 0) {
+        float dtime = (double) (time - graph->net.time) / G_USEC_PER_SEC;
+#else
+    g_get_current_time (&time);
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time.tv_sec != 0) {
+        float dtime;
+        dtime = time.tv_sec - graph->net.time.tv_sec +
+            (double) (time.tv_usec - graph->net.time.tv_usec) / G_USEC_PER_SEC;
+#endif
+        din   = static_cast<guint64>((in  - graph->net.last_in)  / dtime);
+        dout  = static_cast<guint64>((out - graph->net.last_out) / dtime);
+    } else {
+        /* Don't calc anything if new data is less than old (interface
+           removed, counters reset, ...) or if it is the first time */
+        din  = 0;
+        dout = 0;
+    }
+
+    graph->net.last_in  = in;
+    graph->net.last_out = out;
+    graph->net.time     = time;
+
+    net_scale(graph, din, dout);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    g_autofree gchar *str=NULL, *formatted_str=NULL;
+
+    str = g_format_size_full (network_in_bits ? din*8 : din, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? in*8 : in, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in_total), str);
+
+    str = g_format_size_full (network_in_bits ? dout*8 : dout, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? out*8 : out, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out_total), str);
+}
+
+
+/* Updates the load graph when the timeout expires */
+static gboolean
+load_graph_update (gpointer user_data)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(user_data);
+
+    if (graph->render_counter == graph->frames_per_unit - 1) {
+        std::rotate(&graph->data[0], &graph->data[LoadGraph::NUM_POINTS - 1], &graph->data[LoadGraph::NUM_POINTS]);
+
+        switch (graph->type) {
+        case LOAD_GRAPH_CPU:
+            get_load(graph);
+            break;
+        case LOAD_GRAPH_MEM:
+            get_memory(graph);
+            break;
+        case LOAD_GRAPH_NET:
+            get_net(graph);
+            break;
+        default:
+            g_assert_not_reached();
+        }
+    }
+
+    if (graph->draw)
+        load_graph_queue_draw (graph);
+
+    graph->render_counter++;
+
+    if (graph->render_counter >= graph->frames_per_unit)
+        graph->render_counter = 0;
+
+    return TRUE;
+}
+
+
+
+LoadGraph::~LoadGraph()
+{
+  load_graph_stop(this);
+
+  if (timer_index)
+    g_source_remove(timer_index);
+
+  clear_background();
+}
+
+
+
+static gboolean
+load_graph_destroy (GtkWidget *widget, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    delete graph;
+
+    return FALSE;
+}
+
+
+LoadGraph::LoadGraph(guint type)
+  : fontsize(8.0),
+    rmargin(3.5 * fontsize),
+    indent(24.0),
+    n(0),
+    type(type),
+    speed(0),
+    draw_width(0),
+    draw_height(0),
+    render_counter(0),
+    frames_per_unit(10), // this will be changed but needs initialising
+    graph_dely(0),
+    real_draw_height(0),
+    graph_delx(0.0),
+    graph_buffer_offset(0),
+    main_widget(NULL),
+    disp(NULL),
+    background(NULL),
+    timer_index(0),
+    draw(FALSE),
+    mem_color_picker(NULL),
+    swap_color_picker(NULL)
+{
+    LoadGraph * const graph = this;
+
+    // FIXME:
+    // on configure, graph->frames_per_unit = graph->draw_width/(LoadGraph::NUM_POINTS);
+    // knock FRAMES down to 5 until cairo gets faster
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memset(&cpu, 0, sizeof cpu);
+        n = ProcData::get_instance()->config.num_cpus;
+
+        for(guint i = 0; i < G_N_ELEMENTS(labels.cpu); ++i)
+            labels.cpu[i] = gtk_label_new(NULL);
+
+        break;
+
+    case LOAD_GRAPH_MEM:
+        n = 2;
+        labels.memory = gtk_label_new(NULL);
+        labels.swap = gtk_label_new(NULL);
+        break;
+
+    case LOAD_GRAPH_NET:
+        memset(&net, 0, sizeof net);
+        n = 2;
+        net.max = 1;
+        labels.net_in = gtk_label_new(NULL);
+        labels.net_in_total = gtk_label_new(NULL);
+        labels.net_out = gtk_label_new(NULL);
+        labels.net_out_total = gtk_label_new(NULL);
+        break;
+    }
+
+    speed  = ProcData::get_instance()->config.graph_update_interval;
+
+    colors.resize(n);
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memcpy(&colors[0], ProcData::get_instance()->config.cpu_color,
+               n * sizeof colors[0]);
+        break;
+    case LOAD_GRAPH_MEM:
+        colors[0] = ProcData::get_instance()->config.mem_color;
+        colors[1] = ProcData::get_instance()->config.swap_color;
+        mem_color_picker = gsm_color_button_new (&colors[0],
+                                                 GSMCP_TYPE_PIE);
+        swap_color_picker = gsm_color_button_new (&colors[1],
+                                                  GSMCP_TYPE_PIE);
+        break;
+    case LOAD_GRAPH_NET:
+        colors[0] = ProcData::get_instance()->config.net_in_color;
+        colors[1] = ProcData::get_instance()->config.net_out_color;
+        break;
+    }
+
+    timer_index = 0;
+    render_counter = (frames_per_unit - 1);
+    draw = FALSE;
+
+    main_widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+    gtk_widget_set_size_request(main_widget, -1, LoadGraph::GRAPH_MIN_HEIGHT);
+    gtk_widget_show (main_widget);
+
+    disp = gtk_drawing_area_new ();
+    gtk_widget_show (disp);
+    g_signal_connect (G_OBJECT (disp), "draw", G_CALLBACK (load_graph_draw), graph);
+    g_signal_connect (G_OBJECT(disp), "configure_event",
+                      G_CALLBACK (load_graph_configure), graph);
+    g_signal_connect (G_OBJECT(disp), "destroy",
+                      G_CALLBACK (load_graph_destroy), graph);
+
+    gtk_widget_set_events (disp, GDK_EXPOSURE_MASK);
+
+    gtk_box_pack_start (GTK_BOX (main_widget), disp, TRUE, TRUE, 0);
+
+
+    /* Allocate data in a contiguous block */
+    data_block = std::vector<float>(n * LoadGraph::NUM_POINTS, -1.0f);
+
+    for (guint i = 0; i < LoadGraph::NUM_POINTS; ++i)
+        data[i] = &data_block[0] + i * n;
+
+    gtk_widget_show_all (main_widget);
+}
+
+void
+load_graph_start (LoadGraph *graph)
+{
+    if(!graph->timer_index) {
+
+        load_graph_update(graph);
+
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->draw = TRUE;
+}
+
+void
+load_graph_stop (LoadGraph *graph)
+{
+    /* don't draw anymore, but continue to poll */
+    graph->draw = FALSE;
+}
+
+void
+load_graph_change_speed (LoadGraph *graph,
+             guint new_speed)
+{
+    if (graph->speed == new_speed)
+        return;
+
+    graph->speed = new_speed;
+
+    if(graph->timer_index) {
+        g_source_remove (graph->timer_index);
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->clear_background();
+}
+
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *graph)
+{
+    return &graph->labels;
+}
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *graph)<--- Parameter 'graph' can be declared as pointer to const
+{
+    return graph->main_widget;
+}
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *graph)<--- Parameter 'graph' can be declared as pointer to const
+{
+    return graph->mem_color_picker;
+}
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *graph)<--- Parameter 'graph' can be declared as pointer to const
+{
+    return graph->swap_color_picker;
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/25.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/25.html new file mode 100644 index 00000000..cbf052f0 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/25.html @@ -0,0 +1,1075 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtkmm/messagedialog.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/regex.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procopenfiles.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <sys/wait.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <set><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sstream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <iterator><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibmm/regex.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "lsof.h"
+#include "util.h"
+
+
+using std::string;
+
+
+namespace
+{
+
+    class Lsof
+    {
+        Glib::RefPtr<Glib::Regex> re;
+
+        bool matches(const string &filename) const
+        {
+            return this->re->match(filename);
+        }
+
+    public:
+
+        Lsof(const string &pattern, bool caseless)
+        {
+            Glib::RegexCompileFlags flags = static_cast<Glib::RegexCompileFlags>(0);
+
+            if (caseless)
+                flags |= Glib::REGEX_CASELESS;
+
+            this->re = Glib::Regex::create(pattern, flags);
+        }
+
+
+        template<typename OutputIterator>
+        void search(const ProcInfo &info, OutputIterator out) const
+        {
+            glibtop_open_files_entry *entries;
+            glibtop_proc_open_files buf;
+
+            entries = glibtop_get_proc_open_files(&buf, info.pid);
+
+            for (unsigned i = 0; i != buf.number; ++i) {
+                if (entries[i].type & GLIBTOP_FILE_TYPE_FILE) {
+                    const string filename(entries[i].info.file.name);
+                    if (this->matches(filename))
+                        *out++ = filename;
+                }
+            }
+
+            g_free(entries);
+        }
+    };
+
+
+
+    // GUI Stuff
+
+
+    enum ProcmanLsof {
+        PROCMAN_LSOF_COL_SURFACE,
+        PROCMAN_LSOF_COL_PROCESS,
+        PROCMAN_LSOF_COL_PID,
+        PROCMAN_LSOF_COL_FILENAME,
+        PROCMAN_LSOF_NCOLS
+    };
+
+
+    struct GUI {
+
+        GtkListStore *model;
+        GtkEntry *entry;
+        GtkWindow *window;
+        GtkLabel *count;<--- Shadowed declaration
+        ProcData *procdata;
+        bool case_insensitive;
+
+
+        GUI()
+        {
+            procman_debug("New Lsof GUI %p", this);
+        }
+
+
+        ~GUI()
+        {
+            procman_debug("Destroying Lsof GUI %p", this);
+        }
+
+
+        void clear_results()
+        {
+            gtk_list_store_clear(this->model);
+            gtk_label_set_text(this->count, "");
+        }
+
+
+        void clear()
+        {
+            this->clear_results();
+            gtk_entry_set_text(this->entry, "");
+        }
+
+
+        void display_regex_error(const Glib::RegexError& error)
+        {
+            char * msg = g_strdup_printf ("<b>%s</b>\n%s\n%s",
+                                          _("Error"),
+                                          _("'%s' is not a valid Perl regular expression."),
+                                          "%s");
+            std::string message = make_string(g_strdup_printf(msg, this->pattern().c_str(), error.what().c_str()));
+            g_free(msg);
+
+            Gtk::MessageDialog dialog(message,
+                                      true, // use markup
+                                      Gtk::MESSAGE_ERROR,
+                                      Gtk::BUTTONS_OK,
+                                      true); // modal
+            dialog.run();
+        }
+
+
+        void update_count(unsigned count)
+        {
+            std::ostringstream ss;
+            ss << count;
+            string s = ss.str();
+            gtk_label_set_text(this->count, s.c_str());
+        }
+
+
+        string pattern() const
+        {
+            return gtk_entry_get_text(this->entry);
+        }
+
+
+        void search()
+        {
+            typedef std::set<string> MatchSet;
+            typedef MatchSet::const_iterator iterator;
+
+            this->clear_results();
+
+
+            try {
+                Lsof lsof(this->pattern(), this->case_insensitive);
+
+                unsigned count = 0;<--- Shadow variable
+
+                for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it) {
+                    const ProcInfo &info(*it->second);
+
+                    MatchSet matches;
+                    lsof.search(info, std::inserter(matches, matches.begin()));
+                    count += matches.size();
+
+                    for (iterator it(matches.begin()), end(matches.end()); it != end; ++it) {
+                        GtkTreeIter file;
+                        gtk_list_store_append(this->model, &file);
+                        gtk_list_store_set(this->model, &file,
+                                           PROCMAN_LSOF_COL_SURFACE, info.surface,
+                                           PROCMAN_LSOF_COL_PROCESS, info.name,
+                                           PROCMAN_LSOF_COL_PID, info.pid,
+                                           PROCMAN_LSOF_COL_FILENAME, it->c_str(),
+                                           -1);
+                    }
+                }
+
+                this->update_count(count);
+            }
+            catch (Glib::RegexError& error) {
+                this->display_regex_error(error);
+            }
+        }
+
+
+        static void search_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void search_entry_activate(GtkEntry *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void clear_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->clear();
+        }
+
+
+        static void close_button_clicked(GtkButton *, gpointer data)
+        {
+            GUI *gui = static_cast<GUI*>(data);
+            gtk_widget_destroy(GTK_WIDGET(gui->window));
+            delete gui;
+        }
+
+
+        static void case_button_toggled(GtkToggleButton *button, gpointer data)
+        {
+            bool state = gtk_toggle_button_get_active(button);
+            static_cast<GUI*>(data)->case_insensitive = state;
+        }
+
+
+        static gboolean window_delete_event(GtkWidget *, GdkEvent *, gpointer data)
+        {
+            delete static_cast<GUI*>(data);
+            return FALSE;
+        }
+
+    };
+}
+
+
+
+
+void procman_lsof(ProcData *procdata)
+{
+    GtkListStore *model = \
+        gtk_list_store_new(PROCMAN_LSOF_NCOLS,
+                           CAIRO_GOBJECT_TYPE_SURFACE, // PROCMAN_LSOF_COL_SURFACE
+                           G_TYPE_STRING,              // PROCMAN_LSOF_COL_PROCESS
+                           G_TYPE_UINT,                // PROCMAN_LSOF_COL_PID
+                           G_TYPE_STRING               // PROCMAN_LSOF_COL_FILENAME
+        );
+
+    GtkWidget *tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_object_unref(model);
+
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *renderer;
+
+    // SURFACE / PROCESS
+
+    column = gtk_tree_view_column_new();
+
+    renderer = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "surface", PROCMAN_LSOF_COL_SURFACE,
+                                        NULL);
+
+    renderer = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "text", PROCMAN_LSOF_COL_PROCESS,
+                                        NULL);
+
+    gtk_tree_view_column_set_title(column, _("Process"));
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PROCESS);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_column_set_min_width(column, 10);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), PROCMAN_LSOF_COL_PROCESS,
+                                         GTK_SORT_ASCENDING);
+
+
+    // PID
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("PID"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_PID,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PID);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    // FILENAME
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("Filename"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_FILENAME,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_FILENAME);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    GtkWidget *dialog; /* = gtk_dialog_new_with_buttons(_("Search for Open Files"), NULL,
+                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+                                                        NULL); */
+    dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(procdata->app));
+    gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
+    // gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_title(GTK_WINDOW(dialog), _("Search for Open Files"));
+
+    // g_signal_connect(G_OBJECT(dialog), "response",
+    //                           G_CALLBACK(close_dialog), NULL);
+    gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(dialog), 575, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(dialog), 12);
+    GtkWidget *mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_add(GTK_CONTAINER(dialog), mainbox);
+    gtk_box_set_spacing(GTK_BOX(mainbox), 6);
+
+
+    // Label, entry and search button
+
+    GtkWidget *hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), hbox1, FALSE, FALSE, 0);
+
+    GtkWidget *image = gtk_image_new_from_icon_name("edit-find", GTK_ICON_SIZE_DIALOG);
+    gtk_box_pack_start(GTK_BOX(hbox1), image, FALSE, FALSE, 0);
+
+
+    GtkWidget *vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox1), vbox2, TRUE, TRUE, 0);
+
+
+    GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox, TRUE, TRUE, 0);
+    GtkWidget *label = gtk_label_new_with_mnemonic(_("_Name contains:"));
+    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+    GtkWidget *entry = gtk_entry_new();
+
+    gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
+
+    GtkWidget *search_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                         "label", "gtk-find",
+                                                         "use-stock", TRUE,
+                                                         "use-underline", TRUE,
+                                                         NULL));
+
+    gtk_box_pack_start(GTK_BOX(hbox), search_button, FALSE, FALSE, 0);
+
+    GtkWidget *clear_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-clear",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    /* The default accelerator collides with the default close accelerator. */
+    gtk_button_set_label(GTK_BUTTON(clear_button), _("C_lear"));
+    gtk_box_pack_start(GTK_BOX(hbox), clear_button, FALSE, FALSE, 0);
+
+
+    GtkWidget *case_button = gtk_check_button_new_with_mnemonic(_("Case insensitive matching"));
+    GtkWidget *hbox3 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox3), case_button, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox3, FALSE, FALSE, 0);
+
+
+    GtkWidget *results_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), results_box, FALSE, FALSE, 0);
+    GtkWidget *results_label = gtk_label_new_with_mnemonic(_("S_earch results:"));
+    gtk_box_pack_start(GTK_BOX(results_box), results_label, FALSE, FALSE, 0);
+    GtkWidget *count_label = gtk_label_new(NULL);
+    gtk_box_pack_end(GTK_BOX(results_box), count_label, FALSE, FALSE, 0);
+
+    // Scrolled TreeView
+    GtkWidget *scrolled = gtk_scrolled_window_new(NULL, NULL);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
+                                   GTK_POLICY_AUTOMATIC,
+                                   GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled),
+                                        GTK_SHADOW_IN);
+    gtk_container_add(GTK_CONTAINER(scrolled), tree);
+    gtk_box_pack_start(GTK_BOX(mainbox), scrolled, TRUE, TRUE, 0);
+
+    GtkWidget *bottom_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+
+    GtkWidget *close_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-close",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    gtk_box_pack_start(GTK_BOX(mainbox), bottom_box, FALSE, FALSE, 0);
+    gtk_box_pack_end(GTK_BOX(bottom_box), close_button, FALSE, FALSE, 0);
+
+
+    GUI *gui = new GUI; // wil be deleted by the close button or delete-event
+    gui->procdata = procdata;
+    gui->model = model;
+    gui->window = GTK_WINDOW(dialog);
+    gui->entry = GTK_ENTRY(entry);
+    gui->count = GTK_LABEL(count_label);
+
+    g_signal_connect(G_OBJECT(entry), "activate",
+                     G_CALLBACK(GUI::search_entry_activate), gui);
+    g_signal_connect(G_OBJECT(clear_button), "clicked",
+                     G_CALLBACK(GUI::clear_button_clicked), gui);
+    g_signal_connect(G_OBJECT(search_button), "clicked",
+                     G_CALLBACK(GUI::search_button_clicked), gui);
+    g_signal_connect(G_OBJECT(close_button), "clicked",
+                     G_CALLBACK(GUI::close_button_clicked), gui);
+    g_signal_connect(G_OBJECT(case_button), "toggled",
+                     G_CALLBACK(GUI::case_button_toggled), gui);
+    g_signal_connect(G_OBJECT(dialog), "delete-event",
+                     G_CALLBACK(GUI::window_delete_event), gui);
+
+
+    gtk_widget_show_all(dialog);
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/26.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/26.html new file mode 100644 index 00000000..7bce5b12 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/26.html @@ -0,0 +1,1197 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibtop/procmap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mountlist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <map><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sstream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <iomanip><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdexcept><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+using std::string;
+
+
+#include "procman.h"
+#include "memmaps.h"
+#include "proctable.h"
+#include "util.h"
+
+
+/* be careful with this enum, you could break the column names */
+enum
+{
+    MMAP_COL_FILENAME,
+    MMAP_COL_VMSTART,
+    MMAP_COL_VMEND,
+    MMAP_COL_VMSZ,
+    MMAP_COL_FLAGS,
+    MMAP_COL_VMOFFSET,
+    MMAP_COL_PRIVATE_CLEAN,
+    MMAP_COL_PRIVATE_DIRTY,
+    MMAP_COL_SHARED_CLEAN,
+    MMAP_COL_SHARED_DIRTY,
+    MMAP_COL_DEVICE,
+    MMAP_COL_INODE,
+    MMAP_COL_MAX
+};
+
+
+namespace
+{
+    class OffsetFormater
+    {
+        string format;
+
+    public:
+
+        void set(const glibtop_map_entry &last_map)
+        {
+            this->format = (last_map.end <= G_MAXUINT32) ? "%08" G_GINT64_MODIFIER "x" : "%016" G_GINT64_MODIFIER "x";
+        }
+
+        string operator()(guint64 v) const
+        {
+            char buffer[17];
+            g_snprintf(buffer, sizeof buffer, this->format.c_str(), v);
+            return buffer;
+        }
+    };
+
+
+    class InodeDevices
+    {
+        typedef std::map<guint16, string> Map;
+        Map devices;
+
+    public:
+
+        void update()
+        {
+            this->devices.clear();
+
+            glibtop_mountlist list;
+            glibtop_mountentry *entries = glibtop_get_mountlist(&list, 1);
+
+            for (unsigned i = 0; i != list.number; ++i) {
+                struct stat buf;
+
+                if (stat(entries[i].devname, &buf) != -1)
+                    this->devices[buf.st_rdev] = entries[i].devname;
+            }
+
+            g_free(entries);
+        }
+
+        string get(guint64 dev64)
+        {
+            if (dev64 == 0)
+                return "";
+
+            guint16 dev = dev64 & 0xffff;
+
+            if (dev != dev64)
+                g_warning("weird device %" G_GINT64_MODIFIER "x", dev64);
+
+            Map::iterator it(this->devices.find(dev));
+
+            if (it != this->devices.end())
+                return it->second;
+
+            guint8 major, minor;
+            major = dev >> 8;
+            minor = dev;
+
+            std::ostringstream out;
+            out << std::hex
+                << std::setfill('0')
+                << std::setw(2) << unsigned(major)
+                << ':'
+                << std::setw(2) << unsigned(minor);
+
+            this->devices[dev] = out.str();
+            return out.str();
+        }
+    };
+
+
+    class MemMapsData
+    {
+    public:
+        guint timer;
+        GtkWidget *tree;
+        GSettings *settings;
+        ProcInfo *info;
+        OffsetFormater format;
+        mutable InodeDevices devices;
+        const char * const schema;
+
+        MemMapsData(GtkWidget *a_tree, GSettings *a_settings)
+            : tree(a_tree),
+            settings(a_settings),
+            schema("memmapstree")
+        {
+            procman_get_tree_state(this->settings, this->tree, this->schema);
+        }
+
+        ~MemMapsData()
+        {
+            procman_save_tree_state(this->settings, this->tree, this->schema);
+        }
+    };
+}
+
+
+struct glibtop_map_entry_cmp
+{
+    bool operator()(const glibtop_map_entry &a, const guint64 start) const
+    {
+        return a.start < start;
+    }
+
+    bool operator()(const guint64 &start, const glibtop_map_entry &a) const
+    {
+        return start < a.start;
+    }
+
+};
+
+
+static void
+update_row(GtkTreeModel *model, GtkTreeIter &row, const MemMapsData &mm, const glibtop_map_entry *memmaps)
+{
+    guint64 size;
+    string filename, device;
+    string vmstart, vmend, vmoffset;
+    char flags[5] = "----";
+
+    size = memmaps->end - memmaps->start;
+
+    if(memmaps->perm & GLIBTOP_MAP_PERM_READ)    flags [0] = 'r';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_WRITE)   flags [1] = 'w';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_EXECUTE) flags [2] = 'x';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_SHARED)  flags [3] = 's';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_PRIVATE) flags [3] = 'p';
+
+    if (memmaps->flags & (1 << GLIBTOP_MAP_ENTRY_FILENAME))
+      filename = memmaps->filename;
+
+    vmstart  = mm.format(memmaps->start);
+    vmend    = mm.format(memmaps->end);
+    vmoffset = mm.format(memmaps->offset);
+    device   = mm.devices.get(memmaps->device);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        MMAP_COL_FILENAME, filename.c_str(),
+                        MMAP_COL_VMSTART, vmstart.c_str(),
+                        MMAP_COL_VMEND, vmend.c_str(),
+                        MMAP_COL_VMSZ, size,
+                        MMAP_COL_FLAGS, flags,
+                        MMAP_COL_VMOFFSET, vmoffset.c_str(),
+                        MMAP_COL_PRIVATE_CLEAN, memmaps->private_clean,
+                        MMAP_COL_PRIVATE_DIRTY, memmaps->private_dirty,
+                        MMAP_COL_SHARED_CLEAN, memmaps->shared_clean,
+                        MMAP_COL_SHARED_DIRTY, memmaps->shared_dirty,
+                        MMAP_COL_DEVICE, device.c_str(),
+                        MMAP_COL_INODE, memmaps->inode,
+                        -1);
+}
+
+
+
+
+static void
+update_memmaps_dialog (MemMapsData *mmdata)
+{
+    GtkTreeModel *model;
+    glibtop_map_entry *memmaps;
+    glibtop_proc_map procmap;
+
+    memmaps = glibtop_get_proc_map (&procmap, mmdata->info->pid);
+    /* process has disappeared */
+    if(!memmaps or procmap.number == 0) return;
+
+    mmdata->format.set(memmaps[procmap.number - 1]);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+
+    GtkTreeIter iter;<--- Shadowed declaration
+
+    typedef std::map<guint64, GtkTreeIter> IterCache;
+    IterCache iter_cache;
+
+    /*
+      removes the old maps and
+      also fills a cache of start -> iter in order to speed
+      up add
+    */
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        while (true) {
+            char *vmstart = 0;
+            guint64 start;
+            gtk_tree_model_get(model, &iter,
+                               MMAP_COL_VMSTART, &vmstart,
+                               -1);
+
+            try {
+                std::istringstream(vmstart) >> std::hex >> start;
+            } catch (std::logic_error &e) {
+                g_warning("Could not parse %s", vmstart);
+                start = 0;
+            }
+
+            g_free(vmstart);
+
+            bool found = std::binary_search(memmaps, memmaps + procmap.number,
+                                            start, glibtop_map_entry_cmp());
+
+            if (found) {
+                iter_cache[start] = iter;
+                if (!gtk_tree_model_iter_next(model, &iter))
+                    break;
+            } else {
+                if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                    break;
+            }
+        }
+    }
+
+    mmdata->devices.update();
+
+    /*
+      add the new maps
+    */
+
+    for (guint i = 0; i != procmap.number; i++) {
+        GtkTreeIter iter;<--- Shadow variable
+        IterCache::iterator it(iter_cache.find(memmaps[i].start));
+
+        if (it != iter_cache.end())
+            iter = it->second;
+        else
+            gtk_list_store_prepend(GTK_LIST_STORE(model), &iter);
+
+        update_row(model, iter, *mmdata, &memmaps[i]);
+    }
+
+    g_free (memmaps);
+}
+
+
+
+static void
+dialog_response (GtkDialog * dialog, gint response_id, gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+
+    g_source_remove (mmdata->timer);
+
+    delete mmdata;
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+
+static MemMapsData*
+create_memmapsdata (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Filename"),
+        // xgettext: virtual memory start
+        N_("VM Start"),
+        // xgettext: virtual memory end
+        N_("VM End"),
+        // xgettext: virtual memory syze
+        N_("VM Size"),
+        N_("Flags"),
+        // xgettext: virtual memory offset
+        N_("VM Offset"),
+        // xgettext: memory that has not been modified since
+        // it has been allocated
+        N_("Private clean"),
+        // xgettext: memory that has been modified since it
+        // has been allocated
+        N_("Private dirty"),
+        // xgettext: shared memory that has not been modified
+        // since it has been allocated
+        N_("Shared clean"),
+        // xgettext: shared memory that has been modified
+        // since it has been allocated
+        N_("Shared dirty"),
+        N_("Device"),
+        N_("Inode")
+    };
+
+    model = gtk_list_store_new (MMAP_COL_MAX,
+                                G_TYPE_STRING, /* MMAP_COL_FILENAME  */
+                                G_TYPE_STRING, /* MMAP_COL_VMSTART     */
+                                G_TYPE_STRING, /* MMAP_COL_VMEND     */
+                                G_TYPE_UINT64, /* MMAP_COL_VMSZ     */
+                                G_TYPE_STRING, /* MMAP_COL_FLAGS     */
+                                G_TYPE_STRING, /* MMAP_COL_VMOFFSET  */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_DIRTY */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_DIRTY */
+                                G_TYPE_STRING, /* MMAP_COL_DEVICE     */
+                                G_TYPE_UINT64 /* MMAP_COL_INODE     */
+                                );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < MMAP_COL_MAX; i++) {
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(tree), col);
+
+        switch (i) {
+            case MMAP_COL_PRIVATE_CLEAN:
+            case MMAP_COL_PRIVATE_DIRTY:
+            case MMAP_COL_SHARED_CLEAN:
+            case MMAP_COL_SHARED_DIRTY:
+            case MMAP_COL_VMSZ:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                         &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+                break;
+        }
+
+
+        switch (i) {
+            case MMAP_COL_VMSTART:
+            case MMAP_COL_VMEND:
+            case MMAP_COL_FLAGS:
+            case MMAP_COL_VMOFFSET:
+            case MMAP_COL_DEVICE:
+                g_object_set(cell, "family", "monospace", NULL);
+                break;
+        }
+    }
+
+    return new MemMapsData(tree, procdata->settings);
+}
+
+
+static gboolean
+memmaps_timer (gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+    g_assert(model);
+
+    update_memmaps_dialog (mmdata);
+
+    return TRUE;
+}
+
+
+static void
+create_single_memmaps_dialog (GtkTreeModel *model, GtkTreePath *path,
+                              GtkTreeIter *iter, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    MemMapsData *mmdata;
+    GtkWidget *memmapsdialog;
+    GtkWidget *dialog_vbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    ProcInfo *info;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    mmdata = create_memmapsdata (procdata);
+    mmdata->info = info;
+
+    memmapsdialog = gtk_dialog_new_with_buttons (_("Memory Maps"), GTK_WINDOW (procdata->app),
+                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                 "gtk-close", GTK_RESPONSE_CLOSE,
+                                                 NULL);
+    gtk_window_set_resizable(GTK_WINDOW(memmapsdialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(memmapsdialog), 620, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(memmapsdialog), 5);
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG(memmapsdialog));
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Memory maps for process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), label, FALSE, TRUE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    gtk_container_add (GTK_CONTAINER (scrolled), mmdata->tree);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), mmdata->tree);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+
+    g_signal_connect(G_OBJECT(memmapsdialog), "response",
+                              G_CALLBACK(dialog_response), mmdata);
+
+    gtk_widget_show_all (memmapsdialog);
+
+    mmdata->timer = g_timeout_add_seconds (5, memmaps_timer, mmdata);
+
+    update_memmaps_dialog (mmdata);
+}
+
+
+void
+create_memmaps_dialog (ProcData *procdata)
+{
+    /* TODO: do we really want to open multiple dialogs ? */
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_memmaps_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/27.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/27.html new file mode 100644 index 00000000..fec20c10 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/27.html @@ -0,0 +1,1067 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#if defined (__ELF__) && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
+# define SECTION __attribute__ ((section (".gresource.msm"), aligned (8)))
+#else
+# define SECTION
+#endif
+
+static const SECTION union { const guint8 data[3353]; const double alignment; void * const ptr;}  msm_resource_data = { {<--- union member 'Anonymous0::alignment' is never used.<--- union member 'Anonymous0::ptr' is never used.
+  0107, 0126, 0141, 0162, 0151, 0141, 0156, 0164, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0030, 0000, 0000, 0000, 0310, 0000, 0000, 0000, 0000, 0000, 0000, 0050, 0006, 0000, 0000, 0000, 
+  0000, 0000, 0000, 0000, 0001, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0005, 0000, 0000, 0000, 0376, 0236, 0033, 0101, 0005, 0000, 0000, 0000, 
+  0310, 0000, 0000, 0000, 0024, 0000, 0114, 0000, 0334, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 
+  0113, 0120, 0220, 0013, 0002, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 0004, 0000, 0114, 0000, 
+  0350, 0000, 0000, 0000, 0354, 0000, 0000, 0000, 0324, 0265, 0002, 0000, 0377, 0377, 0377, 0377, 
+  0354, 0000, 0000, 0000, 0001, 0000, 0114, 0000, 0360, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 
+  0173, 0250, 0316, 0037, 0000, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 0014, 0000, 0166, 0000, 
+  0000, 0001, 0000, 0000, 0034, 0006, 0000, 0000, 0234, 0164, 0275, 0021, 0000, 0000, 0000, 0000, 
+  0034, 0006, 0000, 0000, 0016, 0000, 0166, 0000, 0060, 0006, 0000, 0000, 0017, 0015, 0000, 0000, 
+  0201, 0321, 0040, 0031, 0001, 0000, 0000, 0000, 0017, 0015, 0000, 0000, 0005, 0000, 0114, 0000, 
+  0024, 0015, 0000, 0000, 0030, 0015, 0000, 0000, 0155, 0141, 0164, 0145, 0055, 0163, 0171, 0163, 
+  0164, 0145, 0155, 0055, 0155, 0157, 0156, 0151, 0164, 0157, 0162, 0057, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0157, 0162, 0147, 0057, 0005, 0000, 0000, 0000, 0057, 0000, 0000, 0000, 
+  0001, 0000, 0000, 0000, 0151, 0156, 0164, 0145, 0162, 0146, 0141, 0143, 0145, 0056, 0165, 0151, 
+  0242, 0073, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0133, 0133, 0163, 0352, 0066, 
+  0020, 0176, 0317, 0257, 0160, 0375, 0332, 0161, 0010, 0227, 0320, 0164, 0006, 0070, 0323, 0166, 
+  0232, 0364, 0241, 0347, 0114, 0046, 0344, 0114, 0037, 0031, 0331, 0136, 0260, 0212, 0054, 0271, 
+  0222, 0314, 0345, 0337, 0237, 0065, 0066, 0004, 0002, 0370, 0102, 0210, 0061, 0224, 0067, 0154, 
+  0257, 0054, 0355, 0267, 0253, 0335, 0317, 0253, 0245, 0363, 0145, 0346, 0063, 0143, 0002, 0122, 
+  0121, 0301, 0273, 0146, 0375, 0366, 0316, 0064, 0200, 0073, 0302, 0245, 0174, 0324, 0065, 0277, 
+  0277, 0076, 0132, 0017, 0346, 0227, 0336, 0115, 0347, 0047, 0313, 0062, 0236, 0200, 0203, 0044, 
+  0032, 0134, 0143, 0112, 0265, 0147, 0214, 0030, 0161, 0301, 0150, 0336, 0066, 0037, 0156, 0033, 
+  0206, 0145, 0241, 0020, 0345, 0032, 0344, 0220, 0070, 0320, 0353, 0110, 0370, 0057, 0244, 0022, 
+  0224, 0301, 0250, 0335, 0065, 0107, 0172, 0374, 0263, 0371, 0066, 0113, 0363, 0266, 0321, 0062, 
+  0153, 0275, 0216, 0260, 0377, 0005, 0107, 0033, 0016, 0043, 0112, 0165, 0315, 0047, 0075, 0376, 
+  0207, 0162, 0127, 0114, 0115, 0203, 0272, 0135, 0323, 0047, 0224, 0017, 0246, 0361, 0215, 0136, 
+  0047, 0220, 0042, 0000, 0251, 0347, 0006, 0047, 0076, 0164, 0115, 0207, 0160, 0153, 0050, 0234, 
+  0120, 0231, 0275, 0107, 0302, 0024, 0164, 0152, 0113, 0201, 0055, 0121, 0115, 0065, 0003, 0323, 
+  0320, 0222, 0160, 0305, 0210, 0046, 0066, 0303, 0233, 0163, 0300, 0221, 0375, 0271, 0322, 0340, 
+  0033, 0137, 0005, 0247, 0132, 0310, 0224, 0127, 0270, 0060, 0044, 0041, 0323, 0326, 0224, 0272, 
+  0332, 0063, 0173, 0255, 0326, 0135, 0016, 0141, 0017, 0350, 0310, 0323, 0050, 0375, 0353, 0375, 
+  0272, 0264, 0343, 0121, 0346, 0356, 0120, 0375, 0167, 0061, 0133, 0323, 0333, 0306, 0253, 0255, 
+  0067, 0117, 0250, 0242, 0270, 0172, 0263, 0367, 0052, 0303, 0064, 0215, 0013, 0200, 0043, 0044, 
+  0005, 0256, 0211, 0106, 0263, 0230, 0075, 0264, 0217, 0246, 0016, 0141, 0073, 0226, 0033, 0060, 
+  0264, 0252, 0047, 0230, 0013, 0022, 0355, 0126, 0113, 0356, 0356, 0323, 0345, 0233, 0320, 0140, 
+  0013, 0061, 0216, 0025, 0342, 0313, 0253, 0143, 0050, 0224, 0041, 0351, 0023, 0071, 0242, 0334, 
+  0122, 0232, 0110, 0204, 0276, 0336, 0310, 0026, 0005, 0356, 0346, 0023, 0324, 0042, 0170, 0057, 
+  0230, 0151, 0113, 0065, 0127, 0224, 0017, 0105, 0151, 0346, 0364, 0140, 0026, 0220, 0110, 0241, 
+  0214, 0127, 0116, 0162, 0312, 0331, 0102, 0242, 0305, 0227, 0176, 0237, 0212, 0222, 0012, 0210, 
+  0203, 0061, 0143, 0017, 0104, 0251, 0376, 0263, 0373, 0141, 0055, 0206, 0365, 0235, 0264, 0241, 
+  0347, 0101, 0264, 0251, 0211, 0155, 0356, 0000, 0376, 0157, 0142, 0003, 0333, 0204, 0236, 0055, 
+  0156, 0225, 0001, 0176, 0074, 0323, 0376, 0100, 0263, 0076, 0164, 0245, 0034, 0242, 0066, 0106, 
+  0330, 0266, 0243, 0026, 0261, 0255, 0041, 0145, 0154, 0307, 0264, 0265, 0325, 0230, 0254, 0175, 
+  0270, 0362, 0103, 0034, 0354, 0374, 0037, 0234, 0060, 0063, 0234, 0355, 0165, 0332, 0207, 0074, 
+  0373, 0172, 0315, 0275, 0230, 0040, 0356, 0200, 0114, 0106, 0045, 0372, 0227, 0107, 0030, 0035, 
+  0241, 0136, 0213, 0340, 0126, 0310, 0231, 0226, 0100, 0147, 0315, 0020, 0073, 0134, 0306, 0212, 
+  0003, 0241, 0150, 0014, 0360, 0335, 0141, 0136, 0331, 0167, 0244, 0140, 0014, 0334, 0365, 0144, 
+  0037, 0071, 0050, 0050, 0005, 0152, 0240, 0222, 0247, 0145, 0144, 0213, 0143, 0173, 0252, 0362, 
+  0010, 0152, 0144, 0105, 0041, 0312, 0354, 0121, 0236, 0073, 0016, 0236, 0312, 0200, 0365, 0003, 
+  0303, 0112, 0250, 0065, 0016, 0137, 0030, 0016, 0323, 0147, 0142, 0073, 0073, 0276, 0133, 0040, 
+  0054, 0376, 0311, 0135, 0143, 0360, 0034, 0217, 0116, 0131, 0157, 0250, 0300, 0042, 0116, 0264, 
+  0142, 0213, 0004, 0001, 0020, 0174, 0221, 0003, 0331, 0130, 0034, 0337, 0135, 0044, 0070, 0100, 
+  0047, 0240, 0254, 0204, 0342, 0145, 0373, 0127, 0262, 0143, 0021, 0244, 0014, 0375, 0102, 0216, 
+  0036, 0301, 0050, 0337, 0261, 0334, 0123, 0071, 0107, 0043, 0335, 0071, 0062, 0227, 0125, 0314, 
+  0315, 0162, 0347, 0365, 0105, 0052, 0253, 0102, 0122, 0177, 0136, 0206, 0254, 0102, 0306, 0332, 
+  0203, 0312, 0247, 0146, 0177, 0374, 0014, 0273, 0046, 0377, 0242, 0214, 0165, 0077, 0234, 0116, 
+  0020, 0126, 0347, 0373, 0154, 0257, 0116, 0167, 0005, 0011, 0115, 0244, 0125, 0025, 0266, 0325, 
+  0037, 0317, 0337, 0215, 0277, 0250, 0302, 0017, 0362, 0171, 0312, 0370, 0131, 0022, 0131, 0067, 
+  0264, 0044, 0132, 0113, 0212, 0151, 0010, 0324, 0332, 0357, 0144, 0300, 0064, 0376, 0032, 0067, 
+  0046, 0204, 0205, 0013, 0267, 0142, 0156, 0124, 0201, 0250, 0255, 0217, 0071, 0063, 0036, 0265, 
+  0341, 0220, 0043, 0111, 0002, 0357, 0154, 0167, 0371, 0301, 0156, 0336, 0376, 0160, 0255, 0342, 
+  0221, 0211, 0351, 0006, 0222, 0103, 0274, 0121, 0032, 0220, 0223, 0175, 0234, 0076, 0265, 0256, 
+  0161, 0377, 0113, 0332, 0354, 0202, 0205, 0076, 0212, 0056, 0041, 0112, 0013, 0231, 0022, 0331, 
+  0152, 0056, 0101, 0037, 0047, 0137, 0040, 0050, 0201, 0133, 0370, 0300, 0212, 0271, 0112, 0063, 
+  0165, 0311, 0263, 0135, 0103, 0322, 0213, 0010, 0300, 0040, 0146, 0172, 0276, 0160, 0121, 0230, 
+  0013, 0176, 0112, 0056, 0204, 0223, 0044, 0144, 0076, 0235, 0301, 0345, 0246, 0072, 0025, 0045, 
+  0372, 0347, 0032, 0370, 0174, 0360, 0057, 0060, 0023, 0107, 0132, 0125, 0041, 0023, 0177, 0005, 
+  0037, 0223, 0260, 0201, 0206, 0067, 0372, 0123, 0022, 0134, 0263, 0162, 0161, 0347, 0274, 0146, 
+  0345, 0174, 0131, 0071, 0072, 0135, 0302, 0004, 0263, 0310, 0134, 0252, 0333, 0302, 0337, 0230, 
+  0231, 0124, 0167, 0161, 0254, 0264, 0015, 0361, 0223, 0244, 0356, 0033, 0306, 0013, 0227, 0055, 
+  0005, 0337, 0002, 0111, 0070, 0257, 0051, 0066, 0022, 0160, 0273, 0100, 0126, 0157, 0147, 0274, 
+  0324, 0023, 0276, 0030, 0001, 0007, 0261, 0253, 0256, 0221, 0043, 0010, 0051, 0334, 0361, 0145, 
+  0326, 0066, 0163, 0342, 0225, 0122, 0143, 0307, 0005, 0027, 0015, 0115, 0231, 0241, 0205, 0301, 
+  0120, 0133, 0030, 0214, 0210, 0343, 0245, 0223, 0035, 0055, 0202, 0225, 0334, 0201, 0201, 0143, 
+  0063, 0003, 0140, 0240, 0075, 0053, 0370, 0343, 0144, 0361, 0271, 0006, 0250, 0037, 0325, 0000, 
+  0007, 0034, 0111, 0235, 0342, 0341, 0225, 0362, 0136, 0024, 0345, 0255, 0177, 0220, 0125, 0160, 
+  0320, 0027, 0110, 0171, 0043, 0255, 0252, 0100, 0171, 0277, 0201, 0236, 0012, 0071, 0276, 0122, 
+  0335, 0342, 0116, 0171, 0245, 0272, 0173, 0330, 0154, 0073, 0067, 0233, 0215, 0140, 0074, 0031, 
+  0233, 0155, 0345, 0154, 0225, 0151, 0076, 0134, 0062, 0355, 0215, 0217, 0370, 0160, 0252, 0263, 
+  0042, 0137, 0057, 0313, 0125, 0237, 0023, 0377, 0112, 0063, 0203, 0026, 0232, 0260, 0101, 0162, 
+  0336, 0352, 0236, 0225, 0055, 0136, 0243, 0245, 0033, 0057, 0311, 0322, 0253, 0141, 0220, 0372, 
+  0207, 0015, 0242, 0160, 0357, 0237, 0333, 0256, 0350, 0143, 0104, 0377, 0134, 0374, 0357, 0113, 
+  0336, 0020, 0150, 0005, 0175, 0206, 0233, 0241, 0072, 0206, 0070, 0302, 0106, 0300, 0101, 0040, 
+  0267, 0341, 0137, 0034, 0120, 0133, 0121, 0327, 0063, 0050, 0235, 0221, 0045, 0077, 0215, 0322, 
+  0366, 0156, 0112, 0256, 0156, 0154, 0071, 0114, 0334, 0362, 0334, 0070, 0014, 0346, 0337, 0042, 
+  0077, 0360, 0321, 0131, 0336, 0347, 0342, 0200, 0072, 0143, 0220, 0003, 0262, 0172, 0136, 0006, 
+  0244, 0233, 0235, 0007, 0355, 0343, 0065, 0163, 0155, 0300, 0176, 0127, 0071, 0330, 0227, 0241, 
+  0376, 0202, 0101, 0157, 0225, 0016, 0372, 0045, 0026, 0176, 0076, 0122, 0146, 0313, 0255, 0134, 
+  0306, 0262, 0057, 0243, 0050, 0164, 0274, 0126, 0273, 0306, 0061, 0133, 0355, 0242, 0276, 0261, 
+  0052, 0124, 0145, 0136, 0100, 0211, 0120, 0072, 0007, 0167, 0332, 0065, 0112, 0353, 0264, 0033, 
+  0226, 0327, 0150, 0127, 0106, 0143, 0134, 0073, 0317, 0327, 0363, 0256, 0166, 0156, 0227, 0252, 
+  0361, 0265, 0225, 0273, 0102, 0045, 0274, 0002, 0273, 0245, 0171, 0314, 0020, 0062, 0254, 0106, 
+  0004, 0171, 0244, 0014, 0214, 0370, 0137, 0070, 0207, 0006, 0221, 0346, 0261, 0202, 0310, 0231, 
+  0235, 0074, 0364, 0061, 0160, 0204, 0312, 0046, 0062, 0141, 0207, 0253, 0313, 0112, 0237, 0100, 
+  0064, 0076, 0261, 0153, 0054, 0113, 0252, 0170, 0136, 0337, 0276, 0361, 0366, 0117, 0332, 0233, 
+  0037, 0325, 0360, 0311, 0023, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0160, 0162, 0145, 0146, 
+  0145, 0162, 0145, 0156, 0143, 0145, 0163, 0056, 0165, 0151, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0065, 0123, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0134, 0335, 0162, 0342, 0066, 
+  0024, 0276, 0357, 0123, 0250, 0276, 0355, 0050, 0004, 0262, 0155, 0167, 0072, 0301, 0073, 0335, 
+  0335, 0046, 0335, 0231, 0266, 0263, 0323, 0354, 0266, 0227, 0036, 0331, 0076, 0140, 0155, 0204, 
+  0344, 0112, 0002, 0102, 0257, 0372, 0054, 0175, 0264, 0076, 0111, 0217, 0177, 0010, 0140, 0300, 
+  0066, 0004, 0210, 0041, 0334, 0331, 0346, 0110, 0072, 0072, 0377, 0237, 0216, 0206, 0353, 0067, 
+  0017, 0003, 0101, 0106, 0240, 0015, 0127, 0262, 0353, 0264, 0057, 0056, 0035, 0002, 0062, 0120, 
+  0041, 0227, 0375, 0256, 0363, 0371, 0323, 0015, 0175, 0355, 0274, 0161, 0277, 0272, 0376, 0232, 
+  0122, 0162, 0013, 0022, 0064, 0263, 0020, 0222, 0061, 0267, 0021, 0351, 0013, 0026, 0002, 0271, 
+  0272, 0270, 0172, 0175, 0321, 0041, 0224, 0042, 0021, 0227, 0026, 0164, 0217, 0005, 0340, 0136, 
+  0153, 0370, 0153, 0310, 0065, 0030, 0042, 0270, 0337, 0165, 0372, 0366, 0376, 0033, 0147, 0266, 
+  0312, 0325, 0105, 0347, 0225, 0323, 0162, 0257, 0225, 0377, 0005, 0002, 0113, 0002, 0301, 0214, 
+  0351, 0072, 0267, 0366, 0376, 0303, 0200, 0365, 0301, 0041, 0074, 0354, 0072, 0074, 0171, 0154, 
+  0073, 0356, 0165, 0254, 0125, 0014, 0332, 0116, 0210, 0144, 0003, 0350, 0072, 0043, 0156, 0270, 
+  0057, 0300, 0161, 0077, 0351, 0041, 0134, 0267, 0246, 0277, 0056, 0321, 0005, 0114, 0322, 0236, 
+  0012, 0206, 0306, 0161, 0157, 0230, 0060, 0145, 0244, 0074, 0120, 0222, 0046, 0217, 0216, 0073, 
+  0346, 0062, 0124, 0143, 0032, 0010, 0265, 0070, 0242, 0225, 0261, 0132, 0203, 0345, 0316, 0241, 
+  0131, 0216, 0100, 0304, 0324, 0327, 0152, 0154, 0100, 0327, 0143, 0371, 0075, 0147, 0102, 0365, 
+  0063, 0236, 0143, 0015, 0075, 0320, 0250, 0161, 0060, 0136, 0230, 0175, 0177, 0012, 0137, 0276, 
+  0322, 0041, 0150, 0072, 0346, 0241, 0215, 0034, 0367, 0333, 0022, 0112, 0313, 0055, 0212, 0204, 
+  0130, 0315, 0244, 0021, 0314, 0062, 0024, 0120, 0327, 0231, 0000, 0256, 0161, 0067, 0061, 0026, 
+  0006, 0344, 0127, 0045, 0271, 0125, 0232, 0174, 0234, 0161, 0130, 0062, 0135, 0010, 0075, 0066, 
+  0024, 0166, 0272, 0362, 0253, 0313, 0313, 0032, 0304, 0021, 0360, 0176, 0144, 0221, 0272, 0123, 
+  0116, 0155, 0254, 0126, 0023, 0232, 0030, 0075, 0215, 0031, 0262, 0142, 0053, 0125, 0151, 0047, 
+  0061, 0320, 0210, 0047, 0224, 0231, 0124, 0347, 0151, 0203, 0210, 0213, 0220, 0244, 0316, 0042, 
+  0231, 0240, 0351, 0053, 0132, 0211, 0257, 0036, 0234, 0025, 0332, 0172, 0213, 0237, 0123, 0125, 
+  0145, 0023, 0171, 0202, 0115, 0324, 0320, 0076, 0111, 0113, 0003, 0246, 0373, 0134, 0122, 0253, 
+  0342, 0162, 0035, 0345, 0164, 0276, 0262, 0126, 0015, 0312, 0111, 0225, 0346, 0050, 0027, 0146, 
+  0321, 0277, 0035, 0027, 0035, 0335, 0362, 0200, 0211, 0022, 0172, 0023, 0263, 0000, 0103, 0214, 
+  0343, 0166, 0252, 0045, 0303, 0202, 0144, 0132, 0017, 0045, 0317, 0126, 0012, 0150, 0210, 0354, 
+  0311, 0242, 0230, 0026, 0007, 0155, 0040, 0253, 0164, 0321, 0265, 0313, 0144, 0153, 0044, 0076, 
+  0347, 0371, 0331, 0207, 0245, 0311, 0005, 0363, 0101, 0070, 0356, 0317, 0110, 0123, 0042, 0200, 
+  0241, 0001, 0232, 0361, 0110, 0131, 0034, 0003, 0103, 0077, 0010, 0240, 0132, 0165, 0133, 0304, 
+  0222, 0012, 0112, 0015, 0001, 0360, 0021, 0030, 0232, 0173, 0105, 0345, 0200, 0064, 0314, 0071, 
+  0156, 0026, 0355, 0126, 0106, 0034, 0324, 0355, 0075, 0052, 0167, 0151, 0044, 0074, 0304, 0114, 
+  0206, 0325, 0233, 0354, 0161, 0041, 0052, 0331, 0210, 0225, 0341, 0231, 0271, 0055, 0070, 0157, 
+  0353, 0161, 0361, 0126, 0256, 0311, 0072, 0012, 0115, 0003, 0176, 0225, 0106, 0337, 0025, 0263, 
+  0302, 0111, 0252, 0264, 0335, 0004, 0225, 0266, 0313, 0125, 0172, 0140, 0266, 0160, 0021, 0232, 
+  0104, 0164, 0307, 0005, 0031, 0356, 0320, 0044, 0223, 0242, 0112, 0322, 0100, 0211, 0341, 0100, 
+  0232, 0156, 0033, 0237, 0223, 0064, 0216, 0017, 0130, 0115, 0055, 0333, 0353, 0255, 0346, 0141, 
+  0156, 0255, 0012, 0043, 0244, 0264, 0136, 0077, 0371, 0162, 0210, 0162, 0143, 0323, 0350, 0236, 
+  0155, 0211, 0226, 0004, 0371, 0025, 0373, 0373, 0115, 0131, 0360, 0225, 0272, 0317, 0366, 0050, 
+  0247, 0157, 0007, 0360, 0227, 0150, 0152, 0056, 0025, 0164, 0243, 0232, 0164, 0045, 0125, 0120, 
+  0271, 0346, 0073, 0125, 0232, 0307, 0211, 0260, 0016, 0062, 0130, 0254, 0141, 0305, 0344, 0345, 
+  0166, 0160, 0020, 0023, 0330, 0257, 0214, 0332, 0235, 0035, 0132, 0037, 0212, 0162, 0146, 0172, 
+  0355, 0327, 0173, 0021, 0277, 0017, 0021, 0033, 0161, 0245, 0017, 0042, 0373, 0205, 0015, 0175, 
+  0127, 0307, 0227, 0176, 0111, 0063, 0326, 0032, 0236, 0275, 0074, 0237, 0035, 0302, 0152, 0230, 
+  0340, 0175, 0324, 0232, 0261, 0114, 0333, 0022, 0272, 0214, 0243, 0125, 0150, 0340, 0155, 0316, 
+  0164, 0131, 0055, 0211, 0162, 0021, 0100, 0005, 0227, 0100, 0007, 0052, 0134, 0261, 0001, 0146, 
+  0255, 0346, 0230, 0335, 0301, 0314, 0075, 0347, 0243, 0307, 0031, 0010, 0040, 0043, 0046, 0206, 
+  0251, 0135, 0212, 0060, 0301, 0246, 0255, 0371, 0061, 0225, 0371, 0106, 0100, 0317, 0122, 0034, 
+  0301, 0202, 0250, 0020, 0374, 0213, 0300, 0100, 0305, 0253, 0351, 0066, 0115, 0022, 0257, 0066, 
+  0267, 0125, 0317, 0100, 0220, 0071, 0321, 0001, 0064, 0237, 0143, 0207, 0124, 0361, 0025, 0376, 
+  0135, 0151, 0336, 0213, 0042, 0350, 0324, 0316, 0223, 0303, 0070, 0144, 0026, 0274, 0024, 0117, 
+  0240, 0172, 0017, 0227, 0057, 0353, 0006, 0313, 0142, 0236, 0154, 0167, 0266, 0166, 0356, 0307, 
+  0115, 0036, 0316, 0271, 0327, 0073, 0255, 0367, 0071, 0225, 0074, 0231, 0062, 0205, 0017, 0004, 
+  0215, 0117, 0311, 0320, 0374, 0120, 0121, 0100, 0017, 0045, 0246, 0205, 0304, 0225, 0053, 0071, 
+  0035, 0110, 0030, 0050, 0311, 0203, 0044, 0207, 0364, 0001, 0215, 0154, 0205, 0060, 0114, 0314, 
+  0245, 0134, 0163, 0056, 0362, 0014, 0276, 0274, 0244, 0312, 0073, 0344, 0157, 0036, 0207, 0254, 
+  0337, 0302, 0041, 0352, 0040, 0056, 0363, 0071, 0021, 0171, 0063, 0134, 0361, 0277, 0177, 0376, 
+  0055, 0233, 0127, 0360, 0201, 0117, 0223, 0003, 0301, 0102, 0275, 0136, 0074, 0077, 0341, 0175, 
+  0156, 0115, 0241, 0010, 0334, 0114, 0013, 0355, 0335, 0150, 0241, 0121, 0252, 0177, 0027, 0101, 
+  0260, 0200, 0101, 0315, 0100, 0051, 0033, 0125, 0200, 0320, 0125, 0336, 0366, 0223, 0114, 0136, 
+  0210, 0227, 0115, 0100, 0064, 0364, 0064, 0230, 0350, 0070, 0201, 0152, 0025, 0017, 0233, 0205, 
+  0210, 0120, 0263, 0061, 0345, 0062, 0304, 0202, 0321, 0046, 0265, 0132, 0221, 0174, 0077, 0006, 
+  0321, 0336, 0221, 0101, 0004, 0311, 0207, 0055, 0354, 0341, 0107, 0201, 0144, 0304, 0207, 0236, 
+  0322, 0100, 0020, 0261, 0342, 0352, 0104, 0151, 0342, 0335, 0043, 0330, 0115, 0236, 0037, 0203, 
+  0314, 0331, 0104, 0236, 0313, 0104, 0072, 0273, 0212, 0031, 0112, 0060, 0315, 0315, 0026, 0106, 
+  0342, 0275, 0347, 0043, 0036, 0002, 0171, 0367, 0361, 0063, 0031, 0032, 0326, 0007, 0342, 0117, 
+  0322, 0227, 0100, 0015, 0245, 0075, 0133, 0306, 0163, 0131, 0306, 0325, 0163, 0244, 0260, 0166, 
+  0163, 0363, 0346, 0323, 0241, 0172, 0217, 0203, 0010, 0315, 0121, 0036, 0222, 0354, 0010, 0370, 
+  0147, 0022, 0150, 0004, 0062, 0370, 0040, 0061, 0053, 0015, 0322, 0263, 0034, 0162, 0223, 0262, 
+  0125, 0062, 0315, 0227, 0241, 0261, 0274, 0067, 0161, 0334, 0344, 0230, 0266, 0204, 0016, 0060, 
+  0257, 0305, 0206, 0377, 0135, 0171, 0100, 0133, 0175, 0122, 0120, 0030, 0360, 0220, 0237, 0137, 
+  0134, 0236, 0370, 0151, 0302, 0306, 0356, 0324, 0074, 0054, 0135, 0327, 0247, 0052, 0117, 0023, 
+  0267, 0161, 0255, 0324, 0304, 0033, 0341, 0140, 0037, 0063, 0326, 0010, 0367, 0346, 0074, 0315, 
+  0104, 0152, 0054, 0023, 0020, 0056, 0270, 0261, 0173, 0106, 0340, 0126, 0003, 0170, 0271, 0201, 
+  0155, 0352, 0131, 0315, 0302, 0346, 0201, 0126, 0102, 0100, 0370, 0147, 0172, 0047, 0244, 0250, 
+  0170, 0223, 0377, 0172, 0214, 0375, 0011, 0023, 0261, 0344, 0226, 0113, 0326, 0322, 0342, 0262, 
+  0216, 0361, 0177, 0102, 0255, 0376, 0301, 0141, 0116, 0014, 0363, 0172, 0076, 0214, 0020, 0030, 
+  0332, 0245, 0241, 0217, 0063, 0127, 0371, 0010, 0244, 0260, 0230, 0032, 0054, 0121, 0023, 0053, 
+  0130, 0335, 0350, 0137, 0272, 0154, 0140, 0100, 0074, 0236, 0222, 0256, 0224, 0302, 0335, 0043, 
+  0301, 0242, 0105, 0114, 0203, 0052, 0235, 0315, 0320, 0132, 0121, 0102, 0235, 0140, 0041, 0327, 
+  0350, 0105, 0027, 0274, 0234, 0044, 0046, 0217, 0363, 0060, 0337, 0251, 0033, 0340, 0223, 0076, 
+  0133, 0203, 0342, 0372, 0042, 0150, 0257, 0024, 0055, 0316, 0100, 0263, 0036, 0367, 0322, 0312, 
+  0073, 0357, 0112, 0153, 0060, 0152, 0250, 0203, 0163, 0157, 0362, 0171, 0172, 0223, 0063, 0361, 
+  0367, 0065, 0213, 0243, 0146, 0001, 0236, 0047, 0001, 0231, 0342, 0316, 0016, 0331, 0277, 0254, 
+  0271, 0277, 0365, 0176, 0173, 0233, 0262, 0174, 0006, 0071, 0307, 0000, 0162, 0226, 0014, 0255, 
+  0241, 0015, 0323, 0203, 0037, 0063, 0154, 0333, 0200, 0235, 0011, 0264, 0320, 0212, 0075, 0255, 
+  0056, 0354, 0154, 0233, 0347, 0056, 0254, 0273, 0102, 0030, 0307, 0326, 0205, 0135, 0277, 0205, 
+  0163, 0027, 0366, 0324, 0273, 0260, 0076, 0112, 0151, 0233, 0166, 0312, 0135, 0244, 0306, 0104, 
+  0202, 0035, 0053, 0175, 0117, 0114, 0014, 0220, 0100, 0113, 0222, 0314, 0166, 0232, 0275, 0224, 
+  0272, 0301, 0365, 0004, 0032, 0266, 0057, 0247, 0347, 0122, 0271, 0150, 0355, 0033, 0332, 0233, 
+  0301, 0355, 0105, 0350, 0330, 0204, 0334, 0371, 0373, 0224, 0243, 0215, 0254, 0157, 0215, 0170, 
+  0366, 0007, 0312, 0053, 0113, 0332, 0020, 0106, 0374, 0014, 0311, 0237, 0011, 0222, 0117, 0205, 
+  0177, 0074, 0227, 0205, 0213, 0034, 0037, 0025, 0324, 0256, 0161, 0125, 0370, 0014, 0266, 0033, 
+  0003, 0266, 0227, 0114, 0355, 0310, 0301, 0366, 0336, 0100, 0364, 0124, 0120, 0047, 0174, 0215, 
+  0171, 0151, 0213, 0057, 0027, 0076, 0057, 0211, 0342, 0330, 0300, 0363, 0272, 0015, 0234, 0241, 
+  0363, 0251, 0103, 0147, 0046, 0204, 0067, 0325, 0176, 0172, 0167, 0165, 0023, 0000, 0235, 0342, 
+  0147, 0017, 0247, 0040, 0230, 0232, 0201, 0230, 0364, 0117, 0000, 0316, 0330, 0371, 0214, 0235, 
+  0137, 0310, 0175, 0305, 0251, 0343, 0274, 0324, 0333, 0212, 0213, 0373, 0077, 0052, 0334, 0161, 
+  0276, 0323, 0170, 0012, 0056, 0167, 0302, 0067, 0032, 0367, 0350, 0247, 0315, 0271, 0370, 0170, 
+  0063, 0053, 0033, 0236, 0347, 0362, 0143, 0310, 0315, 0175, 0162, 0051, 0116, 0302, 0370, 0144, 
+  0357, 0077, 0116, 0265, 0377, 0242, 0157, 0077, 0256, 0120, 0364, 0013, 0276, 0000, 0231, 0233, 
+  0004, 0115, 0044, 0062, 0102, 0031, 0235, 0357, 0077, 0036, 0305, 0242, 0263, 0126, 0105, 0147, 
+  0227, 0235, 0234, 0004, 0274, 0171, 0071, 0170, 0153, 0114, 0063, 0047, 0115, 0015, 0167, 0313, 
+  0210, 0162, 0133, 0041, 0075, 0245, 0237, 0323, 0314, 0276, 0136, 0315, 0320, 0271, 0247, 0177, 
+  0161, 0232, 0176, 0310, 0341, 0174, 0226, 0120, 0115, 0341, 0235, 0150, 0060, 0261, 0222, 0006, 
+  0127, 0240, 0355, 0166, 0366, 0277, 0207, 0171, 0243, 0036, 0113, 0321, 0171, 0312, 0222, 0201, 
+  0337, 0073, 0356, 0374, 0137, 0175, 0055, 0015, 0154, 0025, 0131, 0230, 0361, 0070, 0373, 0163, 
+  0313, 0257, 0376, 0007, 0112, 0344, 0157, 0105, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0155, 
+  0141, 0164, 0145, 0057, 0000, 0000, 0000, 0000
+} };
+
+static GStaticResource static_resource = { msm_resource_data.data, sizeof (msm_resource_data.data) - 1 /* nul terminator */, NULL, NULL, NULL };
+
+G_MODULE_EXPORT
+GResource *msm_get_resource (void);
+GResource *msm_get_resource (void)
+{
+  return g_static_resource_get_resource (&static_resource);
+}
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GLib Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __G_CONSTRUCTOR_H__
+#define __G_CONSTRUCTOR_H__
+
+/*
+  If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and
+  destructors, in a usable way, including e.g. on library unload. If not you're on
+  your own.
+
+  Some compilers need #pragma to handle this, which does not work with macros,
+  so the way you need to use this is (for constructors):
+
+  #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+  #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(my_constructor)
+  #endif
+  G_DEFINE_CONSTRUCTOR(my_constructor)
+  static void my_constructor(void) {
+   ...
+  }
+
+*/
+
+#ifndef __GTK_DOC_IGNORE__
+
+#if  __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func (void);
+#define G_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func (void);
+
+#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
+/* Visual studio 2008 and later has _Pragma */
+
+/*
+ * Only try to include gslist.h if not already included via glib.h,
+ * so that items using gconstructor.h outside of GLib (such as
+ * GResources) continue to build properly.
+ */
+#ifndef __G_LIB_H__
+#include "gslist.h"
+#endif
+
+#include <stdlib.h>
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* We do some weird things to avoid the constructors being optimized
+ * away on VS2015 if WholeProgramOptimization is enabled. First we
+ * make a reference to the array from the wrapper to make sure its
+ * references. Then we use a pragma to make sure the wrapper function
+ * symbol is always included at the link stage. Also, the symbols
+ * need to be extern (but not dllexport), even though they are not
+ * really used from another object file.
+ */
+
+/* We need to account for differences between the mangling of symbols
+ * for x86 and x64/ARM/ARM64 programs, as symbols on x86 are prefixed
+ * with an underscore but symbols on x64/ARM/ARM64 are not.
+ */
+#ifdef _M_IX86
+#define G_MSVC_SYMBOL_PREFIX "_"
+#else
+#define G_MSVC_SYMBOL_PREFIX ""
+#endif
+
+#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
+#define G_DEFINE_DESTRUCTOR(_func) G_MSVC_DTOR (_func, G_MSVC_SYMBOL_PREFIX)
+
+#define G_MSVC_CTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _wrapper(void) { _func(); g_slist_find (NULL,  _array ## _func); return 0; } \
+  __pragma(comment(linker,"/include:" _sym_prefix # _func "_wrapper")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _wrapper;
+
+#define G_MSVC_DTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _constructor(void) { atexit (_func); g_slist_find (NULL,  _array ## _func); return 0; } \
+   __pragma(comment(linker,"/include:" _sym_prefix # _func "_constructor")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined (_MSC_VER)
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* Pre Visual studio 2008 must use #pragma section */
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _wrapper(void) { _func(); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func ## _wrapper;
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _constructor(void) { atexit (_func); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined(__SUNPRO_C)
+
+/* This is not tested, but i believe it should work, based on:
+ * http://opensource.apple.com/source/OpenSSL098/OpenSSL098-35/src/fips/fips_premain.c
+ */
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  init(_func)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void);
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  fini(_func)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void);
+
+#else
+
+/* constructors not supported for this compiler */
+
+#endif
+
+#endif /* __GTK_DOC_IGNORE__ */
+#endif /* __G_CONSTRUCTOR_H__ */
+
+#ifdef G_HAS_CONSTRUCTORS
+
+#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(msmresource_constructor)
+#endif
+G_DEFINE_CONSTRUCTOR(msmresource_constructor)
+#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(msmresource_destructor)
+#endif
+G_DEFINE_DESTRUCTOR(msmresource_destructor)
+
+#else
+#warning "Constructor not supported on this compiler, linking in resources will not work"
+#endif
+
+static void msmresource_constructor (void)
+{
+  g_static_resource_init (&static_resource);
+}
+
+static void msmresource_destructor (void)
+{
+  g_static_resource_fini (&static_resource);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/28.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/28.html new file mode 100644 index 00000000..88cc9fc6 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/28.html @@ -0,0 +1,1039 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procopenfiles.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <netdb.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/socket.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <netinet/in.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <arpa/inet.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "openfiles.h"
+#include "proctable.h"
+#include "util.h"
+#include "settings-keys.h"
+
+#ifndef NI_IDN
+#define NI_IDN 0
+#endif
+
+enum
+{
+    COL_FD,
+    COL_TYPE,
+    COL_OBJECT,
+    COL_OPENFILE_STRUCT,
+    NUM_OPENFILES_COL
+};
+
+
+static const char*
+get_type_name(enum glibtop_file_type t)
+{
+    switch(t)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        return _("file");
+    case GLIBTOP_FILE_TYPE_PIPE:
+        return _("pipe");
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+        return _("IPv6 network connection");
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        return _("IPv4 network connection");
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        return _("local socket");
+    default:
+        return _("unknown type");
+    }
+}
+
+
+
+static char *
+friendlier_hostname(const char *addr_str, int port)
+{
+    struct addrinfo hints = { };
+    struct addrinfo *res = NULL;
+    char hostname[NI_MAXHOST];
+    char service[NI_MAXSERV];
+    char port_str[6];
+
+    if (!addr_str[0]) return g_strdup("");
+
+    snprintf(port_str, sizeof port_str, "%d", port);
+
+    hints.ai_family = AF_UNSPEC;
+    hints.ai_socktype = SOCK_STREAM;
+
+    if (getaddrinfo(addr_str, port_str, &hints, &res))
+        goto failsafe;
+
+    if (getnameinfo(res->ai_addr, res->ai_addrlen, hostname,<--- Null pointer dereference
+            sizeof hostname, service, sizeof service, NI_IDN))
+        goto failsafe;
+
+    if (res) freeaddrinfo(res);<--- Assuming that condition 'res' is not redundant
+        return g_strdup_printf("%s, TCP port %d (%s)", hostname, port, service);
+
+  failsafe:
+    if (res) freeaddrinfo(res);
+    return g_strdup_printf("%s, TCP port %d", addr_str, port);
+}
+
+
+
+static void
+add_new_files (gpointer key, gpointer value, gpointer data)
+{
+    glibtop_open_files_entry *openfiles = static_cast<glibtop_open_files_entry*>(value);
+
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreeIter row;
+
+    char *object;
+
+    switch(openfiles->type)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        object = g_strdup(openfiles->info.file.name);
+        break;
+
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        object = friendlier_hostname(openfiles->info.sock.dest_host,
+                         openfiles->info.sock.dest_port);
+        break;
+
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        object = g_strdup(openfiles->info.localsock.name);
+        break;
+
+    default:
+        object = g_strdup("");
+    }
+
+    gtk_list_store_insert (GTK_LIST_STORE (model), &row, 0);
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        COL_FD, openfiles->fd,
+                        COL_TYPE, get_type_name(static_cast<glibtop_file_type>(openfiles->type)),
+                        COL_OBJECT, object,
+#if GLIB_CHECK_VERSION (2, 68, 0)
+                        COL_OPENFILE_STRUCT, g_memdup2(openfiles, sizeof(*openfiles)),
+#else
+                        COL_OPENFILE_STRUCT, g_memdup(openfiles, sizeof(*openfiles)),
+#endif
+                        -1);
+
+    g_free(object);
+}
+
+static GList *old_maps = NULL;
+
+static gboolean
+classify_openfiles (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+    GHashTable *new_maps = static_cast<GHashTable*>(data);
+    GtkTreeIter *old_iter;
+    glibtop_open_files_entry *openfiles;
+    gchar *old_name;
+
+    gtk_tree_model_get (model, iter, 1, &old_name, -1);
+
+    openfiles = static_cast<glibtop_open_files_entry*>(g_hash_table_lookup (new_maps, old_name));
+    if (openfiles) {
+        g_hash_table_remove (new_maps, old_name);
+        g_free (old_name);
+        return FALSE;
+
+    }
+
+    old_iter = gtk_tree_iter_copy (iter);
+    old_maps = g_list_append (old_maps, old_iter);
+    g_free (old_name);
+    return FALSE;
+
+}
+
+
+static gboolean
+compare_open_files(gconstpointer a, gconstpointer b)
+{
+    const glibtop_open_files_entry *o1 = static_cast<const glibtop_open_files_entry *>(a);
+    const glibtop_open_files_entry *o2 = static_cast<const glibtop_open_files_entry *>(b);
+
+    /* Falta manejar los diferentes tipos! */
+    return (o1->fd == o2->fd) && (o1->type == o2->type); /* XXX! */
+}
+
+
+static void
+update_openfiles_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+    GtkTreeModel *model;
+    glibtop_open_files_entry *openfiles;<--- Shadowed declaration
+    glibtop_proc_open_files procmap;
+    GHashTable *new_maps;
+    guint i;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    if (!info)
+        return;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    openfiles = glibtop_get_proc_open_files (&procmap, info->pid);
+
+    if (!openfiles)
+        return;
+
+    new_maps = static_cast<GHashTable *>(g_hash_table_new_full (g_str_hash, compare_open_files,
+                                                                NULL, NULL));
+    for (i=0; i < procmap.number; i++)
+        g_hash_table_insert (new_maps, openfiles + i, openfiles + i);
+
+    gtk_tree_model_foreach (model, classify_openfiles, new_maps);
+
+    g_hash_table_foreach (new_maps, add_new_files, model);
+
+    while (old_maps) {
+        GtkTreeIter *iter = static_cast<GtkTreeIter*>(old_maps->data);
+        glibtop_open_files_entry *openfiles = NULL;<--- Shadow variable
+
+        gtk_tree_model_get (model, iter,
+                            COL_OPENFILE_STRUCT, &openfiles,
+                            -1);
+
+        gtk_list_store_remove (GTK_LIST_STORE (model), iter);
+        gtk_tree_iter_free (iter);
+        g_free (openfiles);
+
+        old_maps = g_list_next (old_maps);
+
+    }
+
+    g_hash_table_destroy (new_maps);
+    g_free (openfiles);
+}
+
+static void
+close_openfiles_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GSettings *settings;
+    guint timer;
+
+    settings = static_cast<GSettings*>(g_object_get_data (G_OBJECT (tree), "settings"));
+    procman_save_tree_state (settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    return ;
+}
+
+
+static GtkWidget *
+create_openfiles_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    const gchar * const titles[] = {
+        /* Translators: "FD" here means "File Descriptor". Please use
+           a very short translation if possible, and at most
+           2-3 characters for it to be able to fit in the UI. */
+        N_("FD"),
+        N_("Type"),
+        N_("Object")
+    };
+
+    model = gtk_list_store_new (NUM_OPENFILES_COL,
+                                G_TYPE_INT,        /* FD */
+                                G_TYPE_STRING,    /* Type */
+                                G_TYPE_STRING,    /* Object */
+                                G_TYPE_POINTER    /* open_files_entry */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_OPENFILES_COL-1; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        switch (i) {
+        case COL_FD:
+            g_object_set(cell, "xalign", 1.0f, NULL);
+            break;
+        }
+
+        column = gtk_tree_view_column_new_with_attributes (_(titles[i]),
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_sort_column_id (column, i);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    procman_get_tree_state (procdata->settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    return tree;
+}
+
+
+static gboolean
+openfiles_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_openfiles_dialog (tree);
+
+    return TRUE;
+}
+
+
+static void
+create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *openfilesdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    openfilesdialog = gtk_dialog_new_with_buttons (_("Open Files"), NULL,
+                                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                   "gtk-close", GTK_RESPONSE_CLOSE,
+                                                   NULL);
+    gtk_window_set_resizable (GTK_WINDOW (openfilesdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (openfilesdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (openfilesdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (openfilesdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Files opened by process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                    GTK_POLICY_AUTOMATIC,
+                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_openfiles_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+    g_object_set_data (G_OBJECT (tree), "settings", procdata->settings);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (openfilesdialog), "response",
+                      G_CALLBACK (close_openfiles_dialog), tree);
+
+    gtk_widget_show_all (openfilesdialog);
+
+    timer = g_timeout_add_seconds (5, openfiles_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_openfiles_dialog (tree);
+
+}
+
+
+void
+create_openfiles_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_openfiles_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/29.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/29.html new file mode 100644 index 00000000..a5901ac6 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/29.html @@ -0,0 +1,271 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
#ifndef H_PROCMAN_SETTINGS_KEYS_1177430397
+#define H_PROCMAN_SETTINGS_KEYS_1177430397
+
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+namespace procman
+{
+    namespace settings
+    {
+        extern const std::string root;
+        extern const std::string solaris_mode;
+        extern const std::string open_files_tree_prefix;
+        extern const std::string network_in_bits;
+    }
+}
+
+#endif //  H_PROCMAN_SETTINGS_KEYS_1177430397
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/3.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/3.html new file mode 100644 index 00000000..1d042194 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/3.html @@ -0,0 +1,395 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
/* Procman - callbacks
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef _PROCMAN_CALLBACKS_H_
+#define _PROCMAN_CALLBACKS_H_
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+#include "gsm_color_button.h"
+
+void            cb_show_memory_maps (GtkAction *action, gpointer data);
+void            cb_show_open_files (GtkAction *action, gpointer data);
+void            cb_show_process_properties (GtkAction *action, gpointer data);
+void            cb_show_lsof(GtkAction *action, gpointer data);
+void            cb_renice (GtkAction *action, GtkRadioAction *current, gpointer data);
+void            cb_end_process (GtkAction *action, gpointer data);
+void            cb_kill_process (GtkAction *action, gpointer data);
+void            cb_edit_preferences (GtkAction *action, gpointer data);
+
+void            cb_help_contents (GtkAction *action, gpointer data);
+void            cb_about (GtkAction *action, gpointer data);
+
+void            cb_app_exit (GtkAction *action, gpointer data);
+gboolean        cb_app_delete (GtkWidget *window, GdkEventAny *event, gpointer data);
+
+void            cb_end_process_button_pressed (GtkButton *button, gpointer data);
+void            cb_logout (GtkButton *button, gpointer data);
+
+void            cb_info_button_pressed (GtkButton *button, gpointer user_data);
+
+void            cb_cpu_color_changed (GSMColorButton *widget, gpointer user_data);
+void            cb_mem_color_changed (GSMColorButton *widget, gpointer user_data);
+void            cb_swap_color_changed (GSMColorButton *widget, gpointer user_data);
+void            cb_net_in_color_changed (GSMColorButton *widget, gpointer user_data);
+void            cb_net_out_color_changed (GSMColorButton *widget, gpointer user_data);
+
+void            cb_row_selected (GtkTreeSelection *selection, gpointer data);
+
+gboolean        cb_tree_popup_menu (GtkWidget *widget, gpointer data);
+gboolean        cb_tree_button_pressed (GtkWidget *widget, GdkEventButton *event,
+                                        gpointer data);
+
+void            cb_change_current_page (GtkNotebook *nb,
+                                        gint num, gpointer data);
+void            cb_switch_page (GtkNotebook *nb, GtkWidget *page,
+                                gint num, gpointer data);
+
+gint            cb_update_disks (gpointer data);
+gint            cb_user_refresh (GtkAction* action, gpointer data);
+gint            cb_timeout (gpointer data);
+
+void            cb_radio_processes(GtkAction *action,
+                                   GtkRadioAction *current,
+                                   gpointer data);
+
+void            cb_kill_sigstop(GtkAction *action,
+                                gpointer data);
+
+void            cb_kill_sigcont(GtkAction *action,
+                                gpointer data);
+
+#endif /* _PROCMAN_CALLBACKS_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/30.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/30.html new file mode 100644 index 00000000..7bdd1228 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/30.html @@ -0,0 +1,899 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef HAVE_WNCK
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <dirent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk-pixbuf/gdk-pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procstate.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/error.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/file.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/miscutils.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <iostream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <vector><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "prettytable.h"
+#include "defaulttable.h"
+#include "proctable.h"
+#include "util.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+namespace
+{
+  const unsigned APP_ICON_SIZE = 16;
+}
+
+
+PrettyTable::PrettyTable()
+{
+#ifdef HAVE_WNCK
+#ifdef GDK_WINDOWING_X11
+  if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+      WnckScreen* screen = wnck_screen_get_default();
+      g_signal_connect(G_OBJECT(screen), "application_opened",
+		       G_CALLBACK(PrettyTable::on_application_opened), this);
+      g_signal_connect(G_OBJECT(screen), "application_closed",
+	               G_CALLBACK(PrettyTable::on_application_closed), this);
+  }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    // init GIO apps cache
+    std::vector<std::string> dirs = Glib::get_system_data_dirs();
+    for (std::vector<std::string>::iterator it = dirs.begin(); it != dirs.end(); ++it) {
+        std::string path = (*it).append("/applications");
+        Glib::RefPtr<Gio::File> file = Gio::File::create_for_path(path);
+        Glib::RefPtr<Gio::FileMonitor> monitor = file->monitor_directory();
+        monitor->set_rate_limit(1000); // 1 second
+
+        monitor->signal_changed().connect(sigc::mem_fun(this, &PrettyTable::file_monitor_event));
+        monitors[path] = monitor;
+    }
+
+    this->init_gio_app_cache();
+}
+
+
+PrettyTable::~PrettyTable()
+{
+}
+
+#ifdef HAVE_WNCK
+void
+PrettyTable::on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data)
+{
+    PrettyTable * const that = static_cast<PrettyTable*>(data);
+    FILE *f;
+
+    pid_t pid = wnck_application_get_pid(app);
+
+    if (pid == 0)
+        return;
+
+    const char* icon_name = wnck_application_get_icon_name(app);
+
+
+    Glib::RefPtr<Gdk::Pixbuf> icon;
+
+    // Make sure that icon_name is a valid symlink before loading.
+    f = fopen (icon_name, "r");
+    if (f != NULL) {
+        fclose (f);
+        icon = that->theme->load_icon(icon_name, APP_ICON_SIZE);
+    }
+
+    if (not icon) {
+        icon = Glib::wrap(wnck_application_get_icon(app), /* take_copy */ true);
+        icon = icon->scale_simple(APP_ICON_SIZE, APP_ICON_SIZE, Gdk::INTERP_HYPER);
+    }
+
+    if (not icon)
+        return;
+
+    that->register_application(pid, icon);
+}
+
+void
+PrettyTable::register_application(pid_t pid, Glib::RefPtr<Gdk::Pixbuf> icon)
+{
+  /* If process already exists then set the icon. Otherwise put into hash
+  ** table to be added later */
+  if (ProcInfo* info = ProcInfo::find(pid))
+    {
+      info->set_icon(icon);
+      // move the ref to the map
+      this->apps[pid] = icon;
+      procman_debug("MATEWNCK OK for %u", unsigned(pid));
+    }
+}
+
+void
+PrettyTable::on_application_closed(WnckScreen* screen, WnckApplication* app, gpointer data)
+{
+    pid_t pid = wnck_application_get_pid(app);
+
+    if (pid == 0)
+        return;
+
+    static_cast<PrettyTable*>(data)->unregister_application(pid);
+}
+
+void
+PrettyTable::unregister_application(pid_t pid)
+{
+    IconsForPID::iterator it(this->apps.find(pid));
+
+    if (it != this->apps.end())
+        this->apps.erase(it);
+}
+#endif // HAVE_WNCK
+
+void PrettyTable::init_gio_app_cache ()
+{
+    this->gio_apps.clear();
+
+    Glib::ListHandle<Glib::RefPtr<Gio::AppInfo>> registered_apps = Gio::AppInfo::get_all();
+    for (Glib::ListHandle<Glib::RefPtr<Gio::AppInfo>>::const_iterator it = registered_apps.begin(); it != registered_apps.end(); ++it) {
+        Glib::RefPtr<Gio::AppInfo> app = *it;
+        std::string executable = app->get_executable();
+        if (executable != "sh" && executable != "env")
+            this->gio_apps[executable] = app;
+    }
+}
+
+void PrettyTable::file_monitor_event(Glib::RefPtr<Gio::File>,
+                                     Glib::RefPtr<Gio::File>,
+                                     Gio::FileMonitorEvent)
+{
+  this->init_gio_app_cache();
+}
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_theme(const ProcInfo &info)
+{
+    return this->theme->load_icon(info.name, APP_ICON_SIZE);
+}
+
+
+bool PrettyTable::get_default_icon_name(const string &cmd, string &name)
+{
+    for (size_t i = 0; i != G_N_ELEMENTS(default_table); ++i) {
+        if (default_table[i].command->match(cmd)) {
+            name = default_table[i].icon;
+            return true;
+        }
+    }
+
+    return false;
+}
+
+/*
+  Try to get an icon from the default_table
+  If it's not in defaults, try to load it.
+  If there is no default for a command, store NULL in defaults
+  so we don't have to lookup again.
+*/
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_default(const ProcInfo &info)
+{
+    Glib::RefPtr<Gdk::Pixbuf> pix;
+    string name;
+
+    if (this->get_default_icon_name(info.name, name)) {
+        IconCache::iterator it(this->defaults.find(name));
+
+        if (it == this->defaults.end()) {
+            pix = this->theme->load_icon(name, APP_ICON_SIZE);
+            if (pix)
+                this->defaults[name] = pix;
+            } else
+                pix = it->second;
+    }
+
+    return pix;
+}
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_gio(const ProcInfo &info)
+{
+    gchar **cmdline = g_strsplit(info.name, " ", 2);
+    const gchar *executable = cmdline[0];
+    Glib::RefPtr<Gdk::Pixbuf> icon;
+
+    if (executable) {
+        Glib::RefPtr<Gio::AppInfo> app = this->gio_apps[executable];
+        Glib::RefPtr<Gio::Icon> gicon;
+
+        if (app)
+          gicon = app->get_icon();
+
+        if (gicon)
+          icon = this->theme->load_gicon(gicon, APP_ICON_SIZE, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
+    }
+
+    g_strfreev(cmdline);
+    return icon;
+}
+
+#ifdef HAVE_WNCK
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_wnck(const ProcInfo &info)
+{
+    Glib::RefPtr<Gdk::Pixbuf> icon;
+
+    IconsForPID::iterator it(this->apps.find(info.pid));
+
+    if (it != this->apps.end())
+        icon = it->second;
+
+    return icon;
+}
+#endif
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_name(const ProcInfo &info)
+{
+    return this->theme->load_icon(info.name, APP_ICON_SIZE);
+}
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_dummy(const ProcInfo &)
+{
+    return this->theme->load_icon("application-x-executable", APP_ICON_SIZE);
+}
+
+
+namespace
+{
+    bool has_kthreadd()
+    {
+        glibtop_proc_state buf;
+        glibtop_get_proc_state(&buf, 2);
+
+        return buf.cmd == string("kthreadd");
+    }
+
+    // @pre: has_kthreadd
+    bool is_kthread(const ProcInfo &info)
+    {
+        return info.pid == 2 or info.ppid == 2;
+    }
+}
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_for_kernel(const ProcInfo &info)
+{
+    if (is_kthread(info))
+        return this->theme->load_icon("applications-system", APP_ICON_SIZE);
+
+    return Glib::RefPtr<Gdk::Pixbuf>();
+}
+
+
+
+void
+PrettyTable::set_icon(ProcInfo &info)
+{
+    typedef Glib::RefPtr<Gdk::Pixbuf>
+        (PrettyTable::*Getter)(const ProcInfo &);
+
+    static std::vector<Getter> getters;
+
+    if (getters.empty())
+    {
+        getters.push_back(&PrettyTable::get_icon_from_gio);
+#ifdef HAVE_WNCK
+        getters.push_back(&PrettyTable::get_icon_from_wnck);
+#endif
+        getters.push_back(&PrettyTable::get_icon_from_theme);
+        getters.push_back(&PrettyTable::get_icon_from_default);
+        getters.push_back(&PrettyTable::get_icon_from_name);
+        if (has_kthreadd())
+        {
+            procman_debug("kthreadd is running with PID 2");
+            getters.push_back(&PrettyTable::get_icon_for_kernel);
+        }
+        getters.push_back(&PrettyTable::get_icon_dummy);
+    }
+
+    Glib::RefPtr<Gdk::Pixbuf> icon;
+
+    for (size_t i = 0; not icon and i < getters.size(); ++i) {
+        try {
+            icon = (this->*getters[i])(info);
+        }
+        catch (std::exception& e) {
+            g_warning("Failed to load icon for %s(%u) : %s", info.name, info.pid, e.what());
+            continue;
+        }
+        catch (Glib::Exception& e) {
+            g_warning("Failed to load icon for %s(%u) : %s", info.name, info.pid, e.what().c_str());
+            continue;
+        }
+    }
+
+    info.set_icon(icon);
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/31.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/31.html new file mode 100644 index 00000000..d8618dcb --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/31.html @@ -0,0 +1,331 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
#ifndef _PROCMAN_DEFAULTTABLE_H_
+#define _PROCMAN_DEFAULTTABLE_H_
+
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/refptr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/regex.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+/* This file contains prettynames and icons for well-known applications, that by default has no .desktop entry */
+
+struct PrettyTableItem
+{
+    Glib::RefPtr<Glib::Regex> command;
+    std::string icon;
+
+PrettyTableItem(const std::string& a_command, const std::string& a_icon)
+: command(Glib::Regex::create("^(" + a_command + ")$")),
+        icon(a_icon)
+    { }
+};
+
+#define ITEM PrettyTableItem
+
+static const PrettyTableItem default_table[] = {
+    ITEM("(ba|z|tc|c|k)?sh", "utilities-terminal"),
+    ITEM("(k|sys|u)logd|logger", "internet-news-reader"),
+    ITEM("X(org)?", "display"),
+    ITEM("apache2?|httpd|lighttpd", "internet-web-browser"),
+    ITEM("atd|cron|CRON|ntpd", "date"),
+    ITEM("cupsd|lpd?", "printer"),
+    ITEM("cvsd|mtn|git|svn", "file-manager"),
+    ITEM("evolution.*", "internet-mail"),
+    ITEM("famd|gam_server", "file-manager"),
+    ITEM("getty", "input-keyboard"),
+    ITEM("gdb|((gcc|g\\+\\+)(-.*)?)|ar|ld|make", "applications-development"),
+    ITEM("marco|metacity", "gnome-window-manager"),
+    ITEM("sendmail|exim\\d?", "internet-mail"),
+    ITEM("squid", "proxy"),
+    ITEM("ssh(d|-agent)", "ssh-askpass-gnome"),
+    ITEM("top|vmstat", "system-monitor"),
+    ITEM("vim?", "vim"),
+    ITEM("x?inetd", "internet-web-browser"),
+    ITEM("vino.*", "gnome-remote-desktop")
+};
+
+#undef ITEM
+
+#endif /* _PROCMAN_DEFAULTTABLE_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/32.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/32.html new file mode 100644 index 00000000..d34b6a5f --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/32.html @@ -0,0 +1,621 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
/* Procman process actions
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/resource.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procactions.h"
+#include "procman.h"
+#include "proctable.h"
+#include "procdialogs.h"
+#include "callbacks.h"
+
+
+static void
+renice_single_process (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+    const struct ReniceArgs * const args = static_cast<ReniceArgs*>(data);
+
+    ProcInfo *info = NULL;
+    gint error;
+    int saved_errno;
+    gchar *error_msg;
+    GtkWidget *dialog;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+    if (info->nice == args->nice_value)
+        return;
+    error = setpriority (PRIO_PROCESS, info->pid, args->nice_value);
+
+    /* success */
+    if(error != -1) return;
+
+    saved_errno = errno;
+
+    /* need to be root */
+    if(errno == EPERM || errno == EACCES) {
+        gboolean success;
+
+        success = procdialog_create_root_password_dialog (
+            PROCMAN_ACTION_RENICE, args->procdata, info->pid,
+            args->nice_value);
+
+        if(success) return;
+
+        if(errno) {
+            saved_errno = errno;
+        }
+    }
+
+    /* failed */
+    error_msg = g_strdup_printf (
+        _("Cannot change the priority of process with PID %d to %d.\n"
+          "%s"),
+        info->pid, args->nice_value, g_strerror(saved_errno));
+
+    dialog = gtk_message_dialog_new (
+        NULL,
+        GTK_DIALOG_DESTROY_WITH_PARENT,
+        GTK_MESSAGE_ERROR,
+        GTK_BUTTONS_OK,
+        "%s", error_msg);
+
+    gtk_dialog_run (GTK_DIALOG (dialog));
+    gtk_widget_destroy (dialog);
+    g_free (error_msg);
+}
+
+
+void
+renice (ProcData *procdata, int nice)
+{
+    struct ReniceArgs args = { procdata, nice };
+
+    /* EEEK - ugly hack - make sure the table is not updated as a crash
+    ** occurs if you first kill a process and the tree node is removed while
+    ** still in the foreach function
+    */
+    g_source_remove(procdata->timeout);
+
+    gtk_tree_selection_selected_foreach(procdata->selection, renice_single_process,
+                                        &args);
+
+    procdata->timeout = g_timeout_add(procdata->config.update_interval,
+                                      cb_timeout,
+                                      procdata);
+
+    proctable_update (procdata);
+}
+
+
+
+
+static void
+kill_single_process (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+    const struct KillArgs * const args = static_cast<KillArgs*>(data);
+    char *error_msg;
+    ProcInfo *info;
+    int error;
+    int saved_errno;
+    GtkWidget *dialog;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    error = kill (info->pid, args->signal);
+
+    /* success */
+    if(error != -1) return;
+
+    saved_errno = errno;
+
+    /* need to be root */
+    if(errno == EPERM) {
+        gboolean success;
+
+        success = procdialog_create_root_password_dialog (
+            PROCMAN_ACTION_KILL, args->procdata, info->pid,
+            args->signal);
+
+        if(success) return;
+
+        if(errno) {
+            saved_errno = errno;
+        }
+    }
+
+    /* failed */
+    error_msg = g_strdup_printf (
+        _("Cannot kill process with PID %d with signal %d.\n"
+          "%s"),
+        info->pid, args->signal, g_strerror(saved_errno));
+
+    dialog = gtk_message_dialog_new (
+        NULL,
+        GTK_DIALOG_DESTROY_WITH_PARENT,
+        GTK_MESSAGE_ERROR,
+        GTK_BUTTONS_OK,
+        "%s", error_msg);
+
+    gtk_dialog_run (GTK_DIALOG (dialog));
+    gtk_widget_destroy (dialog);
+    g_free (error_msg);
+}
+
+
+void
+kill_process (ProcData *procdata, int sig)
+{
+    struct KillArgs args = { procdata, sig };
+
+    /* EEEK - ugly hack - make sure the table is not updated as a crash
+    ** occurs if you first kill a process and the tree node is removed while
+    ** still in the foreach function
+    */
+    g_source_remove (procdata->timeout);
+
+    gtk_tree_selection_selected_foreach (procdata->selection, kill_single_process,
+                                         &args);
+
+    procdata->timeout = g_timeout_add (procdata->config.update_interval,
+                                       cb_timeout,
+                                       procdata);
+    proctable_update (procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/33.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/33.html new file mode 100644 index 00000000..41c754fc --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/33.html @@ -0,0 +1,1417 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
/* Procman - dialogs
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procdialogs.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "procactions.h"
+#include "util.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "procman_gksu.h"
+#include "procman_pkexec.h"
+#include "cgroups.h"
+
+#define GET_WIDGET(x) GTK_WIDGET(gtk_builder_get_object(builder, x))
+
+static GtkWidget *renice_dialog = NULL;
+static GtkWidget *prefs_dialog = NULL;
+static gint new_nice_value = 0;
+
+
+static void
+kill_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    struct KillArgs *kargs = static_cast<KillArgs*>(data);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    if (id == GTK_RESPONSE_OK)
+        kill_process (kargs->procdata, kargs->signal);
+
+    g_free (kargs);
+}
+
+void
+procdialog_create_kill_dialog (ProcData *procdata, int signal)
+{
+    GtkWidget *kill_alert_dialog;
+    gchar *primary, *secondary, *button_text;
+    struct KillArgs *kargs;
+
+    kargs = g_new(KillArgs, 1);
+    kargs->procdata = procdata;
+    kargs->signal = signal;
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if ( selected_count == 1 ) {
+        ProcInfo *selected_process = NULL;
+        // get the last selected row
+        gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &selected_process);
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing single process*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        } else {
+            /*xgettext: primary alert message for ending single process*/
+            primary = g_strdup_printf (_("Are you sure you want to end the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        }
+    } else {
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the %d selected processes?"),
+                                       selected_count);
+        } else {
+            /*xgettext: primary alert message for ending multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to end the %d selected processes?"),
+                                       selected_count);
+
+        }
+    }
+
+    if ( signal == SIGKILL ) {
+        /*xgettext: secondary alert message*/
+        secondary = _("Killing a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be killed.");
+        button_text = ngettext("_Kill Process", "_Kill Processes", selected_count);
+    } else {
+        /*xgettext: secondary alert message*/
+        secondary = _("Ending a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be ended.");
+        button_text = ngettext("_End Process", "_End Processes", selected_count);
+    }
+
+    kill_alert_dialog = gtk_message_dialog_new (GTK_WINDOW (procdata->app),
+                                                static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
+                                                GTK_MESSAGE_WARNING,
+                                                GTK_BUTTONS_NONE,
+                                                "%s",
+                                                primary);
+    g_free (primary);
+
+    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (kill_alert_dialog),
+                                              "%s",
+                                              secondary);
+
+    gtk_dialog_add_buttons (GTK_DIALOG (kill_alert_dialog),
+                            "gtk-cancel", GTK_RESPONSE_CANCEL,
+                            button_text, GTK_RESPONSE_OK,
+                            NULL);
+
+    gtk_dialog_set_default_response (GTK_DIALOG (kill_alert_dialog),
+                                     GTK_RESPONSE_CANCEL);
+
+    g_signal_connect (G_OBJECT (kill_alert_dialog), "response",
+                      G_CALLBACK (kill_dialog_button_pressed), kargs);
+
+    gtk_widget_show_all (kill_alert_dialog);
+}
+
+static void
+renice_scale_changed (GtkAdjustment *adj, gpointer data)
+{
+    GtkWidget *label = GTK_WIDGET (data);
+
+    new_nice_value = int(gtk_adjustment_get_value (adj));
+    gchar* text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (new_nice_value));
+    gtk_label_set_text (GTK_LABEL (label), text);
+    g_free(text);
+
+}
+
+static void
+renice_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (id == 100) {
+        if (new_nice_value == -100)
+            return;
+        renice(procdata, new_nice_value);
+    }
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+    renice_dialog = NULL;
+}
+
+void
+procdialog_create_renice_dialog (ProcData *procdata)
+{
+    ProcInfo  *info;
+    GtkWidget *dialog = NULL;
+    GtkWidget *dialog_vbox;
+    GtkWidget *vbox;
+    GtkWidget *label;
+    GtkWidget *priority_label;
+    GtkWidget *grid;
+    GtkAdjustment *renice_adj;
+    GtkWidget *hscale;
+    GtkWidget *button;
+    GtkWidget *icon;
+    gchar     *text;
+    gchar     *dialog_title;
+
+    if (renice_dialog)
+        return;
+
+    gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &info);
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if (!info)
+        return;
+
+    if ( selected_count == 1 ) {
+        dialog_title = g_strdup_printf (_("Change Priority of Process “%s†(PID: %u)"),
+                                        info->name, info->pid);
+    } else {
+        dialog_title = g_strdup_printf (_("Change Priority of %d Selected Processes"),
+                                        selected_count);
+    }
+
+    dialog = gtk_dialog_new_with_buttons (dialog_title, NULL,
+                                          GTK_DIALOG_DESTROY_WITH_PARENT,
+                                          "gtk-cancel", GTK_RESPONSE_CANCEL,
+                                          NULL);
+    g_free (dialog_title);
+
+    renice_dialog = dialog;
+    gtk_window_set_resizable (GTK_WINDOW (renice_dialog), FALSE);
+    gtk_container_set_border_width (GTK_CONTAINER (renice_dialog), 5);
+
+    button = gtk_button_new_with_mnemonic (_("Change _Priority"));
+    gtk_widget_set_can_default (button, TRUE);
+
+    icon = gtk_image_new_from_icon_name ("gtk-apply", GTK_ICON_SIZE_BUTTON);
+    gtk_button_set_image (GTK_BUTTON (button), icon);
+
+    gtk_dialog_add_action_widget (GTK_DIALOG (renice_dialog), button, 100);
+    gtk_dialog_set_default_response (GTK_DIALOG (renice_dialog), 100);
+    new_nice_value = -100;
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+    gtk_box_set_spacing (GTK_BOX (dialog_vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), vbox, TRUE, TRUE, 0);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+
+    grid = gtk_grid_new ();
+    gtk_grid_set_column_spacing (GTK_GRID(grid), 12);
+    gtk_grid_set_row_spacing (GTK_GRID(grid), 6);
+    gtk_box_pack_start (GTK_BOX (vbox), grid, TRUE, TRUE, 0);
+
+    label = gtk_label_new_with_mnemonic (_("_Nice value:"));
+    gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 2);
+
+    renice_adj = gtk_adjustment_new (info->nice, RENICE_VAL_MIN, RENICE_VAL_MAX, 1, 1, 0);
+    new_nice_value = 0;
+    hscale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, renice_adj);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), hscale);
+    gtk_scale_set_digits (GTK_SCALE (hscale), 0);
+    gtk_widget_set_hexpand (hscale, TRUE);
+    gtk_grid_attach (GTK_GRID (grid), hscale, 1, 0, 1, 1);
+    text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (info->nice));
+    priority_label = gtk_label_new (text);
+    gtk_grid_attach (GTK_GRID (grid), priority_label, 1, 1, 1, 1);
+    g_free(text);
+
+    text = g_strconcat("<small><i><b>", _("Note:"), "</b> ",
+        _("The priority of a process is given by its nice value. A lower nice value corresponds to a higher priority."),
+        "</i></small>", NULL);
+    label = gtk_label_new (_(text));
+    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+    g_free (text);
+
+    g_signal_connect (G_OBJECT (dialog), "response",
+                      G_CALLBACK (renice_dialog_button_pressed), procdata);
+    g_signal_connect (G_OBJECT (renice_adj), "value_changed",
+                      G_CALLBACK (renice_scale_changed), priority_label);
+
+    gtk_widget_show_all (dialog);
+
+
+}
+
+static void
+prefs_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    if (id == GTK_RESPONSE_HELP)
+    {
+        GError* error = 0;
+        if (!g_app_info_launch_default_for_uri("help:mate-system-monitor/mate-system-monitor-prefs", NULL, &error))
+        {
+            g_warning("Could not display preferences help : %s", error->message);
+            g_error_free(error);
+        }
+    }
+    else
+    {
+        gtk_widget_destroy (GTK_WIDGET (dialog));
+        prefs_dialog = NULL;
+    }
+}
+
+
+class SpinButtonUpdater
+{
+public:
+    SpinButtonUpdater(const string& key)
+        : key(key)
+    { }
+
+    static gboolean callback(GtkWidget *widget, GdkEventFocus *event, gpointer data)
+    {
+        SpinButtonUpdater* updater = static_cast<SpinButtonUpdater*>(data);
+        gtk_spin_button_update(GTK_SPIN_BUTTON(widget));
+        updater->update(GTK_SPIN_BUTTON(widget));
+        return FALSE;
+    }
+
+private:
+
+    void update(GtkSpinButton* spin)
+    {
+        int new_value = int(1000 * gtk_spin_button_get_value(spin));
+        g_settings_set_int(ProcData::get_instance()->settings,
+                           this->key.c_str(), new_value);
+
+        procman_debug("set %s to %d", this->key.c_str(), new_value);
+    }
+
+    const string key;
+};
+
+
+static void
+field_toggled (const gchar *child_schema, GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+    GtkTreeIter iter;
+    GtkTreeViewColumn *column;
+    gboolean toggled;
+    GSettings *settings = g_settings_get_child (ProcData::get_instance()->settings, child_schema);
+    gchar *key;
+    int id;
+
+    if (!path)
+        return;
+
+    gtk_tree_model_get_iter (model, &iter, path);
+
+    gtk_tree_model_get (model, &iter, 2, &column, -1);
+    toggled = gtk_cell_renderer_toggle_get_active (cell);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, !toggled, -1);
+    gtk_tree_view_column_set_visible (column, !toggled);
+
+    id = gtk_tree_view_column_get_sort_column_id (column);
+
+    key = g_strdup_printf ("col-%d-visible", id);
+    g_settings_set_boolean (settings, key, !toggled);
+    g_free (key);
+
+    gtk_tree_path_free (path);
+}
+
+static void
+proc_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("proctree", cell, path_str, data);
+}
+
+static void
+disk_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("disktreenew", cell, path_str, data);
+}
+
+static void
+create_field_page(GtkBuilder* builder, GtkWidget *tree, const gchar *widgetname)
+{
+    GtkTreeView *treeview;
+    GList *it, *columns;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;<--- Shadowed declaration
+    GtkCellRenderer *cell;
+    gchar *full_widgetname;
+
+    full_widgetname = g_strdup_printf ("%s_columns", widgetname);
+    treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, full_widgetname));
+    g_free (full_widgetname);
+
+    model = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER);
+
+    gtk_tree_view_set_model (GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(model));
+    g_object_unref (G_OBJECT (model));
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_toggle_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "active", 0,
+                                         NULL);
+
+    if (g_strcmp0 (widgetname, "proctree") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (proc_field_toggled), model);
+    else if (g_strcmp0 (widgetname, "disktreenew") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (disk_field_toggled), model);
+
+    gtk_tree_view_column_set_clickable (column, TRUE);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "text", 1,
+                                         NULL);
+
+    gtk_tree_view_column_set_title (column, "Not Shown");
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    for(it = columns; it; it = it->next)
+    {
+        GtkTreeViewColumn *column = static_cast<GtkTreeViewColumn*>(it->data);<--- Shadow variable
+        GtkTreeIter iter;
+        const gchar *title;
+        gboolean visible;
+        gint column_id;
+
+        title = gtk_tree_view_column_get_title (column);
+        if (!title)
+            title = _("Icon");
+
+        column_id = gtk_tree_view_column_get_sort_column_id(column);
+        if ((column_id == COL_CGROUP) && (!cgroups_enabled()))
+            continue;
+
+        if ((column_id == COL_UNIT ||
+             column_id == COL_SESSION ||
+             column_id == COL_SEAT ||
+             column_id == COL_OWNER)
+#ifdef HAVE_SYSTEMD
+            && !LOGIND_RUNNING()
+#endif
+                )
+            continue;
+
+        visible = gtk_tree_view_column_get_visible (column);
+
+        gtk_list_store_append (model, &iter);
+        gtk_list_store_set (model, &iter, 0, visible, 1, title, 2, column,-1);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procdialog_create_preferences_dialog (ProcData *procdata)
+{
+    typedef SpinButtonUpdater SBU;
+
+    static SBU interval_updater("update-interval");
+    static SBU graph_interval_updater("graph-update-interval");
+    static SBU disks_interval_updater("disks-interval");
+
+    GtkWidget *notebook;
+    GtkAdjustment *adjustment;
+    GtkWidget *spin_button;
+    GtkWidget *check_button;
+    GtkWidget *smooth_button;
+    GtkBuilder *builder;
+    gfloat update;
+
+    if (prefs_dialog)
+        return;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/preferences.ui");
+
+    prefs_dialog = GET_WIDGET("preferences_dialog");
+    notebook = GET_WIDGET("notebook");
+    spin_button = GET_WIDGET("processes_interval_spinner");
+
+    update = (gfloat) procdata->config.update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0,
+                                   MIN_UPDATE_INTERVAL / 1000,
+                                   MAX_UPDATE_INTERVAL / 1000,
+                                   0.25,
+                                   1.0,
+                                   0);
+
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK (SBU::callback), &interval_updater);
+
+    smooth_button = GET_WIDGET("smooth_button");
+    g_settings_bind(procdata->settings, SmoothRefresh::KEY.c_str(), smooth_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    check_button = GET_WIDGET("check_button");
+    g_settings_bind(procdata->settings, "kill-dialog", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    GtkWidget *solaris_button = GET_WIDGET("solaris_button");
+    g_settings_bind(procdata->settings, procman::settings::solaris_mode.c_str(), solaris_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->tree, "proctree");
+
+    update = (gfloat) procdata->config.graph_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0, 0.25,
+                                                      100.0, 0.25, 1.0, 0);
+
+    spin_button = GET_WIDGET("resources_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &graph_interval_updater);
+
+    GtkWidget *bits_button = GET_WIDGET("bits_button");
+    g_settings_bind(procdata->settings, procman::settings::network_in_bits.c_str(), bits_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+
+    update = (gfloat) procdata->config.disks_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new (update / 1000.0, 1.0,
+                                                       100.0, 1.0, 1.0, 0);
+
+    spin_button = GET_WIDGET("devices_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &disks_interval_updater);
+
+    check_button = GET_WIDGET("all_devices_check");
+    g_settings_bind(procdata->settings, "show-all-fs", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->disk_list, "disktreenew");
+
+    gtk_widget_show_all (prefs_dialog);
+    g_signal_connect (G_OBJECT (prefs_dialog), "response",
+                       G_CALLBACK (prefs_dialog_button_pressed), procdata);
+
+    switch (procdata->config.current_tab) {
+    case PROCMAN_TAB_SYSINFO:
+    case PROCMAN_TAB_PROCESSES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
+        break;
+    case PROCMAN_TAB_RESOURCES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 1);
+        break;
+    case PROCMAN_TAB_DISKS:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 2);
+        break;
+    }
+
+    gtk_builder_connect_signals (builder, NULL);
+    g_object_unref (G_OBJECT (builder));
+}
+
+
+static char *
+procman_action_to_command(ProcmanActionType type,
+                          gint pid,
+                          gint extra_value)
+{
+    switch (type) {
+    case PROCMAN_ACTION_KILL:
+           return g_strdup_printf("kill -s %d %d", extra_value, pid);
+    case PROCMAN_ACTION_RENICE:
+        return g_strdup_printf("renice %d %d", extra_value, pid);
+    default:
+        g_assert_not_reached();
+    }
+}
+
+
+/*
+ * type determines whether if dialog is for killing process or renice.
+ * type == PROCMAN_ACTION_KILL,   extra_value -> signal to send
+ * type == PROCMAN_ACTION_RENICE, extra_value -> new priority.
+ */
+gboolean
+procdialog_create_root_password_dialog(ProcmanActionType type,
+                                       ProcData *procdata,
+                                       gint pid,
+                                       gint extra_value)
+{
+    char * command;
+    gboolean ret = FALSE;
+
+    command = procman_action_to_command(type, pid, extra_value);
+
+    procman_debug("Trying to run '%s' as root", command);
+
+    if (procman_has_pkexec())
+        ret = procman_pkexec_create_root_password_dialog(command);
+    else if (procman_has_gksu())
+        ret = procman_gksu_create_root_password_dialog(command);
+
+    g_free(command);
+    return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/34.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/34.html new file mode 100644 index 00000000..b9fac436 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/34.html @@ -0,0 +1,261 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
#ifndef H_MATE_SYSTEM_MONITOR_GKSU_H_1132171928
+#define H_MATE_SYSTEM_MONITOR_GKSU_H_1132171928
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+gboolean
+procman_gksu_create_root_password_dialog(const char * command);
+
+gboolean
+procman_has_gksu(void) G_GNUC_CONST;
+
+#endif /* H_MATE_SYSTEM_MONITOR_GKSU_H_1132171928 */
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/35.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/35.html new file mode 100644 index 00000000..a61896ec --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/35.html @@ -0,0 +1,261 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
#ifndef _PROCMAN_PKEXEC_H_
+#define _PROCMAN_PKEXEC_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+gboolean
+procman_pkexec_create_root_password_dialog(const char *command);
+
+gboolean
+procman_has_pkexec(void) G_GNUC_CONST;
+
+#endif /* _PROCMAN_PKEXEC_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/36.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/36.html new file mode 100644 index 00000000..f3d2b88d --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/36.html @@ -0,0 +1,1109 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/close.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/sysinfo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman-app.h"
+#include "procman.h"
+#include "interface.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "argv.h"
+#include "util.h"
+
+static void
+mount_changed(const Glib::RefPtr<Gio::Mount>&)
+{
+    cb_update_disks(ProcData::get_instance());
+}
+
+
+static void
+init_volume_monitor(ProcData *procdata)
+{
+    using namespace Gio;
+    using namespace Glib;
+
+    RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+    monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
+}
+
+static gboolean
+has_key (gchar **keys, const gchar *key)
+{
+    gchar **loop = keys;
+
+    while (*loop) {
+        if (!strcmp (*loop++, key))
+            return TRUE;
+    }
+
+    return FALSE;
+}
+
+static void
+tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_tree = g_settings_get_boolean(settings, key);
+
+    g_object_set(G_OBJECT(procdata->tree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
+    proctable_update (procdata);
+}
+
+
+static void
+network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
+    // force scale to be redrawn
+    procdata->net_graph->clear_background();
+}
+
+static void
+view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.whose_process = g_settings_get_int (settings, key);
+    procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2);
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "kill-dialog")) {
+        procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
+    }
+}
+
+static void
+timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "update-interval")) {
+        procdata->config.update_interval = g_settings_get_int (settings, key);
+        procdata->config.update_interval =
+            MAX (procdata->config.update_interval, 1000);
+
+        procdata->smooth_refresh->reset();
+
+        if(procdata->timeout) {
+            g_source_remove (procdata->timeout);
+            procdata->timeout = g_timeout_add (procdata->config.update_interval,
+                                               cb_timeout,
+                                               procdata);
+        }
+    }
+    else if (g_str_equal (key, "graph-update-interval")){
+        procdata->config.graph_update_interval = g_settings_get_int (settings, key);
+        procdata->config.graph_update_interval =
+            MAX (procdata->config.graph_update_interval,
+                 250);
+        load_graph_change_speed(procdata->cpu_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->mem_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->net_graph,
+                                procdata->config.graph_update_interval);
+    }
+    else if (g_str_equal(key, "disks-interval")) {
+        procdata->config.disks_update_interval = g_settings_get_int (settings, key);
+        procdata->config.disks_update_interval =
+            MAX (procdata->config.disks_update_interval, 1000);
+
+        if(procdata->disk_timeout) {
+            g_source_remove (procdata->disk_timeout);
+            procdata->disk_timeout = \
+                g_timeout_add (procdata->config.disks_update_interval,
+                               cb_update_disks,
+                               procdata);
+        }
+    }
+    else {
+        g_assert_not_reached();
+    }
+}
+
+static void
+color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    gchar *color = g_settings_get_string (settings, key);
+
+    if (g_str_has_prefix (key, "cpu-color")) {
+        for (int i = 0; i < procdata->config.num_cpus; i++) {
+            string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
+            if (cpu_key == key) {
+                gdk_rgba_parse (&procdata->config.cpu_color[i], color);
+                procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
+                break;
+            }
+        }
+    }
+    else if (g_str_equal (key, "mem-color")) {
+        gdk_rgba_parse (&procdata->config.mem_color, color);
+        procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
+    }
+    else if (g_str_equal (key, "swap-color")) {
+        gdk_rgba_parse (&procdata->config.swap_color, color);
+        procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
+    }
+    else if (g_str_equal (key, "net-in-color")) {
+        gdk_rgba_parse (&procdata->config.net_in_color, color);
+        procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
+    }
+    else if (g_str_equal (key, "net-out-color")) {
+        gdk_rgba_parse (&procdata->config.net_out_color, color);
+        procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
+    }
+    else {
+        g_assert_not_reached();
+    }
+    g_free(color);
+}
+
+static void
+show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
+
+    cb_update_disks (data);
+}
+
+static ProcData *
+procman_data_new (GSettings *settings)
+{
+    GSettingsSchema *schema;
+    ProcData *pd;
+    gchar *color;
+    gchar **keys;
+    glibtop_cpu cpu;
+
+    pd = ProcData::get_instance();
+
+    g_settings_get (settings, "window-state", "(iiii)",
+                    &pd->config.width, &pd->config.height,
+                    &pd->config.xpos, &pd->config.ypos);
+
+    pd->config.maximized = g_settings_get_boolean(settings, "maximized");
+
+    pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
+    g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd);
+
+    pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
+    std::string detail_string("changed::" + procman::settings::solaris_mode);
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd);
+
+    pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
+    detail_string = "changed::" + procman::settings::network_in_bits;
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd);
+
+    pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
+    g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd);
+    pd->config.update_interval = g_settings_get_int (settings, "update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.graph_update_interval = g_settings_get_int (settings,
+                                                           "graph-update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",
+                      G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd);
+
+
+    /* show_all_fs */
+    pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
+    g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd);
+
+
+    pd->config.whose_process = g_settings_get_int (settings, "view-as");
+    g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd);
+    pd->config.current_tab = g_settings_get_int (settings, "current-tab");
+
+    glibtop_get_cpu (&cpu);
+    pd->frequency = cpu.frequency;
+    pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
+
+    g_object_get (settings, "settings-schema", &schema, NULL);
+    keys = g_settings_schema_list_keys (schema);
+    g_settings_schema_unref (schema);
+
+    for (int i = 0; i < pd->config.num_cpus; i++) {
+        gchar *key;
+        key = g_strdup_printf ("cpu-color%d", i);
+
+        if (has_key (keys, key))
+            color = g_settings_get_string (settings, key);
+        else
+            color = g_strdup ("#f25915e815e8");
+        detail_string = std::string("changed::") + std::string(key);
+        g_signal_connect (G_OBJECT(settings), detail_string.c_str(),
+                          G_CALLBACK(color_changed_cb), pd);
+        gdk_rgba_parse (&pd->config.cpu_color[i], color);
+        g_free (color);
+        g_free (key);
+    }
+    g_strfreev (keys);
+
+    color = g_settings_get_string (settings, "mem-color");
+    if (!color)
+        color = g_strdup ("#000000ff0082");
+    g_signal_connect (G_OBJECT(settings), "changed::mem-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.mem_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "swap-color");
+    if (!color)
+        color = g_strdup ("#00b6000000ff");
+    g_signal_connect (G_OBJECT(settings), "changed::swap-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.swap_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-in-color");
+    if (!color)
+        color = g_strdup ("#000000f200f2");
+    g_signal_connect (G_OBJECT(settings), "changed::net-in-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_in_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-out-color");
+    if (!color)
+        color = g_strdup ("#00f2000000c1");
+    g_signal_connect (G_OBJECT(settings), "changed::net-out-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_out_color, color);
+    g_free (color);
+
+    /* Sanity checks */
+    GdkDisplay *display;
+    GdkMonitor *monitor;
+    GdkRectangle monitor_geometry;
+
+    display = gdk_display_get_default ();
+    monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
+    if (monitor == NULL) {
+        monitor = gdk_display_get_monitor (display, 0);
+    }
+    gdk_monitor_get_geometry (monitor, &monitor_geometry);
+
+    pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width);
+    pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height);
+    pd->config.update_interval = MAX (pd->config.update_interval, 1000);
+    pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250);
+    pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000);
+    pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2);
+    pd->config.current_tab = CLAMP(pd->config.current_tab,
+                                   PROCMAN_TAB_SYSINFO,
+                                   PROCMAN_TAB_DISKS);
+
+    // delayed initialization as SmoothRefresh() needs ProcData
+    // i.e. we can't call ProcData::get_instance
+    pd->smooth_refresh = new SmoothRefresh(settings);
+
+    pd->terminating = FALSE;
+
+    return pd;
+}
+
+static void
+procman_free_data (ProcData *procdata)
+{
+
+    proctable_free_table (procdata);
+    delete procdata->smooth_refresh;
+}
+
+ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
+{
+    Glib::set_application_name(_("System Monitor"));
+}
+
+Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
+{
+    return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
+}
+
+void ProcmanApp::on_activate()
+{
+    gtk_window_present (GTK_WINDOW (procdata->app));
+}
+
+static void
+set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
+{
+    gtk_notebook_set_current_page(notebook, tab);
+    cb_change_current_page(notebook, tab, procdata);
+}
+
+int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
+{
+    int argc = 0;
+    char** argv = command_line->get_arguments(argc);
+
+    Glib::OptionContext context;
+    context.set_summary(_("A simple process and system monitor."));
+    context.set_ignore_unknown_options(true);
+    procman::OptionGroup option_group;
+    context.set_main_group(option_group);
+
+    try {
+        context.parse(argc, argv);
+    } catch (const Glib::Error& ex) {
+        g_error("Arguments parse error : %s", ex.what().c_str());
+    }
+
+    if (option_group.show_system_tab) {
+        procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_SYSINFO, procdata);
+    } else if (option_group.show_processes_tab) {
+        procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_PROCESSES, procdata);
+    } else if (option_group.show_resources_tab) {
+        procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_RESOURCES, procdata);
+    } else if (option_group.show_file_systems_tab) {
+        procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_DISKS, procdata);
+    }
+
+    on_activate ();
+
+    return 0;
+}
+
+void ProcmanApp::on_startup()
+{
+    Gtk::Application::on_startup();
+
+    GSettings *settings;
+
+    Gtk::Window::set_default_icon_name ("utilities-system-monitor");
+
+    settings = g_settings_new (GSM_GSETTINGS_SCHEMA);
+
+    glibtop_init ();
+
+    procdata = procman_data_new (settings);
+    procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA);
+
+    create_main_window (procdata);
+    init_volume_monitor (procdata);
+
+    Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app));
+    window->show();
+    window->set_name ("mate-system-monitor");
+
+    add_window (*window);
+}
+
+void ProcmanApp::on_shutdown()
+{
+    procman_free_data(procdata);
+    glibtop_close();
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/37.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/37.html new file mode 100644 index 00000000..9a0699dc --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/37.html @@ -0,0 +1,283 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
#ifndef _PROCMAN_PROCMAN_APP_H_
+#define _PROCMAN_PROCMAN_APP_H_
+
+#include <gtkmm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+class ProcmanApp : public Gtk::Application
+{
+    ProcData *procdata;
+protected:
+    ProcmanApp();
+public:
+    static Glib::RefPtr<ProcmanApp> create ();
+protected:
+    virtual void on_activate();
+    virtual int on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line);
+    virtual void on_startup();
+    virtual void on_shutdown();
+};
+
+#endif  /* _PROCMAN_PROCMAN_APP_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/38.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/38.html new file mode 100644 index 00000000..972eeaf8 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/38.html @@ -0,0 +1,671 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtkmm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman-app.h"
+#include "procman.h"
+#include "proctable.h"
+
+ProcData::ProcData()
+    : tree(NULL),
+      cpu_graph(NULL),
+      mem_graph(NULL),
+      net_graph(NULL),
+      selected_process(NULL),
+      timeout(0),
+      disk_timeout(0),
+      cpu_total_time(1),
+      cpu_total_time_last(1)
+{ }
+
+ProcData* ProcData::get_instance()
+{
+    static ProcData instance;
+    return &instance;
+}
+
+gboolean
+procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns, *it;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    sort_col = g_settings_get_int (pt_settings, "sort-col");
+
+    order = static_cast<GtkSortType>(g_settings_get_int (pt_settings, "sort-order"));
+
+    if (sort_col != -1)
+        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
+                                              sort_col,
+                                              order);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        for (it = columns; it; it = it->next)
+        {
+            GtkTreeViewColumn *column;
+            gint width;
+            gboolean visible;
+            int id;
+            gchar *key;
+
+            column = static_cast<GtkTreeViewColumn*>(it->data);
+            id = gtk_tree_view_column_get_sort_column_id (column);
+
+            key = g_strdup_printf ("col-%d-width", id);
+            g_settings_get (pt_settings, key, "i", &width);
+            g_free (key);
+
+            key = g_strdup_printf ("col-%d-visible", id);
+            visible = g_settings_get_boolean (pt_settings, key);
+            g_free (key);
+
+            gtk_tree_view_column_set_visible (column, visible);
+            if (visible) {
+                /* ensure column is really visible */
+                width = MAX(width, 20);
+                gtk_tree_view_column_set_fixed_width(column, width);
+            }
+        }
+
+        GVariant     *value;
+        GVariantIter iter;
+        int          sortIndex;
+
+        GSList *order = NULL;<--- Shadow variable
+
+        value = g_settings_get_value(pt_settings, "columns-order");
+        g_variant_iter_init(&iter, value);
+
+        while (g_variant_iter_loop (&iter, "i", &sortIndex))
+            order = g_slist_append(order, GINT_TO_POINTER(sortIndex));
+
+        proctable_set_columns_order(GTK_TREE_VIEW(tree), order);
+
+        g_variant_unref(value);
+        g_slist_free(order);
+    }
+
+    g_object_unref(pt_settings);
+    pt_settings = NULL;
+
+    g_list_free(columns);
+
+    return TRUE;
+}
+
+void
+procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    if (ProcData::get_instance()->terminating)
+        return;
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    if (gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (model), &sort_col,
+                                              &order)) {
+        g_settings_set_int (pt_settings, "sort-col", sort_col);
+        g_settings_set_int (pt_settings, "sort-order", order);
+    }
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        GSList *order;<--- Shadow variable
+        GSList *order_node;
+        GVariantBuilder *builder;
+        GVariant *order_variant;
+
+        order = proctable_get_columns_order(GTK_TREE_VIEW(tree));
+
+        builder = g_variant_builder_new (G_VARIANT_TYPE ("ai"));
+
+        for (order_node = order; order_node; order_node = order_node->next)
+            g_variant_builder_add(builder, "i", GPOINTER_TO_INT(order_node->data));
+
+        order_variant = g_variant_new("ai", builder);
+        g_settings_set_value(pt_settings, "columns-order", order_variant);
+
+        g_slist_free(order);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procman_save_config (ProcData *data)
+{
+    GSettings *settings = data->settings;
+
+    g_assert(data);
+
+    data->config.maximized = gdk_window_get_state(gtk_widget_get_window (data->app)) & GDK_WINDOW_STATE_MAXIMIZED;
+    if (!data->config.maximized) {
+        // we only want to store/overwrite size and position info with non-maximized state info
+        data->config.width  = gdk_window_get_width (gtk_widget_get_window (data->app));
+        data->config.height = gdk_window_get_height(gtk_widget_get_window (data->app));
+
+        gtk_window_get_position(GTK_WINDOW(data->app), &data->config.xpos, &data->config.ypos);
+
+        g_settings_set (settings, "window-state", "(iiii)",
+                        data->config.width, data->config.height,
+                        data->config.xpos, data->config.ypos);
+    }
+    g_settings_set_boolean (settings, "maximized", data->config.maximized);
+
+    g_settings_set_int (settings, "current-tab", data->config.current_tab);
+}
+
+int
+main (int argc, char *argv[])
+{
+    bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+    textdomain (GETTEXT_PACKAGE);
+    setlocale (LC_ALL, "");
+
+    Glib::RefPtr<ProcmanApp> application = ProcmanApp::create();
+    return application->run (argc, argv);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/39.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/39.html new file mode 100644 index 00000000..c34d3e03 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/39.html @@ -0,0 +1,303 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "procman_gksu.h"
+
+gboolean
+procman_gksu_create_root_password_dialog (const char *command)
+{
+    gchar *command_line;
+    gboolean success;
+    GError *error = NULL;
+
+    command_line = g_strdup_printf ("gksu '%s'", command);
+    success = g_spawn_command_line_sync (command_line, NULL, NULL, NULL, &error);
+    g_free (command_line);
+
+    if (!success) {
+        g_critical ("Could not run gksu '%s' : %s\n",
+                    command, error->message);
+        g_error_free (error);
+        return FALSE;
+    }
+
+    g_debug ("gksu did fine\n");
+    return TRUE;
+}
+
+gboolean
+procman_has_gksu (void)
+{
+    return g_file_test ("/usr/bin/gksu", G_FILE_TEST_EXISTS);
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/4.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/4.html new file mode 100644 index 00000000..d7329c12 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/4.html @@ -0,0 +1,763 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef _PROCMAN_PROCMAN_H_
+#define _PROCMAN_PROCMAN_H_
+
+#include <glibmm/refptr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <cairo-gobject.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk-pixbuf/gdk-pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <map><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+struct ProcInfo;
+struct ProcData;
+struct LoadGraph;
+
+#include "smooth_refresh.h"
+#include "prettytable.h"
+
+#define GSM_GSETTINGS_SCHEMA "org.mate.system-monitor"
+
+enum
+{
+    ALL_PROCESSES,
+    MY_PROCESSES,
+    ACTIVE_PROCESSES
+};
+
+enum
+{
+    VERY_HIGH_PRIORITY,
+    HIGH_PRIORITY,
+    NORMAL_PRIORITY,
+    LOW_PRIORITY,
+    VERY_LOW_PRIORITY,
+    CUSTOM_PRIORITY
+};
+
+static const unsigned MIN_UPDATE_INTERVAL =   1 * 1000;
+static const unsigned MAX_UPDATE_INTERVAL = 100 * 1000;
+
+enum ProcmanTab
+{
+    PROCMAN_TAB_SYSINFO,
+    PROCMAN_TAB_PROCESSES,
+    PROCMAN_TAB_RESOURCES,
+    PROCMAN_TAB_DISKS
+};
+
+struct ProcConfig
+{
+    gint        width;
+    gint        height;
+    gint        xpos;
+    gint        ypos;
+    gboolean    maximized;
+    gboolean    show_kill_warning;
+    gboolean    show_tree;
+    gboolean    show_all_fs;
+    int         update_interval;
+    int         graph_update_interval;
+    int         disks_update_interval;
+    gint        whose_process;
+    gint        current_tab;
+    GdkRGBA     cpu_color[GLIBTOP_NCPU];
+    GdkRGBA     mem_color;
+    GdkRGBA     swap_color;
+    GdkRGBA     net_in_color;
+    GdkRGBA     net_out_color;
+    GdkRGBA     bg_color;
+    GdkRGBA     frame_color;
+    gint        num_cpus;
+    bool solaris_mode;
+    bool network_in_bits;
+};
+
+struct MutableProcInfo
+{
+MutableProcInfo()
+  : disk_write_bytes_current(0ULL),
+    disk_read_bytes_current(0ULL),
+    disk_write_bytes_total(0ULL),
+    disk_read_bytes_total(0ULL),
+    status(0U)
+    { }
+
+    std::string user;
+
+    gchar wchan[40];
+
+    // all these members are filled with libgtop which uses
+    // guint64 (to have fixed size data) but we don't need more
+    // than an unsigned long (even for 32bit apps on a 64bit
+    // kernel) as these data are amounts, not offsets.
+    gulong vmsize;
+    gulong memres;
+    gulong memshared;
+    gulong memwritable;
+    gulong mem;
+
+#ifdef HAVE_WNCK
+    // wnck gives an unsigned long
+    gulong memxserver;
+#endif
+
+    gulong start_time;
+    guint64 cpu_time;
+    guint64 disk_write_bytes_current;
+    guint64 disk_read_bytes_current;
+    guint64 disk_write_bytes_total;
+    guint64 disk_read_bytes_total;
+    guint status;
+    guint pcpu;
+    gint nice;
+    gchar *cgroup_name;
+
+    gchar *unit;
+    gchar *session;
+    gchar *seat;
+
+    std::string owner;
+};
+
+class ProcInfo
+: public MutableProcInfo
+{
+    /* undefined */ ProcInfo& operator=(const ProcInfo&);
+    /* undefined */ ProcInfo(const ProcInfo&);
+
+    typedef std::map<guint, std::string> UserMap;
+    /* cached username */
+    static UserMap users;
+
+  public:
+
+    // TODO: use a set instead
+    // sorted by pid. The map has a nice property : it is sorted
+    // by pid so this helps a lot when looking for the parent node
+    // as ppid is nearly always < pid.
+    typedef std::map<pid_t, ProcInfo*> List;
+    typedef List::iterator Iterator;
+
+    static List all;
+
+    static ProcInfo* find(pid_t pid);
+    static Iterator begin() { return ProcInfo::all.begin(); }
+    static Iterator end() { return ProcInfo::all.end(); }
+
+    ProcInfo(pid_t pid);
+    ~ProcInfo();
+    // adds one more ref to icon
+    void set_icon(Glib::RefPtr<Gdk::Pixbuf> icon);
+    void set_user(guint uid);
+    std::string lookup_user(guint uid);
+
+    GtkTreeIter      node;
+    cairo_surface_t *surface;
+    gchar           *tooltip;
+    gchar           *name;
+    gchar           *arguments;
+    gchar           *security_context;
+
+    const pid_t      pid;
+    pid_t            ppid;
+    guint            uid;
+
+// private:
+    // tracks cpu time per process keeps growing because if a
+    // ProcInfo is deleted this does not mean that the process is
+    // not going to be recreated on the next update.  For example,
+    // if dependencies + (My or Active), the proclist is cleared
+    // on each update.  This is a workaround
+    static std::map<pid_t, guint64> cpu_times;
+};
+
+struct ProcData
+{
+    // lazy initialization
+    static ProcData* get_instance();
+
+    GtkUIManager    *uimanager;
+    GtkActionGroup    *action_group;
+    GtkWidget    *statusbar;
+    gint        tip_message_cid;
+    GtkWidget    *tree;
+    GtkWidget    *loadavg;
+    GtkWidget    *endprocessbutton;
+    GtkWidget    *popup_menu;
+    GtkWidget    *disk_list;
+    GtkWidget    *notebook;
+    ProcConfig    config;
+    LoadGraph    *cpu_graph;
+    LoadGraph    *mem_graph;
+    LoadGraph    *net_graph;
+    gint        cpu_label_fixed_width;
+    gint        net_label_fixed_width;
+    ProcInfo    *selected_process;
+    GtkTreeSelection *selection;
+    guint        timeout;
+    guint        disk_timeout;
+
+    PrettyTable    pretty_table;
+
+    GSettings       *settings;
+    GtkWidget        *app;
+    GtkUIManager    *menu;
+
+    unsigned    frequency;
+
+    SmoothRefresh  *smooth_refresh;
+
+    guint64 cpu_total_time;
+    guint64 cpu_total_time_last;
+
+    gboolean terminating;
+
+private:
+    ProcData();
+    /* undefined */ ProcData(const ProcData &);
+    /* undefined */ ProcData& operator=(const ProcData &);
+};
+
+void        procman_save_config (ProcData *data);
+void        procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+gboolean    procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+
+struct ReniceArgs
+{
+    ProcData *procdata;
+    int nice_value;
+};
+
+struct KillArgs
+{
+    ProcData *procdata;
+    int signal;
+};
+
+#endif /* _PROCMAN_PROCMAN_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/40.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/40.html new file mode 100644 index 00000000..59cb183e --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/40.html @@ -0,0 +1,303 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman_pkexec.h"
+
+gboolean
+procman_pkexec_create_root_password_dialog (const char *command)
+{
+    gchar *command_line;
+    gboolean success;
+    GError *error = NULL;
+
+    command_line = g_strdup_printf ("pkexec --disable-internal-agent %s/msm-%s",
+                                    PKGLIBEXECDIR, command);
+    success = g_spawn_command_line_sync (command_line, NULL, NULL, NULL, &error);
+    g_free (command_line);
+
+    if (!success) {
+        g_critical ("Could not run pkexec (\"%s\") : %s\n",
+                    command, error->message);
+        g_error_free (error);
+        return FALSE;
+    }
+
+    g_debug ("pkexec did fine\n");
+    return TRUE;
+}
+
+gboolean
+procman_has_pkexec (void)
+{
+    return g_file_test("/usr/bin/pkexec", G_FILE_TEST_EXISTS);
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/41.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/41.html new file mode 100644 index 00000000..a96c88d2 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/41.html @@ -0,0 +1,913 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
/* Process properties dialog
+ * Copyright (C) 2010 Krishnan Parthasarathi <krishnan.parthasarathi@gmail.com>
+ *                    Robert Ancell <robert.ancell@canonical.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procmem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procmap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procstate.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "procproperties.h"
+#include "proctable.h"
+#include "util.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+enum
+{
+    COL_PROP = 0,
+    COL_VAL,
+    NUM_COLS,
+};
+
+typedef struct _proc_arg {
+    const gchar *prop;
+    gchar *val;
+} proc_arg;
+
+static void
+get_process_memory_writable (ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info (ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+static gchar*
+format_memsize(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
+}
+
+static gchar*
+format_size(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size(size);
+}
+
+static void
+fill_proc_properties (GtkWidget *tree, ProcInfo *info)
+{
+    guint i;
+    GtkListStore *store;
+
+    if (!info)
+        return;
+
+    get_process_memory_info(info);
+
+    proc_arg proc_props[] = {
+        { N_("Process Name"), g_strdup_printf("%s", info->name)},
+        { N_("User"), g_strdup_printf("%s (%d)", info->user.c_str(), info->uid)},
+        { N_("Status"), g_strdup(format_process_state(info->status))},
+        { N_("Memory"), format_memsize(info->mem)},
+        { N_("Virtual Memory"), format_memsize(info->vmsize)},
+        { N_("Resident Memory"), format_memsize(info->memres)},
+        { N_("Writable Memory"), format_memsize(info->memwritable)},
+        { N_("Shared Memory"), format_memsize(info->memshared)},
+#ifdef HAVE_WNCK
+        { N_("X Server Memory"), format_memsize(info->memxserver)},
+#endif
+        { N_("Disk Read Total"), format_size(info->disk_read_bytes_total)},
+        { N_("Disk Write Total"), format_size(info->disk_write_bytes_total)},
+        { N_("CPU"), g_strdup_printf("%d%%", info->pcpu)},
+        { N_("CPU Time"), procman::format_duration_for_display(100 * info->cpu_time / ProcData::get_instance()->frequency) },
+        { N_("Started"), procman_format_date_for_display(info->start_time) },
+        { N_("Nice"), g_strdup_printf("%d", info->nice)},
+        { N_("Priority"), g_strdup_printf("%s", procman::get_nice_level(info->nice)) },
+        { N_("ID"), g_strdup_printf("%d", info->pid)},
+        { N_("Security Context"), info->security_context ? g_strdup_printf("%s", info->security_context) : g_strdup(_("N/A"))},
+        { N_("Command Line"), g_strdup_printf("%s", info->arguments)},
+        { N_("Waiting Channel"), g_strdup_printf("%s", info->wchan)},
+        { N_("Control Group"), info->cgroup_name ? g_strdup_printf("%s", info->cgroup_name) : g_strdup(_("N/A"))},
+        { NULL, NULL}
+    };
+
+    store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
+    for (i = 0; proc_props[i].prop; i++) {
+        GtkTreeIter iter;
+
+        if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL(store), &iter, NULL, i)) {
+            gtk_list_store_append(store, &iter);
+            gtk_list_store_set(store, &iter, COL_PROP, _(proc_props[i].prop), -1);
+        }
+
+        gtk_list_store_set(store, &iter, COL_VAL, g_strstrip(proc_props[i].val), -1);
+        g_free(proc_props[i].val);
+    }
+}
+
+static void
+update_procproperties_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    fill_proc_properties(tree, info);
+}
+
+static void
+close_procprop_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    guint timer;
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static GtkWidget *
+create_procproperties_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    model = gtk_list_store_new (NUM_COLS,
+                                G_TYPE_STRING,	/* Property */
+                                G_TYPE_STRING	/* Value */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_COLS; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        column = gtk_tree_view_column_new_with_attributes (NULL,
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tree), FALSE);
+    fill_proc_properties(tree, procdata->selected_process);
+
+    return tree;
+}
+
+static gboolean
+procprop_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_procproperties_dialog (tree);
+
+    return TRUE;
+}
+
+static void
+create_single_procproperties_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                     GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *procpropdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    procpropdialog = gtk_dialog_new_with_buttons (_("Process Properties"), NULL,
+                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                  "gtk-close", GTK_RESPONSE_CLOSE,
+                                                  NULL);
+    gtk_window_set_resizable (GTK_WINDOW (procpropdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (procpropdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (procpropdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (procpropdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("Properties of process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_procproperties_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (procpropdialog), "response",
+                      G_CALLBACK (close_procprop_dialog), tree);
+
+    gtk_widget_show_all (procpropdialog);
+
+    timer = g_timeout_add_seconds (5, procprop_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_procproperties_dialog (tree);
+}
+
+void
+create_procproperties_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_procproperties_dialog,
+                                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/42.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/42.html new file mode 100644 index 00000000..194f1844 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/42.html @@ -0,0 +1,2635 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
/* Procman tree view and process updating
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <cairo-gobject.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gprintf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/loadavg.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/proclist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procstate.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procmem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procmap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/proctime.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procuid.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procargs.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/prockernel.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/swap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <pwd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <set><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <list><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef HAVE_SYSTEMD
+#include <systemd/sd-login.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include "procman.h"
+#include "selection.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "util.h"
+#include "interface.h"
+#include "selinux.h"
+#include "cgroups.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+ProcInfo::UserMap ProcInfo::users;
+ProcInfo::List ProcInfo::all;
+std::map<pid_t, guint64> ProcInfo::cpu_times;
+
+
+ProcInfo* ProcInfo::find(pid_t pid)
+{
+    Iterator it(ProcInfo::all.find(pid));
+    return (it == ProcInfo::all.end() ? NULL : it->second);
+}
+
+void
+get_last_selected (GtkTreeModel *model, GtkTreePath *path,
+           GtkTreeIter *iter, gpointer data)
+{
+    ProcInfo **info = static_cast<ProcInfo**>(data);
+
+    gtk_tree_model_get (model, iter, COL_POINTER, info, -1);
+}
+
+static void
+cb_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "proctree");
+}
+
+static void
+cb_sort_changed (GtkTreeSortable *model, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state (procdata->settings,
+                             GTK_WIDGET (procdata->tree),
+                             "proctree");
+}
+
+
+static GtkTreeViewColumn*
+my_gtk_tree_view_get_column_with_sort_column_id(GtkTreeView *treeview, int id)
+{
+    GList *columns, *it;
+    GtkTreeViewColumn *col = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(it = columns; it; it = it->next)
+    {
+        if(gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(it->data)) == id)
+        {
+            col = static_cast<GtkTreeViewColumn*>(it->data);
+            break;
+        }
+    }
+
+    g_list_free(columns);
+
+    return col;
+}
+
+
+void
+proctable_set_columns_order(GtkTreeView *treeview, GSList *order)
+{
+    GtkTreeViewColumn* last = NULL;
+    GSList *it;
+
+    for(it = order; it; it = it->next)
+    {
+        int id;
+        GtkTreeViewColumn *cur;
+
+        id = GPOINTER_TO_INT(it->data);
+
+        cur = my_gtk_tree_view_get_column_with_sort_column_id(treeview, id);
+
+        if(cur && cur != last)
+        {
+            gtk_tree_view_move_column_after(treeview, cur, last);
+            last = cur;
+        }
+    }
+}
+
+
+GSList*
+proctable_get_columns_order(GtkTreeView *treeview)
+{
+    GList *columns, *col;
+    GSList *order = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(col = columns; col; col = col->next)
+    {
+        int id;
+
+        id = gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(col->data));
+        order = g_slist_prepend(order, GINT_TO_POINTER(id));
+    }
+
+    g_list_free(columns);
+
+    order = g_slist_reverse(order);
+
+    return order;
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "proctree");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_proctable_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+static gboolean
+search_equal_func(GtkTreeModel *model,
+                  gint column,
+                  const gchar *key,
+                  GtkTreeIter *iter,
+                  gpointer search_data)
+{
+    char* name;
+    char* user;
+    gboolean found;
+
+    gtk_tree_model_get(model, iter,
+                       COL_NAME, &name,
+                       COL_USER, &user,
+                       -1);
+
+    found = !((name && strcasestr(name, key))
+              || (user && strcasestr(user, key)));
+
+    g_free(name);
+    g_free(user);
+
+    return found;
+}
+
+
+
+GtkWidget *
+proctable_new (ProcData * const procdata)
+{
+    GtkWidget *proctree;
+    GtkTreeStore *model;
+    GtkTreeSelection *selection;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell_renderer;
+
+    const gchar *titles[] = {
+        N_("Process Name"),
+        N_("User"),
+        N_("Status"),
+        N_("Virtual Memory"),
+        N_("Resident Memory"),
+        N_("Writable Memory"),
+        N_("Shared Memory"),
+        N_("X Server Memory"),
+        /* xgettext:no-c-format */ N_("% CPU"),
+        N_("CPU Time"),
+        N_("Started"),
+        N_("Nice"),
+        N_("ID"),
+        N_("Security Context"),
+        N_("Command Line"),
+        N_("Memory"),
+        /* xgettext: combined noun, the function the process is waiting in, see wchan ps(1) */
+        N_("Waiting Channel"),
+        N_("Control Group"),
+        N_("Unit"),
+        N_("Session"),
+        /* TRANSLATORS: Seat = i.e. the physical seat the session of the process belongs to, only
+	for multi-seat environments. See http://en.wikipedia.org/wiki/Multiseat_configuration */
+        N_("Seat"),
+        N_("Owner"),
+        N_("Disk Read Total"),
+        N_("Disk Write Total"),
+        N_("Disk Read"),
+        N_("Disk Write"),
+        N_("Priority"),
+        NULL,
+        "POINTER"
+    };
+
+    gint i;
+
+    model = gtk_tree_store_new (NUM_COLUMNS,
+                                G_TYPE_STRING,              /* Process Name */
+                                G_TYPE_STRING,              /* User         */
+                                G_TYPE_UINT,                /* Status       */
+                                G_TYPE_ULONG,               /* VM Size      */
+                                G_TYPE_ULONG,               /* Resident Memory */
+                                G_TYPE_ULONG,               /* Writable Memory */
+                                G_TYPE_ULONG,               /* Shared Memory */
+                                G_TYPE_ULONG,               /* X Server Memory */
+                                G_TYPE_UINT,                /* % CPU        */
+                                G_TYPE_UINT64,              /* CPU time     */
+                                G_TYPE_ULONG,               /* Started      */
+                                G_TYPE_INT,                 /* Nice         */
+                                G_TYPE_UINT,                /* ID           */
+                                G_TYPE_STRING,              /* Security Context */
+                                G_TYPE_STRING,              /* Arguments    */
+                                G_TYPE_ULONG,               /* Memory       */
+                                G_TYPE_STRING,              /* wchan        */
+                                G_TYPE_STRING,              /* Cgroup       */
+                                G_TYPE_STRING,              /* Unit         */
+                                G_TYPE_STRING,              /* Session      */
+                                G_TYPE_STRING,              /* Seat         */
+                                G_TYPE_STRING,              /* Owner        */
+                                G_TYPE_UINT64,              /* Disk read total */
+                                G_TYPE_UINT64,              /* Disk write total*/
+                                G_TYPE_UINT64,              /* Disk read    */
+                                G_TYPE_UINT64,              /* Disk write   */
+                                G_TYPE_STRING,              /* Priority     */
+                                CAIRO_GOBJECT_TYPE_SURFACE, /* Icon         */
+                                G_TYPE_POINTER,             /* ProcInfo     */
+                                G_TYPE_STRING               /* Sexy tooltip */
+        );
+
+    proctree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (proctree), COL_TOOLTIP);
+    g_object_set(G_OBJECT(proctree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+    gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (proctree),
+                                         search_equal_func,
+                                         NULL,
+                                         NULL);
+    g_object_unref (G_OBJECT (model));
+
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree));
+    gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+
+    column = gtk_tree_view_column_new ();
+
+    cell_renderer = gtk_cell_renderer_pixbuf_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "surface", COL_SURFACE,
+                                         NULL);
+
+    cell_renderer = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "text", COL_NAME,
+                                         NULL);
+    gtk_tree_view_column_set_title (column, _(titles[0]));
+    gtk_tree_view_column_set_sort_column_id (column, COL_NAME);
+    gtk_tree_view_column_set_resizable (column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+    gtk_tree_view_column_set_min_width (column, 20);
+    gtk_tree_view_column_set_reorderable (column, TRUE);
+    g_signal_connect(G_OBJECT(column), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (proctree), column);
+    gtk_tree_view_set_expander_column (GTK_TREE_VIEW (proctree), column);
+
+
+    for (i = COL_USER; i <= COL_PRIORITY; i++) {
+
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+#ifndef HAVE_WNCK
+        if (i == COL_MEMXSERVER) {
+          continue;
+        }
+#endif
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(proctree), col);
+
+        // type
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_CPU_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::duration_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_START_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::time_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_STATUS:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::status_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::io_rate_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_PRIORITY:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::priority_cell_data_func,
+                                                        GUINT_TO_POINTER(COL_NICE),
+                                                        NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+        }
+
+        // sorting
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+            case COL_CPU:
+            case COL_CPU_TIME:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_START_TIME:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::number_compare_func, GUINT_TO_POINTER(i),
+                                                NULL);
+                break;
+            case COL_PRIORITY:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::priority_compare_func,
+                                                GUINT_TO_POINTER(COL_NICE), NULL);
+                break;
+            default:
+                break;
+        }
+
+        // xalign
+        switch(i)
+        {
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMWRITABLE:
+            case COL_MEMSHARED:
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_CPU:
+            case COL_NICE:
+            case COL_PID:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_CPU_TIME:
+            case COL_MEM:
+                g_object_set(G_OBJECT(cell), "xalign", 1.0f, NULL);
+                break;
+        }
+
+        // sizing
+        switch (i) {
+            case COL_ARGS:
+                gtk_tree_view_column_set_min_width(col, 150);
+                break;
+            default:
+                gtk_tree_view_column_set_min_width(col, 20);
+                break;
+        }
+    }
+
+    procdata->tree = proctree;
+
+    procman_get_tree_state (procdata->settings, proctree, "proctree");
+
+    /* Override column settings by hiding this column if it's meaningless: */
+    if (!can_show_security_context_column ()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id (GTK_TREE_VIEW (proctree), COL_SECURITYCONTEXT);
+        gtk_tree_view_column_set_visible (column, FALSE);
+    }
+
+    if (!cgroups_enabled()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), COL_CGROUP);
+        gtk_tree_view_column_set_visible(column, FALSE);
+    }
+
+#ifdef HAVE_SYSTEMD
+    if (!LOGIND_RUNNING())
+#endif
+    {
+        for (i = COL_UNIT; i <= COL_OWNER; i++) {
+            column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), i);
+            gtk_tree_view_column_set_visible(column, FALSE);
+        }
+    }
+
+    g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree))),
+                      "changed",
+                      G_CALLBACK (cb_row_selected), procdata);
+    g_signal_connect (G_OBJECT (proctree), "popup_menu",
+                      G_CALLBACK (cb_tree_popup_menu), procdata);
+    g_signal_connect (G_OBJECT (proctree), "button_press_event",
+                      G_CALLBACK (cb_tree_button_pressed), procdata);
+
+    g_signal_connect (G_OBJECT(proctree), "columns-changed",
+                      G_CALLBACK(cb_columns_changed), procdata);
+
+    g_signal_connect (G_OBJECT (model), "sort-column-changed",
+                      G_CALLBACK (cb_sort_changed), procdata);
+
+    return proctree;
+}
+
+
+ProcInfo::~ProcInfo()
+{
+    g_free(this->name);
+    g_free(this->tooltip);
+    g_free(this->arguments);
+    g_free(this->security_context);
+    g_free(this->cgroup_name);
+    g_free(this->unit);
+    g_free(this->session);
+    g_free(this->seat);
+    cairo_surface_destroy(this->surface);
+}
+
+
+static void
+get_process_name (ProcInfo *info,
+                  const gchar *cmd, const GStrv args)
+{
+    if (args) {
+        // look for /usr/bin/very_long_name
+        // and also /usr/bin/interpreter /usr/.../very_long_name
+        // which may have use prctl to alter 'cmd' name
+        for (int i = 0; i != 2 && args[i]; ++i) {
+            char* basename;
+            basename = g_path_get_basename(args[i]);
+
+            if (g_str_has_prefix(basename, cmd)) {
+                info->name = basename;
+                return;
+            }
+
+            g_free(basename);
+        }
+    }
+
+    info->name = g_strdup (cmd);
+}
+
+std::string
+ProcInfo::lookup_user(guint uid)
+{
+    typedef std::pair<ProcInfo::UserMap::iterator, bool> Pair;
+    ProcInfo::UserMap::value_type hint(uid, "");
+    Pair p(ProcInfo::users.insert(hint));
+
+    // procman_debug("User lookup for uid %u: %s", uid, (p.second ? "MISS" : "HIT"));
+
+    if (p.second) {
+        struct passwd* pwd;
+        pwd = getpwuid(uid);
+
+        if (pwd && pwd->pw_name)
+            p.first->second = pwd->pw_name;
+        else {
+            char username[16];
+            g_sprintf(username, "%u", uid);
+            p.first->second = username;
+        }
+    }
+
+    return p.first->second;
+}
+
+void
+ProcInfo::set_user(guint uid)
+{
+    if (G_LIKELY(this->uid == uid))
+        return;
+
+    this->uid = uid;
+    this->user = lookup_user(uid);
+}
+
+static void get_process_memory_writable(ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info(ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+
+static void
+update_info_mutable_cols(ProcInfo *info)
+{
+    ProcData * const procdata = ProcData::get_instance();
+    GtkTreeModel *model;
+    model = gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->tree));
+
+    using procman::tree_store_update;
+
+    tree_store_update(model, &info->node, COL_STATUS, info->status);
+    tree_store_update(model, &info->node, COL_USER, info->user.c_str());
+    tree_store_update(model, &info->node, COL_VMSIZE, info->vmsize);
+    tree_store_update(model, &info->node, COL_MEMRES, info->memres);
+    tree_store_update(model, &info->node, COL_MEMWRITABLE, info->memwritable);
+    tree_store_update(model, &info->node, COL_MEMSHARED, info->memshared);
+#ifdef HAVE_WNCK
+    tree_store_update(model, &info->node, COL_MEMXSERVER, info->memxserver);
+#endif
+    tree_store_update(model, &info->node, COL_CPU, info->pcpu);
+    tree_store_update(model, &info->node, COL_CPU_TIME, info->cpu_time);
+    tree_store_update(model, &info->node, COL_DISK_READ_TOTAL, info->disk_read_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_TOTAL, info->disk_write_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_READ_CURRENT, info->disk_read_bytes_current);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_CURRENT, info->disk_write_bytes_current);
+    tree_store_update(model, &info->node, COL_START_TIME, info->start_time);
+    tree_store_update(model, &info->node, COL_NICE, info->nice);
+    tree_store_update(model, &info->node, COL_MEM, info->mem);
+    tree_store_update(model, &info->node, COL_WCHAN, info->wchan);
+    tree_store_update(model, &info->node, COL_CGROUP, info->cgroup_name);
+    tree_store_update(model, &info->node, COL_UNIT, info->unit);
+    tree_store_update(model, &info->node, COL_SESSION, info->session);
+    tree_store_update(model, &info->node, COL_SEAT, info->seat);
+    tree_store_update(model, &info->node, COL_OWNER, info->owner.c_str());
+}
+
+
+
+static void
+insert_info_to_tree (ProcInfo *info, ProcData *procdata, bool forced = false)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    if (procdata->config.show_tree) {
+
+        ProcInfo *parent = 0;
+
+        if (not forced)
+            parent = ProcInfo::find(info->ppid);
+
+        if (parent) {
+            GtkTreePath *parent_node = gtk_tree_model_get_path(model, &parent->node);
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, &parent->node, 0);
+
+            if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(procdata->tree), parent_node)
+#ifdef __linux__
+                // on linuxes we don't want to expand kthreadd by default (always has pid 2)
+                && (parent->pid != 2)
+#endif
+            )
+                gtk_tree_view_expand_row(GTK_TREE_VIEW(procdata->tree), parent_node, FALSE);
+            gtk_tree_path_free(parent_node);
+        } else
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, NULL, 0);
+    }
+    else
+        gtk_tree_store_insert (GTK_TREE_STORE (model), &info->node, NULL, 0);
+
+    gtk_tree_store_set (GTK_TREE_STORE (model), &info->node,
+                        COL_POINTER, info,
+                        COL_NAME, info->name,
+                        COL_ARGS, info->arguments,
+                        COL_TOOLTIP, info->tooltip,
+                        COL_PID, info->pid,
+                        COL_SECURITYCONTEXT, info->security_context,
+                        -1);
+
+    procdata->pretty_table.set_icon(*info);
+
+    procman_debug("inserted %d%s", info->pid, (forced ? " (forced)" : ""));
+}
+
+
+/* Removing a node with children - make sure the children are queued
+** to be readded.
+*/
+template<typename List>
+static void
+remove_info_from_tree (ProcData *procdata, GtkTreeModel *model,
+                       ProcInfo *current, List &orphans, unsigned lvl = 0)
+{
+    GtkTreeIter child_node;
+
+    if (std::find(orphans.begin(), orphans.end(), current) != orphans.end()) {
+        procman_debug("[%u] %d already removed from tree", lvl, int(current->pid));
+        return;
+    }
+
+    procman_debug("[%u] pid %d, %d children", lvl, int(current->pid),
+                  gtk_tree_model_iter_n_children(model, &current->node));
+
+    // it is not possible to iterate&erase over a treeview so instead we
+    // just pop one child after another and recursively remove it and
+    // its children
+
+    while (gtk_tree_model_iter_children(model, &child_node, &current->node)) {
+        ProcInfo *child = 0;
+        gtk_tree_model_get(model, &child_node, COL_POINTER, &child, -1);
+        remove_info_from_tree(procdata, model, child, orphans, lvl + 1);
+    }
+
+    g_assert(not gtk_tree_model_iter_has_child(model, &current->node));
+
+    if (procdata->selected_process == current)
+        procdata->selected_process = NULL;
+
+    orphans.push_back(current);
+    gtk_tree_store_remove(GTK_TREE_STORE(model), &current->node);
+    procman::poison(current->node, 0x69);
+}
+
+static void
+get_process_systemd_info(ProcInfo *info)
+{
+#ifdef HAVE_SYSTEMD
+    uid_t uid;
+
+    if (!LOGIND_RUNNING())
+        return;
+
+    free(info->unit);
+    info->unit = NULL;
+    sd_pid_get_unit(info->pid, &info->unit);
+
+    free(info->session);
+    info->session = NULL;
+    sd_pid_get_session(info->pid, &info->session);
+
+    free(info->seat);
+    info->seat = NULL;
+
+    if (info->session != NULL)
+        sd_session_get_seat(info->session, &info->seat);
+
+    if (sd_pid_get_owner_uid(info->pid, &uid) >= 0)
+        info->owner = info->lookup_user(uid);
+    else
+        info->owner = "";
+#endif
+}
+
+static void
+update_info (ProcData *procdata, ProcInfo *info)
+{
+    glibtop_proc_state procstate;
+    glibtop_proc_uid procuid;
+    glibtop_proc_time proctime;
+    glibtop_proc_kernel prockernel;
+    glibtop_proc_io procio;
+
+    glibtop_get_proc_kernel(&prockernel, info->pid);
+    g_strlcpy(info->wchan, prockernel.wchan, sizeof info->wchan);
+
+    glibtop_get_proc_state (&procstate, info->pid);
+    info->status = procstate.state;
+
+    glibtop_get_proc_uid (&procuid, info->pid);
+    glibtop_get_proc_time (&proctime, info->pid);
+    glibtop_get_proc_io (&procio, info->pid);
+
+    get_process_memory_info(info);
+
+    info->set_user(procstate.uid);
+
+    // if the cpu time has increased reset the status to running
+    // regardless of kernel state (https://bugzilla.gnome.org/606579)
+    guint64 difference = proctime.rtime - info->cpu_time;
+    if (difference > 0)
+        info->status = GLIBTOP_PROCESS_RUNNING;
+    info->pcpu = difference * 100 / procdata->cpu_total_time;
+    info->pcpu = MIN(info->pcpu, 100);
+
+    if (not procdata->config.solaris_mode)
+      info->pcpu *= procdata->config.num_cpus;
+
+    ProcInfo::cpu_times[info->pid] = info->cpu_time = proctime.rtime;
+    info->nice = procuid.nice;
+
+    gdouble update_interval_seconds = procdata->config.update_interval / 1000.0;
+    difference = procio.disk_wbytes - info->disk_write_bytes_total;
+    info->disk_write_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+    difference = procio.disk_rbytes - info->disk_read_bytes_total;
+    info->disk_read_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+
+    info->disk_write_bytes_total = procio.disk_wbytes;
+    info->disk_read_bytes_total = procio.disk_rbytes;
+
+    // set the ppid only if one can exist
+    // i.e. pid=0 can never have a parent
+    if (info->pid > 0) {
+        info->ppid = procuid.ppid;
+    }
+
+    g_assert(info->pid != info->ppid);
+    g_assert(info->ppid != -1 || info->pid == 0);
+
+    /* get cgroup data */
+    get_process_cgroup_info(info);
+
+    get_process_systemd_info(info);
+}
+
+
+ProcInfo::ProcInfo(pid_t pid)
+    : node(),
+      surface(),
+      tooltip(NULL),
+      name(NULL),
+      arguments(NULL),
+      security_context(NULL),
+      pid(pid),
+      ppid(-1),
+      uid(-1)
+{
+    ProcInfo * const info = this;
+    glibtop_proc_state procstate;
+    glibtop_proc_time proctime;
+    glibtop_proc_args procargs;
+    gchar** arguments;<--- Shadow variable
+
+    glibtop_get_proc_state (&procstate, pid);
+    glibtop_get_proc_time (&proctime, pid);
+    arguments = glibtop_get_proc_argv (&procargs, pid, 0);
+
+    /* FIXME : wrong. name and arguments may change with exec* */
+    get_process_name (info, procstate.cmd, static_cast<const GStrv>(arguments));
+
+    std::string tooltip = make_string(g_strjoinv(" ", arguments));<--- Shadow variable
+    if (tooltip.empty())
+        tooltip = procstate.cmd;
+
+    info->tooltip = g_markup_escape_text(tooltip.c_str(), -1);
+
+    info->arguments = g_strescape(tooltip.c_str(), "\\\"");
+    g_strfreev(arguments);
+
+    guint64 cpu_time = proctime.rtime;
+    std::map<pid_t, guint64>::iterator it(ProcInfo::cpu_times.find(pid));
+    if (it != ProcInfo::cpu_times.end())
+    {
+        if (proctime.rtime >= it->second)
+          cpu_time = it->second;
+    }
+    info->cpu_time = cpu_time;
+    info->start_time = proctime.start_time;
+
+    get_process_selinux_context (info);
+    info->cgroup_name = NULL;
+    get_process_cgroup_info(info);
+
+    info->unit = info->session = info->seat = NULL;
+    get_process_systemd_info(info);
+}
+
+static void
+refresh_list (ProcData *procdata, const pid_t* pid_list, const guint n)
+{
+    typedef std::list<ProcInfo*> ProcList;
+    ProcList addition;
+
+    GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+    guint i;
+
+    // Add or update processes in the process list
+    for(i = 0; i < n; ++i) {
+        ProcInfo *info = ProcInfo::find(pid_list[i]);
+
+        if (!info) {
+            info = new ProcInfo(pid_list[i]);
+            ProcInfo::all[info->pid] = info;
+            addition.push_back(info);
+        }
+
+        update_info (procdata, info);
+    }
+
+
+    // Remove dead processes from the process list and from the
+    // tree. children are queued to be readded at the right place
+    // in the tree.
+
+    const std::set<pid_t> pids(pid_list, pid_list + n);
+
+    ProcInfo::Iterator it(ProcInfo::begin());<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration
+
+    while (it != ProcInfo::end()) {
+        ProcInfo * const info = it->second;
+        ProcInfo::Iterator next(it);
+        ++next;
+
+        if (pids.find(info->pid) == pids.end()) {
+            procman_debug("ripping %d", info->pid);
+            remove_info_from_tree(procdata, model, info, addition);
+            addition.remove(info);
+            ProcInfo::all.erase(it);
+            delete info;
+        }
+
+        it = next;
+    }
+
+    // INVARIANT
+    // pid_list == ProcInfo::all + addition
+
+
+    if (procdata->config.show_tree) {
+
+        // insert process in the tree. walk through the addition list
+        // (new process + process that have a new parent). This loop
+        // handles the dependencies because we cannot insert a process
+        // until its parent is in the tree.
+
+        std::set<pid_t> in_tree(pids);
+
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            in_tree.erase((*it)->pid);
+
+
+        while (not addition.empty()) {
+            procman_debug("looking for %d parents", int(addition.size()));
+            ProcList::iterator it(addition.begin());<--- Shadow variable
+
+            while (it != addition.end()) {
+                procman_debug("looking for %d's parent with ppid %d",
+                              int((*it)->pid), int((*it)->ppid));
+
+
+                // inserts the process in the treeview if :
+                // - it has no parent (ppid = -1),
+                //   ie it is for example the [kernel] on FreeBSD
+                // - it is init
+                // - its parent is already in tree
+                // - its parent is unreachable
+                //
+                // rounds == 2 means that addition contains processes with
+                // unreachable parents
+                //
+                // FIXME: this is broken if the unreachable parent becomes active
+                // i.e. it gets active or changes ower
+                // so we just clear the tree on __each__ update
+                // see proctable_update_list (ProcData * const procdata)
+
+
+                if ((*it)->ppid <= 0 or in_tree.find((*it)->ppid) != in_tree.end()) {
+                    insert_info_to_tree(*it, procdata);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ProcInfo *parent = ProcInfo::find((*it)->ppid);<--- Variable 'parent' can be declared as pointer to const
+                // if the parent is unreachable
+                if (not parent) {
+                    // or std::find(addition.begin(), addition.end(), parent) == addition.end()) {
+                    insert_info_to_tree(*it, procdata, true);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ++it;
+            }
+        }
+    }
+    else {
+        // don't care of the tree
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            insert_info_to_tree(*it, procdata);
+    }
+
+
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)<--- Shadow variable
+        update_info_mutable_cols(it->second);
+}
+
+
+static void
+proctable_update_list (ProcData * const procdata)
+{
+    pid_t* pid_list;
+    glibtop_proclist proclist;
+    glibtop_cpu cpu;
+    gint which, arg;
+    procman::SelectionMemento selection;
+
+    switch (procdata->config.whose_process) {
+        case ALL_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL;
+            arg = 0;
+            break;
+
+        case ACTIVE_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL | GLIBTOP_EXCLUDE_IDLE;
+            arg = 0;
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+
+        default:
+            which = GLIBTOP_KERN_PROC_UID;
+            arg = getuid ();
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+    }
+
+    pid_list = glibtop_get_proclist (&proclist, which, arg);
+
+    /* FIXME: total cpu time elapsed should be calculated on an individual basis here
+    ** should probably have a total_time_last gint in the ProcInfo structure */
+    glibtop_get_cpu (&cpu);
+    procdata->cpu_total_time = MAX(cpu.total - procdata->cpu_total_time_last, 1);
+    procdata->cpu_total_time_last = cpu.total;
+
+    // FIXME: not sure if glibtop always returns a sorted list of pid
+    // but it is important otherwise refresh_list won't find the parent
+    std::sort(pid_list, pid_list + proclist.number);
+
+    refresh_list (procdata, pid_list, proclist.number);
+
+    selection.restore(procdata->tree);
+
+    g_free (pid_list);
+
+    /* proclist.number == g_list_length(procdata->info) == g_hash_table_size(procdata->pids) */
+}
+
+
+void
+proctable_update (ProcData * const procdata)
+{
+    char* string;
+
+    string = make_loadavg_string();
+    gtk_label_set_text (GTK_LABEL(procdata->loadavg), string);
+    g_free (string);
+
+    proctable_update_list (procdata);
+}
+
+
+void
+proctable_free_table (ProcData * const procdata)
+{
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)
+        delete it->second;
+
+    ProcInfo::all.clear();
+}
+
+
+void
+proctable_clear_tree (ProcData * const procdata)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    gtk_tree_store_clear (GTK_TREE_STORE (model));
+
+    proctable_free_table (procdata);
+
+    update_sensitivity(procdata);
+}
+
+
+char*
+make_loadavg_string(void)
+{
+    glibtop_loadavg buf;
+
+    glibtop_get_loadavg(&buf);
+
+    return g_strdup_printf(
+        _("Load averages for the last 1, 5, 15 minutes: "
+          "%0.2f, %0.2f, %0.2f"),
+        buf.loadavg[0],
+        buf.loadavg[1],
+        buf.loadavg[2]);
+}
+
+
+
+void
+ProcInfo::set_icon(Glib::RefPtr<Gdk::Pixbuf> icon)
+{
+  this->surface = gdk_cairo_surface_create_from_pixbuf (icon->gobj(), 0, NULL);
+
+  GtkTreeModel *model;
+  model = gtk_tree_view_get_model(GTK_TREE_VIEW(ProcData::get_instance()->tree));
+  gtk_tree_store_set(GTK_TREE_STORE(model), &this->node,
+                     COL_SURFACE, this->surface,
+                    -1);
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/43.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/43.html new file mode 100644 index 00000000..dc1ef059 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/43.html @@ -0,0 +1,279 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
#ifndef H_MATE_SYSTEM_MONITOR_SELECTION_H_1183113337
+#define H_MATE_SYSTEM_MONITOR_SELECTION_H_1183113337
+
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <vector><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+namespace procman
+{
+    class SelectionMemento
+    {
+        std::vector<pid_t> pids;
+        static void add_to_selected(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer data);
+
+    public:
+        void save(GtkWidget* tree);
+        void restore(GtkWidget* tree);
+    };
+}
+
+#endif /* H_MATE_SYSTEM_MONITOR_SELECTION_H_1183113337 */
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/44.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/44.html new file mode 100644 index 00000000..b0525da6 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/44.html @@ -0,0 +1,265 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
#ifndef PROCMAN_SELINUX_H_20050525
+#define PROCMAN_SELINUX_H_20050525
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+void
+get_process_selinux_context (ProcInfo *info);
+
+gboolean
+can_show_security_context_column (void) G_GNUC_CONST;
+
+#endif /* PROCMAN_SELINUX_H_20050525 */
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/45.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/45.html new file mode 100644 index 00000000..dc3f8198 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/45.html @@ -0,0 +1,323 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "selection.h"
+#include "proctable.h"
+#include "util.h"
+
+namespace procman
+{
+    void SelectionMemento::add_to_selected(GtkTreeModel* model, GtkTreePath*, GtkTreeIter* iter, gpointer data)
+    {
+        guint pid = 0;
+        gtk_tree_model_get(model, iter, COL_PID, &pid, -1);
+        if (pid)
+            static_cast<SelectionMemento*>(data)->pids.push_back(pid);
+    }
+
+
+    void SelectionMemento::save(GtkWidget* tree)
+    {
+        GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
+        gtk_tree_selection_selected_foreach(selection, &SelectionMemento::add_to_selected, this);
+    }
+
+
+    void SelectionMemento::restore(GtkWidget* tree)
+    {
+        if (not this->pids.empty())
+        {
+            GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
+            typedef std::vector<pid_t>::iterator iterator;
+            for (iterator it(this->pids.begin()); it != this->pids.end(); ++it)
+            {
+                if (ProcInfo* proc = ProcInfo::find(*it))
+                {
+                    gtk_tree_selection_select_iter(selection, &proc->node);
+                    procman_debug("Re-selected process %u", unsigned(*it));
+                }
+                else
+                    procman_debug("Could not find process %u, cannot re-select it", unsigned(*it));
+            }
+        }
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/46.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/46.html new file mode 100644 index 00000000..de751e8f --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/46.html @@ -0,0 +1,405 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "selinux.h"
+#include "procman.h"
+#include "util.h"
+
+
+static int (*getpidcon)(pid_t, char**);
+static void (*freecon)(char*);
+static int (*is_selinux_enabled)(void);
+
+static gboolean has_selinux;
+
+static gboolean load_selinux(void)
+{
+    return load_symbols("libselinux.so.1",
+                        "getpidcon", &getpidcon,
+                        "freecon", &freecon,
+                        "is_selinux_enabled", &is_selinux_enabled,
+                        NULL);
+}
+
+
+
+void
+get_process_selinux_context (ProcInfo *info)
+{
+    char *con;
+
+    if (has_selinux && !getpidcon (info->pid, &con)) {
+        info->security_context = g_strdup (con);
+        freecon (con);
+    }
+}
+
+
+
+gboolean
+can_show_security_context_column (void)
+{
+    if (!(has_selinux = load_selinux()))
+        return FALSE;
+
+    switch (is_selinux_enabled()) {
+        case 1:
+            /* We're running on an SELinux kernel */
+            return TRUE;
+
+        case -1:
+            /* Error; hide the security context column */
+
+        case 0:
+            /* We're not running on an SELinux kernel:
+               hide the security context column */
+
+        default:
+            g_warning("SELinux was found but is not enabled.\n");
+            return FALSE;
+    }
+}
+
+
+
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/47.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/47.html new file mode 100644 index 00000000..9b078f12 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/47.html @@ -0,0 +1,553 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/proctime.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <algorithm><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "smooth_refresh.h"
+#include "procman.h"
+#include "util.h"
+
+
+const string SmoothRefresh::KEY("smooth-refresh");
+
+
+unsigned SmoothRefresh::get_own_cpu_usage()
+{
+    glibtop_cpu cpu;
+    glibtop_proc_time proctime;
+    guint64 elapsed;
+    unsigned usage = PCPU_LO;
+
+    glibtop_get_cpu (&cpu);
+    elapsed = cpu.total - this->last_total_time;
+
+    if (elapsed) { // avoid division by 0
+        glibtop_get_proc_time(&proctime, getpid());
+        usage = (proctime.rtime - this->last_cpu_time) * 100 / elapsed;
+        this->last_cpu_time = proctime.rtime;
+    }
+
+    usage = MIN (usage, 100);
+
+    this->last_total_time = cpu.total;
+
+    return usage;
+}
+
+
+
+void SmoothRefresh::status_changed(GSettings *settings,
+                                   const gchar *key,
+                                   gpointer user_data)
+{
+    static_cast<SmoothRefresh*>(user_data)->load_settings_value(key);
+}
+
+void SmoothRefresh::load_settings_value(const gchar *key)
+{
+    this->active = g_settings_get_boolean(settings, key);
+
+    if (this->active)
+        procman_debug("smooth_refresh is enabled");
+}
+
+SmoothRefresh::SmoothRefresh(GSettings *a_settings)
+    :
+    settings(a_settings)
+{
+    this->connection = g_signal_connect(G_OBJECT(settings),
+                                        "changed::smooth-refresh",
+                                        G_CALLBACK(status_changed),
+                                        this);
+
+  this->reset();
+  this->load_settings_value(KEY.c_str());
+}
+
+
+
+void SmoothRefresh::reset()
+{
+    glibtop_cpu cpu;
+    glibtop_proc_time proctime;
+
+    glibtop_get_cpu(&cpu);
+    glibtop_get_proc_time(&proctime, getpid());
+
+    this->interval = ProcData::get_instance()->config.update_interval;
+    this->last_pcpu = PCPU_LO;
+    this->last_total_time = cpu.total;
+    this->last_cpu_time = proctime.rtime;
+}
+
+
+
+SmoothRefresh::~SmoothRefresh()
+{
+    if (this->connection)
+        g_signal_handler_disconnect(G_OBJECT(settings), this->connection);
+}
+
+
+
+bool
+SmoothRefresh::get(guint &new_interval)
+{
+    const unsigned config_interval = ProcData::get_instance()->config.update_interval;
+
+    g_assert(this->interval >= config_interval);
+
+    if (not this->active)
+        return false;
+
+
+    const unsigned pcpu = this->get_own_cpu_usage();
+    /*
+      invariant: MAX_UPDATE_INTERVAL >= interval >= config_interval >= MIN_UPDATE_INTERVAL
+
+      i see 3 cases:
+
+      a) interval is too big (CPU usage < 10%)
+      -> increase interval
+
+      b) interval is too small (CPU usage > 10%) AND interval != config_interval
+      >
+      -> decrease interval
+
+      c) interval is config_interval (start or interval is perfect)
+
+    */
+
+    if (pcpu > PCPU_HI && this->last_pcpu > PCPU_HI)
+        new_interval = this->interval * 11 / 10;
+    else if (this->interval != config_interval && pcpu < PCPU_LO && this->last_pcpu < PCPU_LO)
+        new_interval = this->interval * 9 / 10;
+    else
+        new_interval = this->interval;
+
+    new_interval = CLAMP(new_interval, config_interval, config_interval * 2);
+    new_interval = CLAMP(new_interval, MIN_UPDATE_INTERVAL, MAX_UPDATE_INTERVAL);
+
+    bool changed = this->interval != new_interval;
+
+    if (changed)
+        this->interval = new_interval;
+
+    this->last_pcpu = pcpu;
+
+
+    if (changed) {
+        procman_debug("CPU usage is %3u%%, changed refresh_interval to %u (config %u)",
+                      this->last_pcpu,
+                      this->interval,
+                      config_interval);
+    }
+
+    g_assert(this->interval == new_interval);
+    g_assert(this->interval >= config_interval);
+
+    return changed;
+}
+
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/48.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/48.html new file mode 100644 index 00000000..cbae209f --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/48.html @@ -0,0 +1,2359 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <libxml/parser.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libxml/xpath.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libxml/xpathInternals.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibtop/fsusage.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mountlist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/sysinfo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <netdb.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/socket.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/wait.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <exception><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <vector><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <fstream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sstream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/utsname.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "sysinfo.h"
+#include "procman.h"
+#include "util.h"
+
+
+using std::string;
+using std::vector;
+
+
+namespace {
+
+    class SysInfo
+    {
+    public:
+        string hostname;
+        string distro_name;
+        string distro_release;
+        string kernel;
+        string mate_version;
+        guint64 memory_bytes;
+        guint64 free_space_bytes;
+
+        string graphics;
+        string processors;
+
+        SysInfo()
+        {
+            this->load_processors_info();
+            this->load_graphics_info();
+            this->load_memory_info();
+            this->load_disk_info();
+            this->load_uname_info();
+            this->load_mate_version();
+        }
+
+        virtual ~SysInfo()
+        { }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Virtual function in base class
+        {
+            g_object_set(G_OBJECT(name),
+                        "label",
+                        ("<big><big><b>" + this->distro_name + "</b></big></big>").c_str(),
+                        NULL);
+
+            char* markup;
+#ifdef __linux__
+            if (this->distro_release != "")
+            {
+                /* Translators: The first string parameter is release version (codename),
+                 * the second one is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("Release %s %s"),
+                                         this->distro_release.c_str(),
+                                         SysInfo::get_os_type().c_str());
+            }
+            else
+            {
+                /* Translators: The string parameter is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("%s Version"),
+                                         SysInfo::get_os_type().c_str());
+            }
+#else
+            /* Translators: The string parameter is release version (codename) */
+            markup = g_strdup_printf(_("Release %s"),
+                                     this->distro_release.c_str());
+#endif
+
+            g_object_set(G_OBJECT(release),
+                         "label",
+                         markup,
+                         NULL);
+
+            g_free(markup);
+        }
+
+        static string release()
+        {
+            return uname().release;
+        }
+
+        static string system()
+        {
+            return uname().sysname;
+        }
+
+    private:
+
+        void load_memory_info()
+        {
+            glibtop_mem mem;
+
+            glibtop_get_mem(&mem);
+            this->memory_bytes = mem.total;
+        }
+
+        static string get_os_type ()<--- Unused private function: 'SysInfo::get_os_type'
+        {
+            int bits;
+
+            if (GLIB_SIZEOF_VOID_P == 8)
+                bits = 64;
+            else
+                bits = 32;
+
+            /* translators: This is the type of architecture, for example:
+             * "64-bit" or "32-bit" */
+            char* bytes = g_strdup_printf (_("%d-bit"), bits);
+            string retval(bytes);
+            g_free(bytes);
+            return retval;
+        }
+
+        typedef struct
+        {
+            const char* regex;
+            const char* replacement;
+        } ReplaceStrings;
+
+        static char* remove_duplicate_whitespace (const char* old)
+        {
+            char* result;
+            GRegex* re;
+            GError* error = NULL;
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+
+            re = g_regex_new ("[ \t\n\r]+", G_REGEX_MULTILINE, flags, &error);
+            if (re == NULL) {
+                g_warning ("Error building regex: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+            result = g_regex_replace (re, old, -1, 0, " ", flags, &error);
+            g_regex_unref (re);
+            if (result == NULL) {
+                g_warning ("Error replacing string: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+
+            return result;
+        }
+
+        static char* prettify_info (const char *info)
+        {
+            char* pretty;
+            const GRegexCompileFlags cflags = static_cast<GRegexCompileFlags>(0);
+            const GRegexMatchFlags mflags = static_cast<GRegexMatchFlags>(0);
+
+            static const ReplaceStrings rs[] = {
+                { "Intel[(]R[)]", "Intel\302\256"},
+                { "Core[(]TM[)]", "Core\342\204\242"},
+                { "Atom[(]TM[)]", "Atom\342\204\242"},
+            };
+
+            pretty = g_markup_escape_text (info, -1);
+
+            for (uint i = 0; i < G_N_ELEMENTS (rs); i++) {
+                GError* error;
+                GRegex* re;
+                char* result;
+
+                error = NULL;
+
+                re = g_regex_new (rs[i].regex, cflags, mflags, &error);
+                if (re == NULL) {
+                    g_warning ("Error building regex: %s", error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                result = g_regex_replace_literal (re, pretty, -1, 0,
+                                             rs[i].replacement, mflags, &error);
+
+                g_regex_unref (re);
+
+                if (error != NULL) {
+                    g_warning ("Error replacing %s: %s", rs[i].regex, error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                g_free (pretty);
+                pretty = result;
+            }
+
+            return pretty;
+        }
+
+        static char* get_renderer_from_helper (gboolean discrete_gpu)
+        {
+            int status;
+            const char *argv[] = { LIBEXECDIR "/mate-session-check-accelerated", NULL };
+            g_auto(GStrv) envp = NULL;
+            g_autofree char *renderer = NULL;
+            g_autoptr(GError) error = NULL;
+
+            if (discrete_gpu)
+            {
+                envp = g_get_environ ();
+                envp = g_environ_setenv (envp, "DRI_PRIME", "1", TRUE);
+            }
+
+            if (!g_spawn_sync (NULL, (char **) argv, envp, G_SPAWN_DEFAULT, NULL, NULL, &renderer, NULL, &status, &error))
+            {
+                g_debug ("Failed to get %s GPU: %s",
+                         discrete_gpu ? "discrete" : "integrated",
+                         error->message);
+                return NULL;
+            }
+
+            if (!g_spawn_check_exit_status (status, NULL))
+                return NULL;
+
+            if (renderer == NULL || *renderer == '\0')
+                return NULL;
+
+            return prettify_info (renderer);
+        }
+
+
+        void load_graphics_info()
+        {
+            g_autofree char *renderer = NULL;
+
+            try
+            {
+                g_autoptr(GDBusProxy) session_proxy = NULL;
+                g_autoptr(GVariant) renderer_variant = NULL;
+                g_autoptr(GError) error = NULL;
+
+                session_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                               G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL,
+                                                               "org.gnome.SessionManager",
+                                                               "/org/gnome/SessionManager",
+                                                               "org.gnome.SessionManager",
+                                                               NULL, &error);
+                if (error != NULL)
+                {
+                    throw std::runtime_error ("Unable to connect to create a proxy for org.gnome.SessionManager");
+                }
+
+                renderer_variant = g_dbus_proxy_get_cached_property (session_proxy, "Renderer");
+                if (!renderer_variant)
+                {
+                    throw std::runtime_error ("Unable to retrieve org.gnome.SessionManager.Renderer property.");
+                }
+
+                renderer = prettify_info (g_variant_get_string (renderer_variant, NULL));
+            }
+            catch (std::exception& e)
+            {
+                g_warning ("%s", e.what());
+            }
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (FALSE);
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (TRUE);
+
+            if (renderer)
+            {
+                this->graphics = g_strdup (renderer);
+            }
+            else
+            {
+                this->graphics = _("Unknown");
+            }
+        }
+
+        void load_processors_info()
+        {
+            const glibtop_sysinfo *info = glibtop_get_sysinfo();
+
+            GHashTable* counts;
+            GString* cpu;
+            GHashTableIter iter;
+            gpointer key, value;
+
+            counts = g_hash_table_new (g_str_hash, g_str_equal);
+
+            /* count duplicates */
+            for (uint i = 0; i != info->ncpu; ++i) {
+                const char* const keys[] = { "model name", "cpu", "Processor" };
+                char* model;
+                int* count;
+
+                model = NULL;
+
+                for (int j = 0; model == NULL && j != G_N_ELEMENTS (keys); ++j) {
+                    model = static_cast<char*>(g_hash_table_lookup (info->cpuinfo[i].values,
+                                                 keys[j]));
+                }
+
+                if (model == NULL)
+                    continue;
+
+                count = static_cast<int*>(g_hash_table_lookup (counts, model));
+                if (count == NULL)
+                    g_hash_table_insert (counts, model, GINT_TO_POINTER (1));
+                else
+                    g_hash_table_replace (counts, model, GINT_TO_POINTER (GPOINTER_TO_INT (count) + 1));
+            }
+
+            cpu = g_string_new (NULL);
+            g_hash_table_iter_init (&iter, counts);
+            while (g_hash_table_iter_next (&iter, &key, &value)) {
+                char* stripped;
+                int   count;
+
+                count = GPOINTER_TO_INT (value);
+                stripped = remove_duplicate_whitespace ((const char *)key);
+                if (count > 1)
+                    g_string_append_printf (cpu, "%s \303\227 %d ", stripped, count);
+                else
+                    g_string_append_printf (cpu, "%s ", stripped);
+                g_free (stripped);
+            }
+
+            g_hash_table_destroy (counts);
+            this->processors = string(prettify_info (cpu->str));
+            g_string_free (cpu, TRUE);
+        }
+
+        void load_disk_info()
+        {
+            GHashTable *devices;
+            glibtop_mountentry *entries;
+            glibtop_mountlist mountlist;
+
+            entries = glibtop_get_mountlist(&mountlist, 0);
+            devices = g_hash_table_new(g_str_hash, g_str_equal);
+            this->free_space_bytes = 0;
+
+            for (guint i = 0; i != mountlist.number; ++i) {
+                if ((string(entries[i].mountdir).compare("/") == 0) && \
+                    (string(entries[i].type).compare("zfs") == 0)) {
+                    // Root filesystem is ZFS based: Calculate usage based on "/".
+                    glibtop_fsusage usage;
+                    glibtop_get_fsusage(&usage, "/");
+                    this->free_space_bytes = usage.bavail * usage.block_size;
+                    break;
+                }
+
+                if (string(entries[i].devname).find("/dev/") != 0)
+                    continue;
+
+                if (string(entries[i].mountdir).find("/media/") == 0)
+                    continue;
+
+                /* avoid adding a device more than once such as for btrfs filesystem */
+                if (g_hash_table_contains (devices, entries[i].devname))
+                    continue;
+                else
+                    g_hash_table_insert (devices, entries[i].devname, entries[i].mountdir);
+
+                glibtop_fsusage usage;
+                glibtop_get_fsusage(&usage, entries[i].mountdir);
+                this->free_space_bytes += usage.bavail * usage.block_size;
+            }
+
+            g_hash_table_destroy (devices);
+            g_free(entries);
+        }
+
+        static const struct utsname & uname()
+        {
+            static struct utsname name;
+
+            if (!name.sysname[0]) {
+                ::uname(&name);
+            }
+
+            return name;
+        }
+
+        void load_uname_info()
+        {
+            this->hostname = uname().nodename;
+#if defined(__linux__)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().machine;
+#elif defined(__sun) && defined(__SVR4)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().version + ' ' + uname().machine;
+#else
+            this->kernel = string(uname().version) + ' ' + uname().machine;
+#endif
+        }
+
+
+        void load_mate_version()
+        {
+            xmlDocPtr document;
+            xmlXPathContextPtr context;
+            const string nodes[3] = { "string(/mate-version/platform)",
+                                      "string(/mate-version/minor)",
+                                      "string(/mate-version/micro)" };
+            string values[3];
+
+            if (not (document = xmlParseFile(DATADIR "/mate-about/mate-version.xml")))
+                return;
+
+            if (not (context = xmlXPathNewContext(document)))
+                return;
+
+            for (size_t i = 0; i != 3; ++i)
+            {
+                xmlXPathObjectPtr xpath;
+                xpath = xmlXPathEvalExpression(BAD_CAST nodes[i].c_str(), context);
+
+                if (xpath and xpath->type == XPATH_STRING)
+                    values[i] = reinterpret_cast<const char*>(xpath->stringval);
+
+                xmlXPathFreeObject(xpath);
+            }
+
+            xmlXPathFreeContext(context);
+            xmlFreeDoc(document);
+
+            if (!values[0].empty() && !values[1].empty() && !values[2].empty())
+                this->mate_version = values[0] + '.' + values[1] + '.' + values[2];
+        }
+    };
+
+    class FreeBSDSysInfo
+        : public SysInfo
+    {
+    public:
+	FreeBSDSysInfo()
+        {
+            this->load_freebsd_info();
+        }
+
+    private:
+        void load_freebsd_info()
+        {
+            this->distro_name = "FreeBSD";
+            this->distro_release = release();
+        }
+    };
+
+    class SolarisSysInfo
+        : public SysInfo
+    {
+    public:
+        SolarisSysInfo()
+        {
+            this->load_solaris_info();
+        }
+
+    private:
+        void load_solaris_info()
+        {
+            std::ifstream input("/etc/release");
+
+            if (input) {
+                std::string s;
+                std::getline(input, s);
+                std::size_t found = s.find("OpenIndiana ");
+                if (found!=std::string::npos) {
+                    this->distro_name = "OpenIndiana";
+                    this->distro_release = s.substr(found + strlen("OpenIndiana "));
+                } else if (!s.empty()) {
+                    this->distro_release = s;
+                }
+            }
+
+            if (this->distro_release.empty()) {
+                this->distro_name = "Solaris";
+            }
+        }
+    };
+
+
+    class LSBSysInfo
+        : public SysInfo
+    {
+    public:
+        LSBSysInfo()
+            : re(Glib::Regex::create("^.+?:\\s*(.+)\\s*$"))
+        {
+            // start();
+        }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Function in derived class
+        {
+            this->name = name;
+            this->release = release;
+
+            this->start();
+        }
+
+
+    private:
+
+        sigc::connection child_watch;
+        int lsb_fd;
+        GtkWidget* name;
+        GtkWidget* release;<--- Shadowed declaration<--- Shadowed declaration
+
+        void strip_description(string &s) const
+        {
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+            GMatchInfo* info = 0;
+
+           if (g_regex_match(this->re->gobj(), s.c_str(), flags, &info)) {
+               s = make_string(g_match_info_fetch(info, 1));
+               g_match_info_free(info);
+           }
+        }
+
+        std::istream& get_value(std::istream &is, string &s) const
+        {
+            if (std::getline(is, s))
+                this->strip_description(s);
+            return is;
+        }
+
+
+        void read_lsb(Glib::Pid pid, int status)
+        {
+            this->child_watch.disconnect();
+
+            if (!WIFEXITED(status) or WEXITSTATUS(status) != 0) {
+                g_error("Child %d failed with status %d", int(pid), status);
+                return;
+            }
+
+            Glib::RefPtr<Glib::IOChannel> channel = Glib::IOChannel::create_from_fd(this->lsb_fd);
+            Glib::ustring content;
+
+            while (channel->read_to_end(content) == Glib::IO_STATUS_AGAIN)
+                ;
+
+            channel->close();
+            Glib::spawn_close_pid(pid);
+
+            procman_debug("lsb_release output = '%s'", content.c_str());
+
+            string release, codename;<--- Shadow variable
+            std::istringstream input(content);
+
+            this->get_value(input, this->distro_name)
+                and this->get_value(input, release)
+                and this->get_value(input, codename);
+
+            this->distro_release = release;
+            if (codename != "" && codename != "n/a")
+                this->distro_release += " (" + codename + ')';
+
+            this->SysInfo::set_distro_labels(this->name, this->release);
+        }
+
+
+        void start()
+        {
+            std::vector<string> argv(2);
+            argv[0] = "lsb_release";
+            argv[1] = "-irc";
+
+            Glib::SpawnFlags flags = Glib::SPAWN_DO_NOT_REAP_CHILD
+                | Glib::SPAWN_SEARCH_PATH
+                | Glib::SPAWN_STDERR_TO_DEV_NULL;
+
+            Glib::Pid child;
+
+            try {
+                Glib::spawn_async_with_pipes("/", // wd
+                                             argv,
+                                             flags,
+                                             sigc::slot<void>(), // child setup
+                                             &child,
+                                             0, // stdin
+                                             &this->lsb_fd); // stdout
+            } catch (Glib::SpawnError &e) {
+                g_error("g_spawn_async_with_pipes error: %s", e.what().c_str());
+                return;
+            }
+
+            sigc::slot<void,GPid, int> slot = sigc::mem_fun(this, &LSBSysInfo::read_lsb);
+            this->child_watch = Glib::signal_child_watch().connect(slot, child);
+        }
+
+
+        void sync_lsb_release()<--- Unused private function: 'LSBSysInfo::sync_lsb_release'
+        {
+            char *out= 0;
+            GError *error = 0;
+            int status;
+
+            if (g_spawn_command_line_sync("lsb_release -irc",
+                                          &out,
+                                          0,
+                                          &status,
+                                          &error)) {
+                string release, codename;<--- Shadow variable
+                if (!error and WIFEXITED(status) and WEXITSTATUS(status) == 0) {
+                    std::istringstream input(out);
+                    this->get_value(input, this->distro_name)
+                        and this->get_value(input, release)
+                        and this->get_value(input, codename);
+                    this->distro_release = release;
+                if (codename != "" && codename != "n/a")
+                    this->distro_release += " (" + codename + ')';
+                }
+            }
+
+            if (error)
+                g_error_free(error);
+
+            g_free(out);
+        }
+
+    private:
+        Glib::RefPtr<Glib::Regex> re;
+    };
+
+
+    class NetBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        NetBSDSysInfo()
+        {
+            this->load_netbsd_info();
+        }
+
+    private:
+        void load_netbsd_info()
+        {
+            this->distro_name = "NetBSD";
+
+            std::ifstream input("/etc/release");
+
+            if (input)
+                std::getline(input, this->distro_release);
+        }
+    };
+
+
+    class GenericSysInfo
+        : public SysInfo
+    {
+    public:
+        GenericSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            std::ifstream input("/etc/os-release");
+
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int start;
+                    std::getline(input, s);
+                    if (s.find("NAME=") == 0) {
+                        start = strlen("NAME=");
+                        if ((s.at(start) == '\"') && (s.at(s.size() - 1) == '\"')) {
+                            this->distro_name = s.substr(start + 1, s.size() - start - 2);
+                        } else {
+                            this->distro_name = s.substr(start);
+                        }
+                    } else if (s.find("VERSION=") == 0) {
+                        start = strlen("VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    } else if (s.find("# VERSION=") == 0) {
+                        start = strlen("# VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    }
+                }
+                input.close();
+                input.clear();
+            }
+            if (this->distro_release.empty()) {
+                input.open("/etc/debian_version");
+                if (input) {
+                    getline(input, this->distro_release);
+                }
+            }
+        }
+    };
+
+    class MintSysInfo
+        : public SysInfo
+    {
+    public:
+        MintSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            this->distro_name = "Linux Mint";
+            std::ifstream input("/etc/linuxmint/info");
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int len;
+                    std::getline(input, s);
+                    if (s.find("DESCRIPTION=") == 0) {
+                        len = strlen("DESCRIPTION=");
+                        // also strip the surrounding quotes
+                       this->distro_release = s.substr(len + 1, s.size() - len - 2);
+                   }
+                }
+            }
+        }
+    };
+
+    class OpenBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        OpenBSDSysInfo()
+        {
+            this->load_openbsd_info();
+        }
+
+    private:
+        void load_openbsd_info()
+        {
+            this->distro_name = "OpenBSD";
+            this->distro_release = this->kernel;
+
+            std::ifstream input("/etc/motd");
+
+            if (input)
+                std::getline(input, this->kernel);
+        }
+    };
+
+    SysInfo* get_sysinfo()
+    {
+        if (g_file_test ("/etc/linuxmint/info", G_FILE_TEST_EXISTS)) {
+            return new MintSysInfo;
+        }
+        else if (g_file_test ("/etc/os-release", G_FILE_TEST_EXISTS)) {
+            return new GenericSysInfo;
+        }
+        else if (char *p = g_find_program_in_path("lsb_release")) {
+            g_free(p);
+            return new LSBSysInfo;
+        }
+        else if (SysInfo::system() == "FreeBSD") {
+            return new FreeBSDSysInfo;
+        }
+        else if (SysInfo::system() == "SunOS") {
+            return new SolarisSysInfo;
+        }
+        else if (SysInfo::system() == "NetBSD") {
+            return new NetBSDSysInfo;
+        }
+        else if (SysInfo::system() == "OpenBSD") {
+            return new OpenBSDSysInfo;
+        }
+
+        return new SysInfo;
+    }
+}
+
+
+#define X_PAD  0
+#define Y_PAD  0
+#define LOGO_W 92
+#define LOGO_H 351
+#define RADIUS 5
+
+static gboolean sysinfo_logo_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    GtkStyle *style;
+    cairo_t *cr;
+    cairo_pattern_t *cp;
+
+    cr = gdk_cairo_create(gtk_widget_get_window(widget));
+
+    gtk_widget_get_allocation (widget, &allocation);
+    cairo_translate(cr, allocation.x, allocation.y);
+
+    cairo_move_to(cr, X_PAD + RADIUS, Y_PAD);
+    cairo_line_to(cr, X_PAD + LOGO_W - RADIUS, Y_PAD);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + RADIUS, RADIUS, -0.5 * M_PI, 0);
+    cairo_line_to(cr, X_PAD + LOGO_W, Y_PAD + LOGO_H - RADIUS);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0, 0.5 * M_PI);
+    cairo_line_to(cr, X_PAD + RADIUS, Y_PAD + LOGO_H);
+    cairo_arc(cr, X_PAD + RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0.5 * M_PI, -1.0 * M_PI);
+    cairo_line_to(cr, X_PAD, Y_PAD + RADIUS);
+    cairo_arc(cr,  X_PAD + RADIUS, Y_PAD + RADIUS, RADIUS, -1.0 * M_PI, -0.5 * M_PI);
+
+    cp = cairo_pattern_create_linear(0, Y_PAD, 0, Y_PAD + LOGO_H);
+    style = gtk_widget_get_style (widget);
+    cairo_pattern_add_color_stop_rgba(cp, 0.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      1.0);
+    cairo_pattern_add_color_stop_rgba(cp, 1.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      0.0);
+    cairo_set_source(cr, cp);
+    cairo_fill(cr);
+
+    cairo_pattern_destroy(cp);
+    cairo_destroy(cr);
+
+    return FALSE;
+}
+
+static GtkWidget*
+add_section(GtkBox *vbox , const char * title, int num_row, int num_col, GtkWidget **out_frame)
+{
+    GtkWidget *table;
+
+    GtkWidget *frame = gtk_frame_new(title);
+    gtk_frame_set_label_align(GTK_FRAME(frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
+
+    table = gtk_grid_new();
+    gtk_grid_set_row_spacing(GTK_GRID(table), 6);
+    gtk_grid_set_column_spacing(GTK_GRID(table), 6);
+    gtk_widget_set_margin_start (GTK_WIDGET(table), 12);
+    gtk_container_set_border_width(GTK_CONTAINER(table), 6);
+    gtk_container_add(GTK_CONTAINER(frame), table);
+
+    if(out_frame)
+        *out_frame = frame;
+
+    return table;
+}
+
+
+static GtkWidget*
+add_row(GtkGrid * table, const char * label, const char * value, int row)
+{
+    GtkWidget *header = gtk_label_new(NULL);
+    gtk_label_set_markup(GTK_LABEL(header), label);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        table, header,
+        0, row, 1, 1);
+
+    GtkWidget *label_widget = gtk_label_new(value);
+    gtk_label_set_selectable(GTK_LABEL(label_widget), TRUE);
+    gtk_widget_set_can_focus(label_widget, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (label_widget), 0.0);
+    gtk_grid_attach(
+        table, label_widget,
+        1, row, 1, 1);
+
+    return label_widget;
+}
+
+
+static GtkWidget *
+procman_create_sysinfo_view(void)
+{
+    GtkWidget *hbox;
+    GtkWidget *vbox;
+
+    SysInfo *data = get_sysinfo();;
+
+    GtkWidget * logo;
+
+    GtkWidget *distro_frame;
+    GtkWidget *distro_release_label;
+    GtkWidget *distro_table;
+
+    GtkWidget *hardware_table;
+    GtkWidget *disk_space_table;
+
+    GtkWidget *header;
+
+    gchar *markup;
+
+    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);
+
+    /* left-side logo */
+    if (g_file_test (DATADIR "/pixmaps/mate-system-monitor/distribution/side.png", G_FILE_TEST_EXISTS)) {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/distribution/side.png");
+    }
+    else {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/side.png");
+    }
+    gtk_widget_set_valign (logo, GTK_ALIGN_START);
+    gtk_widget_set_margin_start (logo, 5);
+    gtk_widget_set_margin_end (logo, 5);
+    gtk_widget_set_margin_top (logo, 12);
+    gtk_widget_set_margin_bottom (logo, 12);
+    gtk_box_pack_start(GTK_BOX(hbox), logo, FALSE, FALSE, 0);
+
+    g_signal_connect(G_OBJECT(logo), "draw", G_CALLBACK(sysinfo_logo_draw), NULL);
+
+    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
+    gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
+
+    // hostname
+
+    markup = g_strdup_printf("<big><big><b><u>%s</u></b></big></big>",
+                             data->hostname.c_str());
+    GtkWidget *hostname_frame = gtk_frame_new(markup);
+    g_free(markup);
+    gtk_frame_set_label_align(GTK_FRAME(hostname_frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(hostname_frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(hostname_frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), hostname_frame, FALSE, FALSE, 0);
+
+
+    /* distro section */
+
+    unsigned table_size = 2;
+    if (data->mate_version != "")
+        table_size++;
+    distro_table = add_section(GTK_BOX(vbox), "???", table_size, 1, &distro_frame);
+
+    unsigned table_count = 0;
+
+    distro_release_label = gtk_label_new("???");
+    gtk_label_set_selectable(GTK_LABEL(distro_release_label), TRUE);
+    gtk_widget_set_can_focus(distro_release_label, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (distro_release_label), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), distro_release_label,
+        0, table_count, 1, 1);
+    table_count++;
+    data->set_distro_labels(gtk_frame_get_label_widget(GTK_FRAME(distro_frame)), distro_release_label);
+
+    markup = g_strdup_printf(_("Kernel %s"), data->kernel.c_str());
+    header = gtk_label_new(markup);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    g_free(markup);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), header,
+        0, table_count, 1, 1);
+    table_count++;
+
+    if (data->mate_version != "")
+    {
+        markup = g_strdup_printf(_("MATE %s"), data->mate_version.c_str());
+        header = gtk_label_new(markup);
+        gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+        gtk_widget_set_can_focus(header, FALSE);
+        g_free(markup);
+        gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+        gtk_grid_attach(
+            GTK_GRID(distro_table), header,
+            0, table_count, 1, 1);
+        table_count++;<--- Variable 'table_count' is assigned a value that is never used.
+    }
+
+    /* hardware section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("Hardware"));
+    hardware_table = add_section(GTK_BOX(vbox), markup, 1, 3, NULL);
+    g_free(markup);
+
+    markup = g_format_size_full(data->memory_bytes, G_FORMAT_SIZE_IEC_UNITS);
+    add_row(GTK_GRID(hardware_table), _("Memory:"), markup, 0);
+    g_free(markup);
+
+    add_row(GTK_GRID(hardware_table), _("Processor:"),
+            data->processors.c_str(), 1);
+    add_row(GTK_GRID(hardware_table), _("Graphics:"),
+            data->graphics.c_str(), 2);
+
+    /* disk space section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("System Status"));
+    disk_space_table = add_section(GTK_BOX(vbox), markup, 1, 2, NULL);
+    g_free(markup);
+
+    markup = g_format_size(data->free_space_bytes);
+    add_row(GTK_GRID(disk_space_table), _("Available disk space:"), markup, 0);
+    g_free(markup);
+
+    return hbox;
+}
+
+
+
+namespace procman
+{
+    void build_sysinfo_ui()
+    {
+        static GtkWidget* ui;
+
+        if (!ui) {
+            ProcData* procdata = ProcData::get_instance();
+            ui = procman_create_sysinfo_view();
+            GtkBox* box = GTK_BOX(gtk_notebook_get_nth_page(GTK_NOTEBOOK(procdata->notebook),
+                                                            PROCMAN_TAB_SYSINFO));
+            gtk_box_pack_start(box, ui, TRUE, TRUE, 0);
+            gtk_widget_show_all(ui);
+        }
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/49.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/49.html new file mode 100644 index 00000000..598373c6 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/49.html @@ -0,0 +1,1557 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gprintf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibtop/proctime.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procstate.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <stddef.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <cstring><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "util.h"
+#include "procman.h"
+
+gchar *
+procman_format_date_for_display(time_t time_raw)
+{
+    gchar *result = NULL;
+    const char *format;
+    GDateTime *date_time, *today;
+    GTimeSpan date_age;
+
+    date_time = g_date_time_new_from_unix_local (time_raw);
+    today = g_date_time_new_now_local ();
+
+    date_age = g_date_time_difference (today, date_time);
+    if (date_age < G_TIME_SPAN_DAY) {
+        format = _("Today %l:%M %p");
+    } else if (date_age < 2 * G_TIME_SPAN_DAY) {
+        format = _("Yesterday %l:%M %p");
+    } else if (date_age < 7 * G_TIME_SPAN_DAY) {
+        format = _("%a %l:%M %p");
+    } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
+        format = _("%b %d %l:%M %p");
+    } else {
+	format = _("%b %d %Y");
+    }
+
+    g_date_time_unref (today);
+    result = g_date_time_format (date_time, format);
+    g_date_time_unref (date_time);
+
+    return result;
+}
+
+const char*
+format_process_state(guint state)
+{
+    const char *status;
+
+    switch (state)
+        {
+        case GLIBTOP_PROCESS_RUNNING:
+            status = _("Running");
+            break;
+
+        case GLIBTOP_PROCESS_STOPPED:
+            status = _("Stopped");
+            break;
+
+        case GLIBTOP_PROCESS_ZOMBIE:
+            status = _("Zombie");
+            break;
+
+        case GLIBTOP_PROCESS_UNINTERRUPTIBLE:
+            status = _("Uninterruptible");
+            break;
+
+        default:
+            status = _("Sleeping");
+            break;
+        }
+
+    return status;
+}
+
+
+
+static char *
+mnemonic_safe_process_name(const char *process_name)
+{
+    const char *p;
+    GString *name;
+
+    name = g_string_new ("");
+
+    for(p = process_name; *p; ++p)
+    {
+        g_string_append_c (name, *p);
+
+        if(*p == '_')
+            g_string_append_c (name, '_');
+    }
+
+    return g_string_free (name, FALSE);
+}
+
+
+
+static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
+{
+    *q = *r / d;
+    *r = *r % d;
+    return *q != 0;
+}
+
+
+/*
+ * @param d: duration in centiseconds
+ * @type d: unsigned
+ */
+gchar *
+procman::format_duration_for_display(unsigned centiseconds)
+{
+    unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
+
+    (void)(divide(&seconds, &centiseconds, 100)
+           && divide(&minutes, &seconds, 60)
+           && divide(&hours, &minutes, 60)
+           && divide(&days, &hours, 24)
+           && divide(&weeks, &days, 7));
+
+    if (weeks)
+        /* xgettext: weeks, days */
+        return g_strdup_printf(_("%uw%ud"), weeks, days);
+
+    if (days)
+        /* xgettext: days, hours (0 -> 23) */
+        return g_strdup_printf(_("%ud%02uh"), days, hours);
+
+    if (hours)
+        /* xgettext: hours (0 -> 23), minutes, seconds */
+        return g_strdup_printf(_("%u:%02u:%02u"), hours, minutes, seconds);
+
+    /* xgettext: minutes, seconds, centiseconds */
+    return g_strdup_printf(_("%u:%02u.%02u"), minutes, seconds, centiseconds);
+}
+
+
+
+GtkWidget*
+procman_make_label_for_mmaps_or_ofiles(const char *format,
+                                       const char *process_name,
+                                       unsigned pid)
+{
+    GtkWidget *label;
+    char *name, *title;
+
+    name = mnemonic_safe_process_name (process_name);
+    title = g_strdup_printf(format, name, pid);
+    label = gtk_label_new_with_mnemonic (title);
+    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+
+    g_free (title);
+    g_free (name);
+
+    return label;
+}
+
+gchar *
+procman::get_nice_level (gint nice)
+{
+    if (nice < -7)
+        return _("Very High");
+    else if (nice < -2)
+        return _("High");
+    else if (nice < 3)
+        return _("Normal");
+    else if (nice < 7)
+        return _("Low");
+    else
+        return _("Very Low");
+}
+
+
+gboolean
+load_symbols(const char *module, ...)
+{
+    GModule *mod;
+    gboolean found_all = TRUE;
+    va_list args;
+
+    mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
+
+    if (!mod)
+        return FALSE;
+
+    procman_debug("Found %s", module);
+
+    va_start(args, module);
+
+    while (1) {
+        const char *name;
+        void **symbol;
+
+        name = va_arg(args, char*);
+
+        if (!name)
+            break;
+
+        symbol = va_arg(args, void**);
+
+        if (g_module_symbol(mod, name, symbol)) {
+            procman_debug("Loaded %s from %s", name, module);
+        }
+        else {
+            procman_debug("Could not load %s from %s", name, module);
+            found_all = FALSE;
+            break;
+        }
+    }
+
+    va_end(args);
+
+
+    if (found_all)
+        g_module_make_resident(mod);
+    else
+        g_module_close(mod);
+
+    return found_all;
+}
+
+
+static gboolean
+is_debug_enabled(void)
+{
+    static gboolean init;
+    static gboolean enabled;
+
+    if (!init) {
+        enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL;
+        init = TRUE;
+    }
+
+    return enabled;
+}
+
+
+#if GLIB_CHECK_VERSION(2,61,2)
+static gint64
+get_relative_time(void)
+{
+    static unsigned long start_time;
+    gint64 tv;
+
+    if (G_UNLIKELY(!start_time)) {
+        glibtop_proc_time buf;
+        glibtop_get_proc_time(&buf, getpid());
+        start_time = buf.start_time;
+    }
+
+    tv = g_get_real_time ();
+    return tv - (gint64) start_time;
+}
+#else
+static double
+get_relative_time(void)
+{
+    static unsigned long start_time;
+    GTimeVal tv;
+
+    if (G_UNLIKELY(!start_time)) {
+        glibtop_proc_time buf;
+        glibtop_get_proc_time(&buf, getpid());
+        start_time = buf.start_time;
+    }
+
+    g_get_current_time(&tv);
+    return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
+}
+#endif
+
+static guint64
+get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
+                             const guint index)
+{
+    GValue value = { 0 };
+    gtk_tree_model_get_value(model, first, index, &value);
+
+    guint64 size;
+    switch (G_VALUE_TYPE(&value)) {
+        case G_TYPE_UINT:
+            size = g_value_get_uint(&value);
+            break;
+        case G_TYPE_ULONG:
+            size = g_value_get_ulong(&value);
+            break;
+        case G_TYPE_UINT64:
+            size = g_value_get_uint64(&value);
+            break;
+        default:
+            g_assert_not_reached();
+    }
+
+    g_value_unset(&value);
+    return size;
+}
+
+void
+procman_debug_real(const char *file, int line, const char *func,
+                   const char *format, ...)
+{
+    va_list args;
+    char *msg;
+
+    if (G_LIKELY(!is_debug_enabled()))
+        return;
+
+    va_start(args, format);
+    msg = g_strdup_vprintf(format, args);
+    va_end(args);
+
+#if GLIB_CHECK_VERSION(2,61,2)
+    g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
+#else
+    g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
+#endif
+    g_free(msg);
+}
+
+
+
+namespace procman
+{
+    void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                    GtkTreeModel *model, GtkTreeIter *iter,
+                                    gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+            case G_TYPE_UINT64:
+                size = g_value_get_uint64(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
+        g_object_set(renderer, "text", str, NULL);
+        g_free(str);
+    }
+
+    /*
+      Same as above but handles size == 0 as not available
+     */
+    void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                       GtkTreeModel *model, GtkTreeIter *iter,
+                                       gpointer user_data)
+    {
+     	const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+          case G_TYPE_UINT64:
+              size = g_value_get_uint64(&value);
+              break;
+
+          default:
+              g_assert_not_reached();
+        }
+
+	g_value_unset(&value);
+
+        if (size == 0) {
+            char *str = g_strdup_printf ("<i>%s</i>", _("N/A"));
+            g_object_set(renderer, "markup", str, NULL);
+            g_free(str);
+        }
+	else {
+            char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
+            g_object_set(renderer, "text", str, NULL);
+            g_free(str);
+        }
+    }
+
+    void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                     GtkTreeModel *model, GtkTreeIter *iter,
+                                     gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+            case G_TYPE_UINT64:
+                size = g_value_get_uint64(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        char *str = g_format_size(size);
+        g_object_set(renderer, "text", str, NULL);
+        g_free(str);
+    }
+
+    /*
+      Same as above but handles size == 0 as not available
+     */
+    void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                        GtkTreeModel *model, GtkTreeIter *iter,
+                                        gpointer user_data)
+    {
+     	const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+          case G_TYPE_UINT64:
+              size = g_value_get_uint64(&value);
+              break;
+
+          default:
+              g_assert_not_reached();
+        }
+
+	g_value_unset(&value);
+
+        if (size == 0) {
+            char *str = g_strdup_printf ("<i>%s</i>", _("N/A"));
+            g_object_set(renderer, "markup", str, NULL);
+            g_free(str);
+        }
+	else {
+            char *str = g_format_size(size);
+            g_object_set(renderer, "text", str, NULL);
+            g_free(str);
+        }
+    }
+
+    void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                                GtkTreeModel *model, GtkTreeIter *iter,
+                                gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+            case G_TYPE_UINT64:
+                size = g_value_get_uint64(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        if (size == 0) {
+            char *str = g_strdup_printf ("<i>%s</i>", _("N/A"));
+            g_object_set(renderer, "markup", str, NULL);
+            g_free(str);
+        }
+        else {
+            char *str = g_format_size(size);
+            char *formatted_str = g_strdup_printf(_("%s/s"), str);
+            g_object_set(renderer, "text", formatted_str, NULL);
+            g_free(formatted_str);
+            g_free(str);
+        }
+
+    }
+
+    void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                                 GtkTreeModel *model, GtkTreeIter *iter,
+                                 gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        unsigned time;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+            time = g_value_get_ulong(&value);
+            break;
+
+            case G_TYPE_UINT64:
+                time = g_value_get_uint64(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        time = 100 * time / ProcData::get_instance()->frequency;
+        char *str = format_duration_for_display(time);
+        g_object_set(renderer, "text", str, NULL);
+        g_free(str);
+    }
+
+
+    void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                             GtkTreeModel *model, GtkTreeIter *iter,
+                             gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        time_t time;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                time = g_value_get_ulong(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        gchar *str = procman_format_date_for_display(time);
+        g_object_set(renderer, "text", str, NULL);
+        g_free(str);
+    }
+
+    void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                               GtkTreeModel *model, GtkTreeIter *iter,
+                               gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint state;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_UINT:
+                state = g_value_get_uint(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        const char *str = format_process_state(state);
+        g_object_set(renderer, "text", str, NULL);
+    }
+
+    void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                             GtkTreeModel *model, GtkTreeIter *iter,
+                             gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        gint priority = g_value_get_int(&value);
+
+        g_value_unset(&value);
+
+        g_object_set(renderer, "text", procman::get_nice_level(priority), NULL);
+
+    }
+
+    gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
+                            GtkTreeIter* second, gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+        GValue value1 = { 0 };
+        GValue value2 = { 0 };
+        gtk_tree_model_get_value(model, first, index, &value1);
+        gtk_tree_model_get_value(model, second, index, &value2);
+        gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
+        g_value_unset(&value1);
+        g_value_unset(&value2);
+        return result;
+    }
+
+    gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
+                            GtkTreeIter* second, gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size1, size2;
+        size1 = get_size_from_column(model, first, index);
+        size2 = get_size_from_column(model, second, index);
+
+        if ( size2 > size1 )
+            return 1;
+        else if ( size2 < size1 )
+            return -1;
+        return 0;
+    }
+
+    template<>
+    void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
+    {
+        char* current_value;
+
+        gtk_tree_model_get(model, iter, column, &current_value, -1);
+
+        if (g_strcmp0(current_value, new_value) != 0)
+            gtk_tree_store_set(GTK_TREE_STORE(model), iter, column, new_value, -1);
+
+        g_free(current_value);
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/5.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/5.html new file mode 100644 index 00000000..111df8f5 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/5.html @@ -0,0 +1,435 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
#ifndef _PROCMAN_SMOOTH_REFRESH
+#define _PROCMAN_SMOOTH_REFRESH
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+using std::string;
+
+class SmoothRefresh
+{
+  public:
+
+    /*
+      smooth_refresh_new
+
+      @config_interval : pointer to config_interval so we can observe
+      config_interval changes.
+
+      @return : initialized SmoothRefresh
+    */
+    SmoothRefresh(GSettings *a_settings);
+
+    ~SmoothRefresh();
+
+    /*
+      smooth_refresh_reset
+
+      Resets state and re-read config_interval
+    */
+    void reset();
+
+    /*
+      smooth_refresh_get
+
+      Computes the new refresh_interval so that CPU usage is lower than
+      SMOOTH_REFRESH_PCPU.
+
+      @new_interval : where the new refresh_interval is stored.
+
+      @return : TRUE is refresh_interval has changed. The new refresh_interval
+      is stored in @new_interval. Else FALSE;
+    */
+    bool get(guint &new_interval);
+
+    static const string KEY;
+    static const bool KEY_DEFAULT_VALUE;
+
+  private:
+
+    unsigned get_own_cpu_usage();
+
+    static void status_changed(GSettings *settings,
+                               const gchar *key,
+                               gpointer user_data);
+
+    void load_settings_value(const gchar *key);
+
+    /*
+      fuzzy logic:
+      - decrease refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_LO
+      - increase refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_HI
+
+    */
+
+    enum
+    {
+        PCPU_HI = 22,
+        PCPU_LO = 18
+    };
+
+    /*
+      -self : procman's PID (so we call getpid() only once)
+
+      -interval : current refresh interval
+
+      -config_interval : pointer to the configuration refresh interval.
+      Used to watch configuration changes
+
+      -interval >= -config_interval
+
+      -last_pcpu : to avoid spikes, the last CPU%. See PCPU_{LO,HI}
+
+      -last_total_time:
+      -last_cpu_time: Save last cpu and process times to compute CPU%
+    */
+
+    GSettings *settings;
+    bool active;
+    guint connection;
+    guint interval;
+    unsigned  last_pcpu;
+    guint64 last_total_time;
+    guint64 last_cpu_time;
+};
+
+#endif /* _PROCMAN_SMOOTH_REFRESH */
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/50.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/50.html new file mode 100644 index 00000000..70b6b8df --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/50.html @@ -0,0 +1,275 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+int main(int argc, char* argv[])<--- Parameter 'argv' can be declared as const array
+{
+    gchar **argv_modified = g_new0 (gchar *, (size_t)(argc + 1));
+    memcpy (argv_modified, argv, (size_t)(argc) * sizeof (char*));
+    argv_modified[0] = COMMAND;
+    int errsv = 0;
+
+    if (execvp (COMMAND, argv_modified) == -1) {
+        errsv = errno;
+    }
+
+    g_free (argv_modified);
+    return errsv;
+}
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/6.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/6.html new file mode 100644 index 00000000..7792f2fa --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/6.html @@ -0,0 +1,385 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
// -*- c++ -*-
+
+#ifndef _PROCMAN_PRETTYTABLE_H_
+#define _PROCMAN_PRETTYTABLE_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk-pixbuf/gdk-pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/refptr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdkmm/pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/filemonitor.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <map><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef HAVE_WNCK
+extern "C" {
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+}
+#endif
+
+#include "iconthemewrapper.h"
+
+class ProcInfo;
+
+using std::string;
+
+class PrettyTable
+{
+ public:
+    PrettyTable();
+    ~PrettyTable();
+
+    void set_icon(ProcInfo &);
+
+private:
+
+#ifdef HAVE_WNCK
+    static void on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_opened'
+    static void on_application_closed(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_closed'
+
+    void register_application(pid_t pid, Glib::RefPtr<Gdk::Pixbuf> icon);
+    void unregister_application(pid_t pid);
+#endif
+
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_theme(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_default(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_gio(const ProcInfo &);
+#ifdef HAVE_WNCK
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_wnck(const ProcInfo &);
+#endif
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_name(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_for_kernel(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_dummy(const ProcInfo &);
+
+    bool get_default_icon_name(const string &cmd, string &name);
+    void file_monitor_event (Glib::RefPtr<Gio::File>,
+                             Glib::RefPtr<Gio::File>,
+                             Gio::FileMonitorEvent);
+    void init_gio_app_cache ();
+
+    typedef std::map<string, Glib::RefPtr<Gdk::Pixbuf> > IconCache;
+    typedef std::map<pid_t, Glib::RefPtr<Gdk::Pixbuf> > IconsForPID;
+    typedef std::map<string, Glib::RefPtr<Gio::AppInfo> > AppCache;
+    typedef std::map<string, Glib::RefPtr<Gio::FileMonitor> > DesktopDirMonitors;
+
+    IconsForPID apps;
+    IconCache defaults;
+    DesktopDirMonitors monitors;
+    AppCache gio_apps;
+    procman::IconThemeWrapper theme;
+};
+
+#endif /* _PROCMAN_PRETTYTABLE_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/7.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/7.html new file mode 100644 index 00000000..e4d2cec9 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/7.html @@ -0,0 +1,287 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
#ifndef H_PROCMAN_ICONTHEMEWRAPPER_H_1185707711
+#define H_PROCMAN_ICONTHEMEWRAPPER_H_1185707711
+
+#include <glibmm/refptr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/ustring.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtkmm/icontheme.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdkmm/pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+namespace procman
+{
+    class IconThemeWrapper
+    {
+      public:
+        // returns 0 instead of raising an exception
+        Glib::RefPtr<Gdk::Pixbuf>
+            load_icon(const Glib::ustring& icon_name, int size) const;
+        Glib::RefPtr<Gdk::Pixbuf>
+            load_gicon(const Glib::RefPtr<Gio::Icon>& gicon, int size, Gtk::IconLookupFlags flags) const;
+
+        const IconThemeWrapper* operator->() const
+        { return this; }
+    };
+}
+
+#endif // H_PROCMAN_ICONTHEMEWRAPPER_H_1185707711
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/8.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/8.html new file mode 100644 index 00000000..f0a0b119 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/8.html @@ -0,0 +1,385 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
/*
+ * Mate system monitor color pickers
+ * Copyright (C) 2007 Karl Lattimer <karl@qdh.org.uk>
+ * Copyright (C) 2012-2021 MATE Developers
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with the software; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GSM_COLOR_BUTTON_H__
+#define __GSM_COLOR_BUTTON_H__
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+/* The GtkColorSelectionButton widget is a simple color picker in a button.
+ * The button displays a sample of the currently selected color. When
+ * the user clicks on the button, a color selection dialog pops up.
+ * The color picker emits the "color_set" signal when the color is set.
+ */
+#define GSM_TYPE_COLOR_BUTTON            (gsm_color_button_get_type ())
+G_DECLARE_DERIVABLE_TYPE (GSMColorButton, gsm_color_button, GSM, COLOR_BUTTON, GtkDrawingArea)
+
+/* Widget types */
+enum
+{
+    GSMCP_TYPE_CPU,
+    GSMCP_TYPE_PIE,
+    GSMCP_TYPE_NETWORK_IN,
+    GSMCP_TYPE_NETWORK_OUT,
+    GSMCP_TYPES
+};
+
+struct _GSMColorButtonClass
+{
+    GtkWidgetClass parent_class;
+
+    void (*color_set) (GSMColorButton * cp);
+
+    /* Padding for future expansion */
+    void (*_gtk_reserved1) (void);
+    void (*_gtk_reserved2) (void);
+    void (*_gtk_reserved3) (void);
+    void (*_gtk_reserved4) (void);
+};
+
+GtkWidget *gsm_color_button_new (const GdkRGBA * color, guint type);
+void gsm_color_button_set_color (GSMColorButton * color_button, const GdkRGBA * color);
+void gsm_color_button_set_fraction (GSMColorButton * color_button, const gdouble fraction);
+void gsm_color_button_set_cbtype (GSMColorButton * color_button, guint type);
+void gsm_color_button_get_color (GSMColorButton * color_button, GdkRGBA * color);
+gdouble gsm_color_button_get_fraction (GSMColorButton * color_button);
+guint gsm_color_button_get_cbtype (GSMColorButton * color_button);
+void gsm_color_button_set_title (GSMColorButton * color_button, const gchar * title);
+const gchar* gsm_color_button_get_title(GSMColorButton* color_button);
+
+G_END_DECLS
+#endif /* __GSM_COLOR_BUTTON_H__ */
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/9.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/9.html new file mode 100644 index 00000000..0b6fb092 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/9.html @@ -0,0 +1,305 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
/* Procman - main window
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef _PROCMAN_INTERFACE_H_
+#define _PROCMAN_INTERFACE_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+void            create_main_window (ProcData *data);
+void            update_sensitivity (ProcData *data);
+void            block_priority_changed_handlers(ProcData *data, bool block);
+void            do_popup_menu(ProcData *data, GdkEventButton *event);
+GtkWidget *     make_title_label (const char *text);
+
+#endif /* _PROCMAN_INTERFACE_H_ */
+
+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/index.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/index.html new file mode 100644 index 00000000..12e0179e --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/index.html @@ -0,0 +1,663 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
src/argv.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibmm/optionentry.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/argv.h
4missingIncludeSysteminformationInclude file: <glibmm/optiongroup.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/callbacks.cpp
21missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <giomm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/callbacks.h
24missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/cgroups.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <cstring> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27variableScope398styleThe scope of the variable 'paren_offset' can be reduced.
27variableScope398styleThe scope of the variable 'off' can be reduced.
27variableScope398styleThe scope of the variable 'tmp_size' can be reduced.
55cstyleCast398styleC-style pointer casting
src/cgroups.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/defaulttable.h
4missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibmm/refptr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glibmm/regex.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/disks.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <mntent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <giomm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <giomm/themedicon.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <glibtop/mountlist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <glibtop/fsusage.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
202redundantAssignment563styleVariable 'res' is reassigned a value before the old one has been used.
src/gsm_color_button.c
23missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <cairo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <librsvg/rsvg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
522constParameterPointer398styleParameter 'color' can be declared as pointer to const
648variableScope398styleThe scope of the variable 'color_chooser' can be reduced.
723constParameterCallback398styleParameter 'event' can be declared as pointer to const. However it seems that 'gsm_color_button_pressed' is a callback function, if 'event' is declared with const you might also need to cast function pointer(s).
src/gsm_color_button.h
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gdk/gdk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/iconthemewrapper.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <gtkmm/icontheme.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <giomm/error.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/iconthemewrapper.h
4missingIncludeSysteminformationInclude file: <glibmm/refptr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibmm/ustring.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <gtkmm/icontheme.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <gdkmm/pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/interface.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
452cstyleCast398styleC-style pointer casting
454cstyleCast398styleC-style pointer casting
src/interface.h
24missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/load-graph.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <gdkmm/pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <dirent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <glibtop.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
16missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <glibtop/mem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
18missingIncludeSysteminformationInclude file: <glibtop/swap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
19missingIncludeSysteminformationInclude file: <glibtop/netload.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
20missingIncludeSysteminformationInclude file: <glibtop/netlist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
21missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <algorithm> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41shadowVariable398styleLocal variable 'n' shadows outer variable
164shadowVariable398styleLocal variable 'i' shadows outer variable
836constParameterPointer398styleParameter 'graph' can be declared as pointer to const
842constParameterPointer398styleParameter 'graph' can be declared as pointer to const
848constParameterPointer398styleParameter 'graph' can be declared as pointer to const
src/load-graph.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36noExplicitConstructor398styleStruct 'LoadGraph' has a constructor with 1 argument that is not explicit.
src/lsof.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <gtkmm/messagedialog.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibmm/regex.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glibtop/procopenfiles.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <sys/wait.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <set> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <sstream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <iterator> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <glibmm/regex.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
164shadowVariable398styleLocal variable 'count' shadows outer variable
src/lsof.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/memmaps.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glibtop/procmap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibtop/mountlist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <map> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <sstream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <iomanip> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <stdexcept> not found. Please note: Cppcheck does not need standard library headers to get proper results.
269shadowVariable398styleLocal variable 'iter' shadows outer variable
src/memmaps.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/msm-resources.c
1missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9unusedStructMember563styleunion member 'Anonymous0::alignment' is never used.
9unusedStructMember563styleunion member 'Anonymous0::ptr' is never used.
src/openfiles.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibtop/procopenfiles.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <netdb.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <sys/socket.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <netinet/in.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <arpa/inet.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
73nullPointerRedundantCheck476warningEither the condition 'res' is redundant or there is possible null pointer dereference: res.
205shadowVariable398styleLocal variable 'openfiles' shadows outer variable
247variableScope398styleThe scope of the variable 'column' can be reduced.
248variableScope398styleThe scope of the variable 'cell' can be reduced.
src/openfiles.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/prettytable.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <libwnck/libwnck.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <dirent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <gdk-pixbuf/gdk-pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <glibtop/procstate.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <giomm/error.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <giomm/file.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
16missingIncludeSysteminformationInclude file: <glibmm/miscutils.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <iostream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
19missingIncludeSysteminformationInclude file: <vector> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/prettytable.h
6missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <gdk-pixbuf/gdk-pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <glibmm/refptr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <gdkmm/pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <giomm/filemonitor.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <map> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
18missingIncludeSysteminformationInclude file: <libwnck/libwnck.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_opened'
40unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_closed'
src/procactions.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <sys/time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <sys/resource.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procdialogs.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
294noExplicitConstructor398styleClass 'SpinButtonUpdater' has a constructor with 1 argument that is not explicit.
415shadowVariable398styleLocal variable 'column' shadows outer variable
475cstyleCast398styleC-style pointer casting
498cstyleCast398styleC-style pointer casting
513cstyleCast398styleC-style pointer casting
src/procdialogs.h
23missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman-app.cpp
1missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
2missingIncludeSysteminformationInclude file: <glibtop.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glibtop/close.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibtop/sysinfo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
348uninitMemberVar398warningMember variable 'ProcmanApp::procdata' is not initialized in the constructor.
src/procman-app.h
4missingIncludeSysteminformationInclude file: <gtkmm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman.cpp
21missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gtkmm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34uninitMemberVarPrivate398warningMember variable 'ProcData::uimanager' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::action_group' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::statusbar' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::loadavg' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::endprocessbutton' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::popup_menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::disk_list' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::notebook' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::config' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::selection' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::settings' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::app' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::frequency' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::smooth_refresh' is not initialized in the constructor.
112shadowVariable398styleLocal variable 'order' shadows outer variable
162shadowVariable398styleLocal variable 'order' shadows outer variable
src/procman.h
23missingIncludeSysteminformationInclude file: <glibmm/refptr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <cairo-gobject.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gdk-pixbuf/gdk-pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <map> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
103uninitMemberVar398warningMember variable 'MutableProcInfo::cgroup_name' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::unit' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::session' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::seat' is not initialized in the constructor.
173noExplicitConstructor398styleClass 'ProcInfo' has a constructor with 1 argument that is not explicit.
src/procman_gksu.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman_gksu.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman_pkexec.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman_pkexec.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procproperties.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glibtop/procmem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glibtop/procmap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glibtop/procstate.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
208variableScope398styleThe scope of the variable 'column' can be reduced.
209variableScope398styleThe scope of the variable 'cell' can be reduced.
src/procproperties.h
25missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/proctable.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <cairo-gobject.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gprintf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glibtop.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <glibtop/loadavg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <glibtop/proclist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <glibtop/procio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <glibtop/procstate.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <glibtop/procmem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <glibtop/procmap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <glibtop/proctime.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <glibtop/procuid.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <glibtop/procargs.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <glibtop/prockernel.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
40missingIncludeSysteminformationInclude file: <glibtop/mem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <glibtop/swap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
42missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
43missingIncludeSysteminformationInclude file: <pwd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
44missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
46missingIncludeSysteminformationInclude file: <set> not found. Please note: Cppcheck does not need standard library headers to get proper results.
47missingIncludeSysteminformationInclude file: <list> not found. Please note: Cppcheck does not need standard library headers to get proper results.
50missingIncludeSysteminformationInclude file: <systemd/sd-login.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
64missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
920shadowVariable398styleLocal variable 'arguments' shadows outer variable
929shadowVariable398styleLocal variable 'tooltip' shadows outer variable
1016shadowVariable398styleLocal variable 'it' shadows outer variable
1022shadowVariable398styleLocal variable 'it' shadows outer variable
1052constVariablePointer398styleVariable 'parent' can be declared as pointer to const
1068shadowVariable398styleLocal variable 'it' shadows outer variable
1073shadowVariable398styleLocal variable 'it' shadows outer variable
src/proctable.h
24missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/selection.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/selection.h
4missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <vector> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/selinux.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
21varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
src/selinux.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/settings-keys.h
4missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/smooth_refresh.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <glibtop.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <glibtop/proctime.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <algorithm> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/smooth_refresh.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
22noExplicitConstructor398styleClass 'SmoothRefresh' has a constructor with 1 argument that is not explicit.
src/sysinfo.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibmm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <libxml/parser.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <libxml/xpath.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <libxml/xpathInternals.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <glibtop/fsusage.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <glibtop/mountlist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <glibtop/mem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <glibtop/sysinfo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
18missingIncludeSysteminformationInclude file: <netdb.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
19missingIncludeSysteminformationInclude file: <sys/socket.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
20missingIncludeSysteminformationInclude file: <sys/wait.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
21missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
22missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <exception> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <vector> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <fstream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <sstream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <sys/utsname.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
126unusedPrivateFunction398styleUnused private function: 'SysInfo::get_os_type'
233cstyleCast398styleC-style pointer casting
343cstyleCast398styleC-style pointer casting
509uninitMemberVar398warningMember variable 'LSBSysInfo::lsb_fd' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::name' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::release' is not initialized in the constructor.
515missingOverridestyleThe function 'set_distro_labels' overrides a function in a base class but is not marked with a 'override' specifier.
570shadowVariable398styleLocal variable 'release' shadows outer variable
615unusedPrivateFunction398styleUnused private function: 'LSBSysInfo::sync_lsb_release'
626variableScope398styleThe scope of the variable 'codename' can be reduced.
626shadowVariable398styleLocal variable 'release' shadows outer variable
690stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
697stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
701stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
736variableScope398styleThe scope of the variable 'len' can be reduced.
738stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
1001unreadVariable563styleVariable 'table_count' is assigned a value that is never used.
src/util.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib/gprintf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <glibtop/proctime.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <glibtop/procstate.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <stddef.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <cstring> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/util.h
6missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
123constParameterPointer398styleParameter 'new_value' can be declared as pointer to const
tools/msm_execute_helper.c
1missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
2missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6constParameter398styleParameter 'argv' can be declared as const array
+
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/stats.html b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/stats.html new file mode 100644 index 00000000..a2e83e06 --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/stats.html @@ -0,0 +1,201 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+

Top 10 files for warning severity, total findings: 24
+   15  src/procman.cpp
+   4   src/procman.h
+   3   src/sysinfo.cpp
+   1   src/procman-app.cpp
+   1   src/openfiles.cpp
+

+

Top 10 files for portability severity, total findings: 1
+   1  src/selinux.cpp
+

+

Top 10 files for performance severity, total findings: 4
+   4  src/sysinfo.cpp
+

+

Top 10 files for style severity, total findings: 55
+   10  src/sysinfo.cpp
+   7   src/proctable.cpp
+   5   src/procdialogs.cpp
+   5   src/load-graph.cpp
+   4   src/cgroups.cpp
+   3   src/openfiles.cpp
+   3   src/gsm_color_button.c
+   2   src/procproperties.cpp
+   2   src/procman.cpp
+   2   src/prettytable.h
+

+

Top 10 files for information severity, total findings: 269
+   26  src/proctable.cpp
+   24  src/sysinfo.cpp
+   18  src/load-graph.cpp
+   14  src/prettytable.cpp
+   12  src/gsm_color_button.c
+   11  src/procman.h
+   11  src/lsof.cpp
+   10  src/util.cpp
+   10  src/memmaps.cpp
+   10  src/interface.cpp
+

+ +
+ +
+ + diff --git a/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/style.css b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/style.css new file mode 100644 index 00000000..3897bfaf --- /dev/null +++ b/2023-10-16-150621-7841-cppcheck@71c61020bc59_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2024-01-24-110103-6148-1@4d3102f305d3_master/index.html b/2024-01-24-110103-6148-1@4d3102f305d3_master/index.html new file mode 100644 index 00000000..71fc2c03 --- /dev/null +++ b/2024-01-24-110103-6148-1@4d3102f305d3_master/index.html @@ -0,0 +1,136 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@92d6d745c481
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 17.0.6 (Fedora 17.0.6-1.fc39) +
Date:Wed Jan 24 11:01:03 2024
+

Bug Summary

+ + + + + + + +
Bug TypeQuantityDisplay?
All Bugs14
Logic error
Use of identical expressions1
Unused code
Dead assignment1
Unreachable code12
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
Unused codeDead assignmentrootdir/src/disks.cppget_mount_opt2011View Report
Unused codeUnreachable coderootdir/src/procman-app.cppon_command_line3811View Report
Unused codeUnreachable coderootdir/src/util.cppio_rate_cell_data_func4941View Report
Unused codeUnreachable coderootdir/src/util.cppstatus_cell_data_func5911View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_gicon421View Report
Unused codeUnreachable coderootdir/src/util.cppduration_cell_data_func5351View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_na_cell_data_func3841View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_na_cell_data_func4561View Report
Unused codeUnreachable coderootdir/src/util.cppstorage_size_cell_data_func4221View Report
Unused codeUnreachable coderootdir/src/iconthemewrapper.cppload_icon131View Report
Unused codeUnreachable coderootdir/src/util.cpptime_cell_data_func5641View Report
Unused codeUnreachable coderootdir/src/procman-app.cpptimeouts_changed_cb1511View Report
Unused codeUnreachable coderootdir/src/util.cppmemory_size_cell_data_func3501View Report
Logic errorUse of identical expressionsusr/include/sigc++-2.0/sigc++/visit_each.hoperator()981View Report
+ + diff --git a/2024-01-24-110103-6148-1@4d3102f305d3_master/report-22e004.html b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-22e004.html new file mode 100644 index 00000000..378a2374 --- /dev/null +++ b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-22e004.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 381, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/librsvg-2.0 -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/pango-1.0 -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/cairo -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/blkid -I /usr/include/at-spi-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/pixman-1 -I /usr/include/fribidi -I /usr/include/sysprof-6 -I /usr/include/libpng16 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-01-24-110103-6148-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
This statement is never executed
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2024-01-24-110103-6148-1@4d3102f305d3_master/report-491eb3.html b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-491eb3.html new file mode 100644 index 00000000..b3bcaf32 --- /dev/null +++ b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-491eb3.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 494, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/librsvg-2.0 -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/pango-1.0 -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/cairo -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/blkid -I /usr/include/at-spi-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/pixman-1 -I /usr/include/fribidi -I /usr/include/sysprof-6 -I /usr/include/libpng16 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-01-24-110103-6148-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 78 > (61)) || (2 == (2
) && 78 == (61) && 3 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 78 > (61)) || (2 == (2
) && 78 == (61) && 3 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2024-01-24-110103-6148-1@4d3102f305d3_master/report-4d889d.html b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-4d889d.html new file mode 100644 index 00000000..5f36ddea --- /dev/null +++ b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-4d889d.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 591, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/librsvg-2.0 -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/pango-1.0 -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/cairo -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/blkid -I /usr/include/at-spi-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/pixman-1 -I /usr/include/fribidi -I /usr/include/sysprof-6 -I /usr/include/libpng16 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-01-24-110103-6148-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 78 > (61)) || (2 == (2
) && 78 == (61) && 3 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 78 > (61)) || (2 == (2
) && 78 == (61) && 3 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2024-01-24-110103-6148-1@4d3102f305d3_master/report-633ebf.html b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-633ebf.html new file mode 100644 index 00000000..cc5f60a1 --- /dev/null +++ b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-633ebf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 42, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/librsvg-2.0 -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/pango-1.0 -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/cairo -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/blkid -I /usr/include/at-spi-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/pixman-1 -I /usr/include/fribidi -I /usr/include/sysprof-6 -I /usr/include/libpng16 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-01-24-110103-6148-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
This statement is never executed
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2024-01-24-110103-6148-1@4d3102f305d3_master/report-6c54e6.html b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-6c54e6.html new file mode 100644 index 00000000..b2f4778f --- /dev/null +++ b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-6c54e6.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 535, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/librsvg-2.0 -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/pango-1.0 -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/cairo -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/blkid -I /usr/include/at-spi-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/pixman-1 -I /usr/include/fribidi -I /usr/include/sysprof-6 -I /usr/include/libpng16 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-01-24-110103-6148-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 78 > (61)) || (2 == (2
) && 78 == (61) && 3 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 78 > (61)) || (2 == (2
) && 78 == (61) && 3 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2024-01-24-110103-6148-1@4d3102f305d3_master/report-6c8186.html b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-6c8186.html new file mode 100644 index 00000000..66da4b62 --- /dev/null +++ b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-6c8186.html @@ -0,0 +1,886 @@ + + + +/usr/include/sigc++-2.0/sigc++/visit_each.h + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:usr/include/sigc++-2.0/sigc++/visit_each.h
Warning:line 98, column 64
identical expressions on both sides of logical operator
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/librsvg-2.0 -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/pango-1.0 -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/cairo -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/blkid -I /usr/include/at-spi-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/pixman-1 -I /usr/include/fribidi -I /usr/include/sysprof-6 -I /usr/include/libpng16 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-01-24-110103-6148-1 -x c++ procman.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright 2002, The libsigc++ Development Team
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18#ifndef _SIGC_VISIT_EACH_HPP_
19#define _SIGC_VISIT_EACH_HPP_
20
21#include <sigc++/type_traits.h>
22#include <type_traits>
23
24namespace sigc {
25
26#ifndef DOXYGEN_SHOULD_SKIP_THIS
27namespace internal {
28
29//This should really be an inner class of limit_derived_target, without the T_limit template type,
30//But the SUN CC 5.7 (not earlier versions) compiler finds it ambiguous when we specify a particular specialization of it.
31//and does not seem to allow us to tell it explicitly that it's an inner class.
32template <bool I_derived, class T_type, class T_limit>
33struct with_type;
34
35//Specialization for I_derived = false
36template <class T_type, class T_limit> struct
37with_type<false, T_type, T_limit>
38{
39 static void execute_(const T_type&, const T_limit&) {}
40};
41
42//Specialization for I_derived = true
43template <class T_type, class T_limit>
44struct with_type<true, T_type, T_limit>
45{
46 static void execute_(const T_type& _A_type, const T_limit& _A_action)
47 { _A_action.action_(_A_type); }
48};
49
50
51/// Helper struct for visit_each_type().
52template <class T_target, class T_action>
53struct limit_derived_target
54{
55 typedef limit_derived_target<T_target, T_action> T_self;
56
57 template <class T_type>
58 void operator()(const T_type& _A_type) const
59 {
60 with_type<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
61 }
62
63 limit_derived_target(const T_action& _A_action)
64 : action_(_A_action)
65 {}
66
67 T_action action_;
68};
69
70// Specialization for T_target pointer types, to provide a slightly different execute_() implementation.
71
72template <bool I_derived, class T_type, class T_limit>
73struct with_type_pointer;
74
75//Specialization for I_derived = false
76template <class T_type, class T_limit>
77struct with_type_pointer<false, T_type, T_limit>
78{
79 static void execute_(const T_type&, const T_limit&) {}
80};
81
82//Specialization for I_derived = true
83template <class T_type, class T_limit>
84struct with_type_pointer<true, T_type, T_limit>
85{
86 static void execute_(const T_type& _A_type, const T_limit& _A_action)
87 { _A_action.action_(&_A_type); }
88};
89
90template <class T_target, class T_action>
91struct limit_derived_target<T_target*, T_action>
92{
93 typedef limit_derived_target<T_target*, T_action> T_self;
94
95 template <class T_type>
96 void operator()(const T_type& _A_type) const
97 {
98 with_type_pointer<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value, T_type, T_self>::execute_(_A_type, *this);
identical expressions on both sides of logical operator
99 }
100
101 limit_derived_target(const T_action& _A_action)
102 : action_(_A_action)
103 {}
104
105 T_action action_;
106};
107
108} /* namespace internal */
109#endif // DOXYGEN_SHOULD_SKIP_THIS
110
111// struct visitor was introduced as a result of https://bugzilla.gnome.org/show_bug.cgi?id=724496
112// The advantage of using specializations of a template struct instead of overloads of
113// a template function is described by Herb Sutter in http://www.gotw.ca/publications/mill17.htm
114// In libsigc++ the main reason for using this technique is that we can avoid using ADL
115// (argument-dependent lookup), and therefore there is no risk that a visit_each() overload
116// in e.g. Boost is selected by mistake.
117
118/** sigc::visitor<T_functor>::do_visit_each() performs a functor on each of the targets of a functor.
119 * All unknown types just call @a _A_action on them.
120 * Add specializations that specialize the @a T_functor argument for your own
121 * functor types, so that subobjects get visited. This is needed to enable
122 * auto-disconnection support for your functor types.
123 *
124 * @par Example:
125 * @code
126 * namespace some_ns
127 * {
128 * struct some_functor
129 * {
130 * void operator()() {}
131 * some_possibly_sigc_trackable_derived_type some_data_member;
132 * some_other_functor_type some_other_functor;
133 * };
134 * }
135 *
136 * namespace sigc
137 * {
138 * template <>
139 * struct visitor<some_ns::some_functor>
140 * {
141 * template <class T_action>
142 * static void do_visit_each(const T_action& _A_action,
143 * const some_ns::some_functor& _A_target)
144 * {
145 * sigc::visit_each(_A_action, _A_target.some_data_member);
146 * sigc::visit_each(_A_action, _A_target.some_other_functor);
147 * }
148 * };
149 * }
150 * @endcode
151 *
152 * @ingroup sigcfunctors
153 */
154template <class T_functor>
155struct visitor
156{
157 template <class T_action>
158 static void do_visit_each(const T_action& _A_action, const T_functor& _A_functor)
159 {
160 _A_action(_A_functor);
161 }
162};
163
164/** This function performs a functor on each of the targets of a functor.
165 *
166 * @ingroup sigcfunctors
167 */
168template <class T_action, class T_functor>
169void visit_each(const T_action& _A_action, const T_functor& _A_functor)
170{ sigc::visitor<T_functor>::do_visit_each(_A_action, _A_functor); }
171
172/** This function performs a functor on each of the targets
173 * of a functor limited to a restricted type.
174 *
175 * @ingroup sigcfunctors
176 */
177template <class T_type, class T_action, class T_functor>
178void visit_each_type(const T_action& _A_action, const T_functor& _A_functor)
179{
180 typedef internal::limit_derived_target<T_type, T_action> type_limited_action;
181
182 type_limited_action limited_action(_A_action);
183
184 //specifying the types of the template specialization prevents disconnection of bound trackable references (such as with std::ref()),
185 //probably because the visit_each<> specializations take various different template types,
186 //in various sequences, and we are probably specifying only a subset of them with this.
187 //
188 //But this is required by the AIX (and maybe IRIX MipsPro and Tru64) compilers.
189 //I guess that std::ref() therefore does not work on those platforms. murrayc
190 // sigc::visit_each<type_limited_action, T_functor>(limited_action, _A_functor);
191
192 //g++ (even slightly old ones) is our primary platform, so we could use the non-crashing version.
193 //However, the explicit version also fixes a crash in a slightly more common case: http://bugzilla.gnome.org/show_bug.cgi?id=169225
194 //Users (and distributors) of libsigc++ on AIX (and maybe IRIX MipsPro and Tru64) do
195 //need to use the version above instead, to allow compilation.
196
197 //Added 2014-03-20: The preceding comment probably does not apply any more,
198 //now when the visit_each<>() overloads have been replaced by visitor<> specializations.
199 //It's probably safe to add explicit template parameters on calls to visit_each(),
200 //visit_each_type() and visitor::do_visit_each(), if necessary.
201
202 sigc::visit_each(limited_action, _A_functor);
203}
204
205} /* namespace sigc */
206#endif
diff --git a/2024-01-24-110103-6148-1@4d3102f305d3_master/report-77634b.html b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-77634b.html new file mode 100644 index 00000000..1952897a --- /dev/null +++ b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-77634b.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 384, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/librsvg-2.0 -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/pango-1.0 -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/cairo -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/blkid -I /usr/include/at-spi-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/pixman-1 -I /usr/include/fribidi -I /usr/include/sysprof-6 -I /usr/include/libpng16 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-01-24-110103-6148-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 78 > (61)) || (2 == (2
) && 78 == (61) && 3 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 78 > (61)) || (2 == (2
) && 78 == (61) && 3 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2024-01-24-110103-6148-1@4d3102f305d3_master/report-7bbc8c.html b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-7bbc8c.html new file mode 100644 index 00000000..5c20c1c7 --- /dev/null +++ b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-7bbc8c.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 456, column 15
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/librsvg-2.0 -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/pango-1.0 -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/cairo -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/blkid -I /usr/include/at-spi-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/pixman-1 -I /usr/include/fribidi -I /usr/include/sysprof-6 -I /usr/include/libpng16 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-01-24-110103-6148-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 78 > (61)) || (2 == (2
) && 78 == (61) && 3 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 78 > (61)) || (2 == (2
) && 78 == (61) && 3 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2024-01-24-110103-6148-1@4d3102f305d3_master/report-7ce786.html b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-7ce786.html new file mode 100644 index 00000000..76e48a0c --- /dev/null +++ b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-7ce786.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 422, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/librsvg-2.0 -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/pango-1.0 -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/cairo -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/blkid -I /usr/include/at-spi-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/pixman-1 -I /usr/include/fribidi -I /usr/include/sysprof-6 -I /usr/include/libpng16 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-01-24-110103-6148-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 78 > (61)) || (2 == (2
) && 78 == (61) && 3 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 78 > (61)) || (2 == (2
) && 78 == (61) && 3 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2024-01-24-110103-6148-1@4d3102f305d3_master/report-802eaf.html b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-802eaf.html new file mode 100644 index 00000000..e93b4518 --- /dev/null +++ b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-802eaf.html @@ -0,0 +1,737 @@ + + + +iconthemewrapper.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/iconthemewrapper.cpp
Warning:line 13, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name iconthemewrapper.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/librsvg-2.0 -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/pango-1.0 -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/cairo -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/blkid -I /usr/include/at-spi-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/pixman-1 -I /usr/include/fribidi -I /usr/include/sysprof-6 -I /usr/include/libpng16 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-01-24-110103-6148-1 -x c++ iconthemewrapper.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <gtkmm/icontheme.h>
4#include <giomm/error.h>
5
6#include "iconthemewrapper.h"
7
8
9Glib::RefPtr<Gdk::Pixbuf>
10procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
11{
12 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
13 try
This statement is never executed
14 {
15 return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
16 }
17 catch (Gtk::IconThemeError &error)
18 {
19 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
20 g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
21 return Glib::RefPtr<Gdk::Pixbuf>();
22 }
23 catch (Gio::Error &error)
24 {
25 g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
26 return Glib::RefPtr<Gdk::Pixbuf>();
27 }
28}
29
30Glib::RefPtr<Gdk::Pixbuf>
31procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
32 int size, Gtk::IconLookupFlags flags) const
33{
34 Gtk::IconInfo icon_info;
35 gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
36 icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
37
38 if (!icon_info) {
39 return Glib::RefPtr<Gdk::Pixbuf>();
40 }
41
42 try
43 {
44 return icon_info.load_icon();
45 }
46 catch (Gtk::IconThemeError &error)
47 {
48 if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
49 g_error("Cannot load gicon from theme: %s", error.what().c_str());
50 return Glib::RefPtr<Gdk::Pixbuf>();
51 }
52 catch (Gio::Error &error)
53 {
54 g_debug("Could not load gicon: %s", error.what().c_str());
55 return Glib::RefPtr<Gdk::Pixbuf>();
56 }
57}
diff --git a/2024-01-24-110103-6148-1@4d3102f305d3_master/report-8e6c9c.html b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-8e6c9c.html new file mode 100644 index 00000000..37802391 --- /dev/null +++ b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-8e6c9c.html @@ -0,0 +1,1200 @@ + + + +disks.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/disks.cpp
Warning:line 201, column 13
Value stored to 'res' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name disks.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/librsvg-2.0 -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/pango-1.0 -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/cairo -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/blkid -I /usr/include/at-spi-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/pixman-1 -I /usr/include/fribidi -I /usr/include/sysprof-6 -I /usr/include/libpng16 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-01-24-110103-6148-1 -x c++ disks.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#ifdef __linux__1
4#include <mntent.h>
5#endif // __linux__
6
7#include <giomm.h>
8#include <giomm/themedicon.h>
9#include <gtk/gtk.h>
10#include <glibtop/mountlist.h>
11#include <glibtop/fsusage.h>
12#include <glib/gi18n.h>
13
14#include "procman.h"
15#include "disks.h"
16#include "util.h"
17#include "interface.h"
18#include "iconthemewrapper.h"
19
20namespace
21{
22 const unsigned DISK_ICON_SIZE = 24;
23}
24
25enum DiskColumns
26{
27 /* string columns* */
28 DISK_DEVICE,
29 DISK_DIR,
30 DISK_TYPE,
31 DISK_SUBVOLUME,
32 DISK_TOTAL,
33 DISK_FREE,
34 DISK_AVAIL,
35 /* USED has to be the last column */
36 DISK_USED,
37 // then unvisible columns
38 /* Surface column */
39 DISK_ICON,
40 /* numeric columns */
41 DISK_USED_PERCENTAGE,
42 DISK_N_COLUMNS
43};
44
45
46
47static void
48fsusage_stats(const glibtop_fsusage *buf,
49 guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
50 gint *percentage)
51{
52 guint64 total = buf->blocks * buf->block_size;
53
54 if (!total) {
55 /* not a real device */
56 *btotal = *bfree = *bavail = *bused = 0ULL;
57 *percentage = 0;
58 } else {
59 int percent;
60 *btotal = total;
61 *bfree = buf->bfree * buf->block_size;
62 *bavail = buf->bavail * buf->block_size;
63 *bused = *btotal - *bfree;
64 /* percent = 100.0f * *bused / *btotal; */
65 percent = 100 * *bused / (*bused + *bavail);
66 *percentage = CLAMP(percent, 0, 100)(((percent) > (100)) ? (100) : (((percent) < (0)) ? (0)
: (percent)))
;
67 }
68}
69
70
71namespace
72{
73 string get_icon_for_path(const std::string& path)
74 {
75 using namespace Glib;
76 using namespace Gio;
77
78 // FIXME: I don't know whether i should use Volume or Mount or UnixMount
79 // all i need an icon name.
80 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
81
82 std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
83
84 for (size_t i = 0; i != mounts.size(); ++i) {
85 if (mounts[i]->get_name() != path)
86 continue;
87
88 RefPtr<Icon> icon = mounts[i]->get_icon();
89 RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
90
91 if (themed_icon) {
92 char* name = 0;
93 // FIXME: not wrapped yet
94 g_object_get(G_OBJECT(themed_icon->gobj())((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((themed_icon->gobj())), (((GType) ((20) << (2)))
)))))
, "name", &name, NULL__null);
95 return make_string(name);
96 }
97 }
98
99 return "";
100 }
101}
102
103
104static Glib::RefPtr<Gdk::Pixbuf>
105get_icon_for_device(const char *mountpoint)
106{
107 procman::IconThemeWrapper icon_theme;
108 string icon_name = get_icon_for_path(mountpoint);
109 if (icon_name == "")
110 // FIXME: defaults to a safe value
111 icon_name = "drive-harddisk"; // get_icon_for_path("/");
112 return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
113}
114
115
116static gboolean
117find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
118 GtkTreeIter *result)
119{
120 GtkTreeIter iter;
121 gboolean found = FALSE(0);
122
123 if (gtk_tree_model_get_iter_first(model, &iter)) {
124 do {
125 char *dir;
126
127 gtk_tree_model_get(model, &iter,
128 DISK_DIR, &dir,
129 -1);
130
131 if (dir && !strcmp(dir, mountpoint)) {
132 *result = iter;
133 found = TRUE(!(0));
134 }
135
136 g_free(dir);
137
138 } while (!found && gtk_tree_model_iter_next(model, &iter));
139 }
140
141 return found;
142}
143
144
145
146static void
147remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
148{
149 GtkTreeIter iter;
150
151 if (!gtk_tree_model_get_iter_first(model, &iter))
152 return;
153
154 while (true) {
155 char *dir;
156 guint i;
157 gboolean found = FALSE(0);
158
159 gtk_tree_model_get(model, &iter,
160 DISK_DIR, &dir,
161 -1);
162
163 for (i = 0; i != n; ++i) {
164 if (!strcmp(dir, entries[i].mountdir)) {
165 found = TRUE(!(0));
166 break;
167 }
168 }
169
170 g_free(dir);
171
172 if (!found) {
173 if (!gtk_list_store_remove(GTK_LIST_STORE(model)((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_list_store_get_type ()))))))
, &iter))
174 break;
175 else
176 continue;
177 }
178
179 if (!gtk_tree_model_iter_next(model, &iter))
180 break;
181 }
182}
183
184#ifdef __linux__1
185static char *
186get_mount_opt(const glibtop_mountentry *entry, const char* opt)
187{
188 char *opt_value = NULL__null;
189 const struct mntent *mnt;
190 FILE *fp;
191
192 if (!(fp = setmntent(MOUNTED"/etc/mtab", "r"))) {
193 goto out;
194 }
195
196 while ((mnt = getmntent(fp))) {
197 if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
198 (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
199 char *res;
200
201 res = hasmntopt(mnt, "subvol");
Value stored to 'res' is never read
202 if ((res = hasmntopt(mnt, "subvol")) != NULL__null) {
203 char **strs = g_strsplit_set(res, "=", 2);
204
205 if (g_strv_length(strs) == 2) {
206 char *value = strs[1];
207 if (g_strcmp0 (value,"/root") == 0)
208 opt_value = g_strdup("/")g_strdup_inline ("/");
209 else
210 opt_value = g_strdup(strs[1])g_strdup_inline (strs[1]);
211 g_strfreev(strs);
212 }
213 }
214 break;
215 }
216 }
217
218 endmntent(fp);
219
220 out:
221 return opt_value;
222}
223#endif // __linux__
224
225
226static void
227add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
228{
229 Glib::RefPtr<Gdk::Pixbuf> pixbuf;
230 cairo_surface_t *surface;
231 GtkTreeIter iter;
232 glibtop_fsusage usage;
233 guint64 bused, bfree, bavail, btotal;
234 gint percentage;
235#ifdef __linux__1
236 char *subvol = NULL__null;
237#endif // __linux__
238
239 glibtop_get_fsusage(&usage, entry->mountdir);
240
241 if (not show_all_fs and usage.blocks == 0) {
242 if (find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
243 gtk_list_store_remove(list, &iter);
244 return;
245 }
246
247 fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
248#ifdef __linux__1
249 subvol = get_mount_opt(entry, "subvol");
250#endif // __linux__
251 pixbuf = get_icon_for_device(entry->mountdir);
252 surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL__null);
253
254 /* if we can find a row with the same mountpoint, we get it but we
255 still need to update all the fields.
256 This makes selection persistent.
257 */
258 if (!find_disk_in_model(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entry->mountdir, &iter))
259 gtk_list_store_append(list, &iter);
260
261 gtk_list_store_set(list, &iter,
262 DISK_ICON, surface,
263 DISK_DEVICE, entry->devname,
264 DISK_DIR, entry->mountdir,
265 DISK_TYPE, entry->type,
266#ifdef __linux__1
267
268 DISK_SUBVOLUME, subvol != NULL__null ? subvol : "",
269#else
270 DISK_SUBVOLUME, "",
271#endif // __linux__
272 DISK_USED_PERCENTAGE, percentage,
273 DISK_TOTAL, btotal,
274 DISK_FREE, bfree,
275 DISK_AVAIL, bavail,
276 DISK_USED, bused,
277 -1);
278#ifdef __linux__1
279 g_free (subvol);
280#endif // __linux__
281}
282
283
284
285int
286cb_update_disks(gpointer data)
287{
288 ProcData *const procdata = static_cast<ProcData*>(data);
289
290 GtkListStore *list;
291 glibtop_mountentry * entries;
292 glibtop_mountlist mountlist;
293 guint i;
294
295 list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)))((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_tree_view_get_model(((((GtkTreeView*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((procdata->disk_list)), ((gtk_tree_view_get_type
()))))))))), ((gtk_list_store_get_type ()))))))
;
296
297 entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
298
299 remove_old_disks(GTK_TREE_MODEL(list)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list)), ((gtk_tree_model_get_type ()))))))
, entries, mountlist.number);
300
301 for (i = 0; i < mountlist.number; i++)
302 add_disk(list, &entries[i], procdata->config.show_all_fs);
303
304 g_free(entries);
305
306 return TRUE(!(0));
307}
308
309
310static void
311cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
312{
313 ProcData * const procdata = static_cast<ProcData*>(user_data);
314
315 procman_save_tree_state(procdata->settings,
316 GTK_WIDGET(treeview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_widget_get_type ()))))))
,
317 "disktreenew");
318}
319
320
321static void
322open_dir(GtkTreeView *tree_view,
323 GtkTreePath *path,
324 GtkTreeViewColumn *column,
325 gpointer user_data)
326{
327 GtkTreeIter iter;
328 GtkTreeModel *model;
329 char *dir, *url;
330
331 model = gtk_tree_view_get_model(tree_view);
332
333 if (!gtk_tree_model_get_iter(model, &iter, path)) {
334 char *p;
335 p = gtk_tree_path_to_string(path);
336 g_warning("Cannot get iter for path '%s'\n", p);
337 g_free(p);
338 return;
339 }
340
341 gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
342
343 url = g_strdup_printf("file://%s", dir);
344
345 GError* error = 0;
346 if (!g_app_info_launch_default_for_uri(url, NULL__null, &error)) {
347 g_warning("Cannot open '%s' : %s\n", url, error->message);
348 g_error_free(error);
349 }
350
351 g_free(url);
352 g_free(dir);
353}
354
355static guint timeout_id = 0;
356static GtkTreeViewColumn *current_column;
357
358static gboolean
359save_column_width (gpointer data)
360{
361 gint width;
362 gchar *key;
363 int id;
364 GSettings *settings;
365
366 settings = g_settings_get_child (G_SETTINGS (data)((((GSettings*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((g_settings_get_type ()))))))
, "disktreenew");
367 id = gtk_tree_view_column_get_sort_column_id (current_column);
368 width = gtk_tree_view_column_get_width (current_column);
369
370 key = g_strdup_printf ("col-%d-width", id);
371 g_settings_set_int(settings, key, width);
372 g_free (key);
373
374 if (timeout_id) {
375 g_source_remove (timeout_id);
376 timeout_id = 0;
377 }
378
379 return FALSE(0);
380}
381
382static void
383cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
384{
385 current_column = GTK_TREE_VIEW_COLUMN(widget)((((GtkTreeViewColumn*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((widget)), ((gtk_tree_view_column_get_type (
)))))))
;
386
387 if (timeout_id)
388 g_source_remove (timeout_id);
389
390 timeout_id = g_timeout_add (250, save_column_width, data);
391}
392
393void
394create_disk_view(ProcData *procdata, GtkBuilder *builder)
395{
396 GtkWidget *scrolled;
397 GtkWidget *disk_tree;
398 GtkListStore *model;
399 GtkTreeViewColumn *col;
400 GtkCellRenderer *cell;
401 guint i;
402
403 const gchar * const titles[] = {
404 N_("Device")("Device"),
405 N_("Directory")("Directory"),
406 N_("Type")("Type"),
407 N_("SubVolume")("SubVolume"),
408 N_("Total")("Total"),
409 N_("Free")("Free"),
410 N_("Available")("Available"),
411 N_("Used")("Used")
412 };
413
414 scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "disks_scrolled"))), ((
gtk_widget_get_type ()))))))
;
415
416 model = gtk_list_store_new(DISK_N_COLUMNS, /* n columns */
417 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DEVICE */
418 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_DIR */
419 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_TYPE */
420 G_TYPE_STRING((GType) ((16) << (2))), /* DISK_SUBVOLUME */
421 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_TOTAL */
422 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_FREE */
423 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_AVAIL */
424 G_TYPE_UINT64((GType) ((11) << (2))), /* DISK_USED */
425 CAIRO_GOBJECT_TYPE_SURFACEcairo_gobject_surface_get_type (), /* DISK_ICON */
426 G_TYPE_INT((GType) ((6) << (2)))); /* DISK_USED_PERCENTAGE */
427
428 disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_model_get_type ()))))))
);
429 g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("row-activated"), (((GCallback) (open_dir))), (__null
), __null, (GConnectFlags) 0)
;
430 procdata->disk_list = disk_tree;
431 gtk_container_add(GTK_CONTAINER(scrolled)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((scrolled)), ((gtk_container_get_type ()))))))
, disk_tree);
432 g_object_unref(G_OBJECT(model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
);
433
434 /* icon + device */
435
436 col = gtk_tree_view_column_new();
437 cell = gtk_cell_renderer_pixbuf_new();
438 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
439 gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
440 NULL__null);
441
442 cell = gtk_cell_renderer_text_new();
443 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
444 gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
445 NULL__null);
446 gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE])gettext (titles[DISK_DEVICE]));
447 gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
448 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
449 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
450 gtk_tree_view_column_set_min_width (col, 30);
451 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
452 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
453 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
454
455 /* sizes - used */
456
457 for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
458 cell = gtk_cell_renderer_text_new();
459 col = gtk_tree_view_column_new();
460 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
461 gtk_tree_view_column_set_title(col, _(titles[i])gettext (titles[i]));
462 gtk_tree_view_column_set_sort_column_id(col, i);
463 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
464 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
465 gtk_tree_view_column_set_min_width (col, 30);
466 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
467 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
468 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
469
470 switch (i) {
471 case DISK_TOTAL:
472 case DISK_FREE:
473 case DISK_AVAIL:
474 g_object_set(cell, "xalign", 1.0f, NULL__null);
475 gtk_tree_view_column_set_cell_data_func(col, cell,
476 &procman::storage_size_cell_data_func,
477 GUINT_TO_POINTER(i)((gpointer) (gulong) (i)),
478 NULL__null);
479 break;
480
481 default:
482 gtk_tree_view_column_set_attributes(col, cell,
483 "text", i,
484 NULL__null);
485 break;
486 }
487 }
488
489 /* used + percentage */
490
491 col = gtk_tree_view_column_new();
492 cell = gtk_cell_renderer_text_new();
493 g_object_set(cell, "xalign", 1.0f, NULL__null);
494 gtk_tree_view_column_pack_start(col, cell, FALSE(0));
495 gtk_tree_view_column_set_cell_data_func(col, cell,
496 &procman::storage_size_cell_data_func,
497 GUINT_TO_POINTER(DISK_USED)((gpointer) (gulong) (DISK_USED)),
498 NULL__null);
499
500 cell = gtk_cell_renderer_progress_new();
501 gtk_tree_view_column_pack_start(col, cell, TRUE(!(0)));
502 gtk_tree_view_column_set_attributes(col, cell, "value",
503 DISK_USED_PERCENTAGE, NULL__null);
504 gtk_tree_view_column_set_title(col, _(titles[DISK_USED])gettext (titles[DISK_USED]));
505 gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
506 gtk_tree_view_column_set_reorderable(col, TRUE(!(0)));
507 gtk_tree_view_column_set_resizable(col, TRUE(!(0)));
508 gtk_tree_view_column_set_min_width (col, 150);
509 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
510 g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((col)), (((GType) ((20) << (2))))))
))), ("notify::fixed-width"), (((GCallback) (cb_disks_column_resized
))), (procdata->settings), __null, (GConnectFlags) 0)
;
511 gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((disk_tree)), ((gtk_tree_view_get_type ()))))))
, col);
512
513 /* numeric sort */
514
515 procman_get_tree_state(procdata->settings, disk_tree,
516 "disktreenew");
517
518 g_signal_connect (G_OBJECT(disk_tree), "columns-changed",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
519 G_CALLBACK(cb_disk_columns_changed), procdata)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((disk_tree)), (((GType) ((20) << (2
))))))))), ("columns-changed"), (((GCallback) (cb_disk_columns_changed
))), (procdata), __null, (GConnectFlags) 0)
;
520}
diff --git a/2024-01-24-110103-6148-1@4d3102f305d3_master/report-c673b5.html b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-c673b5.html new file mode 100644 index 00000000..02f817ed --- /dev/null +++ b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-c673b5.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 564, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/librsvg-2.0 -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/pango-1.0 -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/cairo -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/blkid -I /usr/include/at-spi-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/pixman-1 -I /usr/include/fribidi -I /usr/include/sysprof-6 -I /usr/include/libpng16 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-01-24-110103-6148-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 78 > (61)) || (2 == (2
) && 78 == (61) && 3 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 78 > (61)) || (2 == (2
) && 78 == (61) && 3 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2024-01-24-110103-6148-1@4d3102f305d3_master/report-d507c5.html b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-d507c5.html new file mode 100644 index 00000000..912e8352 --- /dev/null +++ b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-d507c5.html @@ -0,0 +1,1116 @@ + + + +procman-app.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/procman-app.cpp
Warning:line 151, column 9
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name procman-app.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/librsvg-2.0 -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/pango-1.0 -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/cairo -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/blkid -I /usr/include/at-spi-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/pixman-1 -I /usr/include/fribidi -I /usr/include/sysprof-6 -I /usr/include/libpng16 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-01-24-110103-6148-1 -x c++ procman-app.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <glib/gi18n.h>
2#include <glibtop.h>
3#include <glibtop/close.h>
4#include <glibtop/cpu.h>
5#include <glibtop/sysinfo.h>
6
7#include "procman-app.h"
8#include "procman.h"
9#include "interface.h"
10#include "proctable.h"
11#include "callbacks.h"
12#include "load-graph.h"
13#include "settings-keys.h"
14#include "argv.h"
15#include "util.h"
16
17static void
18mount_changed(const Glib::RefPtr<Gio::Mount>&)
19{
20 cb_update_disks(ProcData::get_instance());
21}
22
23
24static void
25init_volume_monitor(ProcData *procdata)
26{
27 using namespace Gio;
28 using namespace Glib;
29
30 RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
31
32 monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
33 monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
34 monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
35}
36
37static gboolean
38has_key (gchar **keys, const gchar *key)
39{
40 gchar **loop = keys;
41
42 while (*loop) {
43 if (!strcmp (*loop++, key))
44 return TRUE(!(0));
45 }
46
47 return FALSE(0);
48}
49
50static void
51tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
52{
53 ProcData *procdata = static_cast<ProcData*>(data);
54
55 procdata->config.show_tree = g_settings_get_boolean(settings, key);
56
57 g_object_set(G_OBJECT(procdata->tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->tree)), (((GType) ((20) << (2))))))))
,
58 "show-expanders", procdata->config.show_tree,
59 NULL__null);
60
61 proctable_clear_tree (procdata);
62 proctable_update (procdata);
63}
64
65static void
66solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
67{
68 ProcData *procdata = static_cast<ProcData*>(data);
69
70 procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
71 proctable_update (procdata);
72}
73
74
75static void
76network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
77{
78 ProcData *procdata = static_cast<ProcData*>(data);
79
80 procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
81 // force scale to be redrawn
82 procdata->net_graph->clear_background();
83}
84
85static void
86view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
87{
88 ProcData *procdata = static_cast<ProcData*>(data);
89
90 procdata->config.whose_process = g_settings_get_int (settings, key);
91 procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2)(((procdata->config.whose_process) > (2)) ? (2) : (((procdata
->config.whose_process) < (0)) ? (0) : (procdata->config
.whose_process)))
;
92 proctable_clear_tree (procdata);
93 proctable_update (procdata);
94}
95
96static void
97warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
98{
99 ProcData *procdata = static_cast<ProcData*>(data);
100
101 if (g_str_equal (key, "kill-dialog")(strcmp ((const char *) (key), (const char *) ("kill-dialog")
) == 0)
) {
102 procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
103 }
104}
105
106static void
107timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
108{
109 ProcData *procdata = static_cast<ProcData*>(data);
110
111 if (g_str_equal (key, "update-interval")(strcmp ((const char *) (key), (const char *) ("update-interval"
)) == 0)
) {
112 procdata->config.update_interval = g_settings_get_int (settings, key);
113 procdata->config.update_interval =
114 MAX (procdata->config.update_interval, 1000)(((procdata->config.update_interval) > (1000)) ? (procdata
->config.update_interval) : (1000))
;
115
116 procdata->smooth_refresh->reset();
117
118 if(procdata->timeout) {
119 g_source_remove (procdata->timeout);
120 procdata->timeout = g_timeout_add (procdata->config.update_interval,
121 cb_timeout,
122 procdata);
123 }
124 }
125 else if (g_str_equal (key, "graph-update-interval")(strcmp ((const char *) (key), (const char *) ("graph-update-interval"
)) == 0)
){
126 procdata->config.graph_update_interval = g_settings_get_int (settings, key);
127 procdata->config.graph_update_interval =
128 MAX (procdata->config.graph_update_interval,(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
129 250)(((procdata->config.graph_update_interval) > (250)) ? (
procdata->config.graph_update_interval) : (250))
;
130 load_graph_change_speed(procdata->cpu_graph,
131 procdata->config.graph_update_interval);
132 load_graph_change_speed(procdata->mem_graph,
133 procdata->config.graph_update_interval);
134 load_graph_change_speed(procdata->net_graph,
135 procdata->config.graph_update_interval);
136 }
137 else if (g_str_equal(key, "disks-interval")(strcmp ((const char *) (key), (const char *) ("disks-interval"
)) == 0)
) {
138 procdata->config.disks_update_interval = g_settings_get_int (settings, key);
139 procdata->config.disks_update_interval =
140 MAX (procdata->config.disks_update_interval, 1000)(((procdata->config.disks_update_interval) > (1000)) ? (
procdata->config.disks_update_interval) : (1000))
;
141
142 if(procdata->disk_timeout) {
143 g_source_remove (procdata->disk_timeout);
144 procdata->disk_timeout = \
145 g_timeout_add (procdata->config.disks_update_interval,
146 cb_update_disks,
147 procdata);
148 }
149 }
150 else {
151 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 151, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
This statement is never executed
152 }
153}
154
155static void
156color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
157{
158 ProcData * const procdata = static_cast<ProcData*>(data);
159 gchar *color = g_settings_get_string (settings, key);
160
161 if (g_str_has_prefix (key, "cpu-color")(__builtin_constant_p ("cpu-color")? __extension__ ({ const char
* const __str = (key); const char * const __prefix = ("cpu-color"
); gboolean __result = (0); if (__str == __null || __prefix ==
__null) __result = (g_str_has_prefix) (__str, __prefix); else
{ const size_t __str_len = strlen (((__str) + !(__str))); const
size_t __prefix_len = strlen (((__prefix) + !(__prefix))); if
(__str_len >= __prefix_len) __result = memcmp (((__str) +
!(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0; }
__result; }) : (g_str_has_prefix) (key, "cpu-color") )
) {
162 for (int i = 0; i < procdata->config.num_cpus; i++) {
163 string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
164 if (cpu_key == key) {
165 gdk_rgba_parse (&procdata->config.cpu_color[i], color);
166 procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
167 break;
168 }
169 }
170 }
171 else if (g_str_equal (key, "mem-color")(strcmp ((const char *) (key), (const char *) ("mem-color")) ==
0)
) {
172 gdk_rgba_parse (&procdata->config.mem_color, color);
173 procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
174 }
175 else if (g_str_equal (key, "swap-color")(strcmp ((const char *) (key), (const char *) ("swap-color"))
== 0)
) {
176 gdk_rgba_parse (&procdata->config.swap_color, color);
177 procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
178 }
179 else if (g_str_equal (key, "net-in-color")(strcmp ((const char *) (key), (const char *) ("net-in-color"
)) == 0)
) {
180 gdk_rgba_parse (&procdata->config.net_in_color, color);
181 procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
182 }
183 else if (g_str_equal (key, "net-out-color")(strcmp ((const char *) (key), (const char *) ("net-out-color"
)) == 0)
) {
184 gdk_rgba_parse (&procdata->config.net_out_color, color);
185 procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
186 }
187 else {
188 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "procman-app.cpp"
, 188, ((const char*) (__PRETTY_FUNCTION__)), __null); } while
(0)
;
189 }
190 g_free(color);
191}
192
193static void
194show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
195{
196 ProcData * const procdata = static_cast<ProcData*>(data);
197
198 procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
199
200 cb_update_disks (data);
201}
202
203static ProcData *
204procman_data_new (GSettings *settings)
205{
206 GSettingsSchema *schema;
207 ProcData *pd;
208 gchar *color;
209 gchar **keys;
210 glibtop_cpu cpu;
211
212 pd = ProcData::get_instance();
213
214 g_settings_get (settings, "window-state", "(iiii)",
215 &pd->config.width, &pd->config.height,
216 &pd->config.xpos, &pd->config.ypos);
217
218 pd->config.maximized = g_settings_get_boolean(settings, "maximized");
219
220 pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
221 g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::show-tree"), (((GCallback) (tree_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
222
223 pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
224 std::string detail_string("changed::" + procman::settings::solaris_mode);
225 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (solaris_mode_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
226
227 pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
228 detail_string = "changed::" + procman::settings::network_in_bits;
229 g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (network_in_bits_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
230
231 pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
232 g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::kill-dialog"), (((GCallback) (warning_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
233 pd->config.update_interval = g_settings_get_int (settings, "update-interval");
234 g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::update-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
235 pd->config.graph_update_interval = g_settings_get_int (settings,
236 "graph-update-interval");
237 g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
238 G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::graph-update-interval"), (((GCallback) (
timeouts_changed_cb))), (pd), __null, (GConnectFlags) 0)
;
239 pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
240 g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::disks-interval"), (((GCallback) (timeouts_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
241
242
243 /* show_all_fs */
244 pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
245 g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd)g_signal_connect_data ((settings), ("changed::show-all-fs"), (
((GCallback) (show_all_fs_changed_cb))), (pd), __null, (GConnectFlags
) 0)
;
246
247
248 pd->config.whose_process = g_settings_get_int (settings, "view-as");
249 g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::view-as"), (((GCallback) (view_as_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
250 pd->config.current_tab = g_settings_get_int (settings, "current-tab");
251
252 glibtop_get_cpu (&cpu);
253 pd->frequency = cpu.frequency;
254 pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
255
256 g_object_get (settings, "settings-schema", &schema, NULL__null);
257 keys = g_settings_schema_list_keys (schema);
258 g_settings_schema_unref (schema);
259
260 for (int i = 0; i < pd->config.num_cpus; i++) {
261 gchar *key;
262 key = g_strdup_printf ("cpu-color%d", i);
263
264 if (has_key (keys, key))
265 color = g_settings_get_string (settings, key);
266 else
267 color = g_strdup ("#f25915e815e8")g_strdup_inline ("#f25915e815e8");
268 detail_string = std::string("changed::") + std::string(key);
269 g_signal_connect (G_OBJECT(settings), detail_string.c_str(),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
270 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), (detail_string.c_str()), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
271 gdk_rgba_parse (&pd->config.cpu_color[i], color);
272 g_free (color);
273 g_free (key);
274 }
275 g_strfreev (keys);
276
277 color = g_settings_get_string (settings, "mem-color");
278 if (!color)
279 color = g_strdup ("#000000ff0082")g_strdup_inline ("#000000ff0082");
280 g_signal_connect (G_OBJECT(settings), "changed::mem-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
281 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::mem-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
282 gdk_rgba_parse(&pd->config.mem_color, color);
283 g_free (color);
284
285 color = g_settings_get_string (settings, "swap-color");
286 if (!color)
287 color = g_strdup ("#00b6000000ff")g_strdup_inline ("#00b6000000ff");
288 g_signal_connect (G_OBJECT(settings), "changed::swap-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
289 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::swap-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
290 gdk_rgba_parse(&pd->config.swap_color, color);
291 g_free (color);
292
293 color = g_settings_get_string (settings, "net-in-color");
294 if (!color)
295 color = g_strdup ("#000000f200f2")g_strdup_inline ("#000000f200f2");
296 g_signal_connect (G_OBJECT(settings), "changed::net-in-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
297 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-in-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
298 gdk_rgba_parse(&pd->config.net_in_color, color);
299 g_free (color);
300
301 color = g_settings_get_string (settings, "net-out-color");
302 if (!color)
303 color = g_strdup ("#00f2000000c1")g_strdup_inline ("#00f2000000c1");
304 g_signal_connect (G_OBJECT(settings), "changed::net-out-color",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
305 G_CALLBACK(color_changed_cb), pd)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((settings)), (((GType) ((20) << (2)
)))))))), ("changed::net-out-color"), (((GCallback) (color_changed_cb
))), (pd), __null, (GConnectFlags) 0)
;
306 gdk_rgba_parse(&pd->config.net_out_color, color);
307 g_free (color);
308
309 /* Sanity checks */
310 GdkDisplay *display;
311 GdkMonitor *monitor;
312 GdkRectangle monitor_geometry;
313
314 display = gdk_display_get_default ();
315 monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
316 if (monitor == NULL__null) {
317 monitor = gdk_display_get_monitor (display, 0);
318 }
319 gdk_monitor_get_geometry (monitor, &monitor_geometry);
320
321 pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width)(((pd->config.width) > (monitor_geometry.width)) ? (monitor_geometry
.width) : (((pd->config.width) < (50)) ? (50) : (pd->
config.width)))
;
322 pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height)(((pd->config.height) > (monitor_geometry.height)) ? (monitor_geometry
.height) : (((pd->config.height) < (50)) ? (50) : (pd->
config.height)))
;
323 pd->config.update_interval = MAX (pd->config.update_interval, 1000)(((pd->config.update_interval) > (1000)) ? (pd->config
.update_interval) : (1000))
;
324 pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250)(((pd->config.graph_update_interval) > (250)) ? (pd->
config.graph_update_interval) : (250))
;
325 pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000)(((pd->config.disks_update_interval) > (1000)) ? (pd->
config.disks_update_interval) : (1000))
;
326 pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2)(((pd->config.whose_process) > (2)) ? (2) : (((pd->config
.whose_process) < (0)) ? (0) : (pd->config.whose_process
)))
;
327 pd->config.current_tab = CLAMP(pd->config.current_tab,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
328 PROCMAN_TAB_SYSINFO,(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
329 PROCMAN_TAB_DISKS)(((pd->config.current_tab) > (PROCMAN_TAB_DISKS)) ? (PROCMAN_TAB_DISKS
) : (((pd->config.current_tab) < (PROCMAN_TAB_SYSINFO))
? (PROCMAN_TAB_SYSINFO) : (pd->config.current_tab)))
;
330
331 // delayed initialization as SmoothRefresh() needs ProcData
332 // i.e. we can't call ProcData::get_instance
333 pd->smooth_refresh = new SmoothRefresh(settings);
334
335 pd->terminating = FALSE(0);
336
337 return pd;
338}
339
340static void
341procman_free_data (ProcData *procdata)
342{
343
344 proctable_free_table (procdata);
345 delete procdata->smooth_refresh;
346}
347
348ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
349{
350 Glib::set_application_name(_("System Monitor")gettext ("System Monitor"));
351}
352
353Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
354{
355 return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
356}
357
358void ProcmanApp::on_activate()
359{
360 gtk_window_present (GTK_WINDOW (procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
361}
362
363static void
364set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
365{
366 gtk_notebook_set_current_page(notebook, tab);
367 cb_change_current_page(notebook, tab, procdata);
368}
369
370int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
371{
372 int argc = 0;
373 char** argv = command_line->get_arguments(argc);
374
375 Glib::OptionContext context;
376 context.set_summary(_("A simple process and system monitor.")gettext ("A simple process and system monitor."));
377 context.set_ignore_unknown_options(true);
378 procman::OptionGroup option_group;
379 context.set_main_group(option_group);
380
381 try {
382 context.parse(argc, argv);
383 } catch (const Glib::Error& ex) {
384 g_error("Arguments parse error : %s", ex.what().c_str());
385 }
386
387 if (option_group.show_system_tab) {
388 procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request")procman_debug_real("procman-app.cpp", 388, __func__, "Starting with PROCMAN_TAB_SYSINFO by commandline request"
)
;
389 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_SYSINFO, procdata);
390 } else if (option_group.show_processes_tab) {
391 procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request")procman_debug_real("procman-app.cpp", 391, __func__, "Starting with PROCMAN_TAB_PROCESSES by commandline request"
)
;
392 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_PROCESSES, procdata);
393 } else if (option_group.show_resources_tab) {
394 procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request")procman_debug_real("procman-app.cpp", 394, __func__, "Starting with PROCMAN_TAB_RESOURCES by commandline request"
)
;
395 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_RESOURCES, procdata);
396 } else if (option_group.show_file_systems_tab) {
397 procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request")procman_debug_real("procman-app.cpp", 397, __func__, "Starting with PROCMAN_TAB_DISKS by commandline request"
)
;
398 set_tab(GTK_NOTEBOOK(procdata->notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->notebook)), ((gtk_notebook_get_type ())))))
)
, PROCMAN_TAB_DISKS, procdata);
399 }
400
401 on_activate ();
402
403 return 0;
404}
405
406void ProcmanApp::on_startup()
407{
408 Gtk::Application::on_startup();
409
410 GSettings *settings;
411
412 Gtk::Window::set_default_icon_name ("utilities-system-monitor");
413
414 settings = g_settings_new (GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
415
416 glibtop_init ();
417
418 procdata = procman_data_new (settings);
419 procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA"org.mate.system-monitor");
420
421 create_main_window (procdata);
422 init_volume_monitor (procdata);
423
424 Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((procdata->app)), ((gtk_window_get_type ()))))))
);
425 window->show();
426 window->set_name ("mate-system-monitor");
427
428 add_window (*window);
429}
430
431void ProcmanApp::on_shutdown()
432{
433 procman_free_data(procdata);
434 glibtop_close();
435}
436
diff --git a/2024-01-24-110103-6148-1@4d3102f305d3_master/report-e8ff80.html b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-e8ff80.html new file mode 100644 index 00000000..dbd0cc0f --- /dev/null +++ b/2024-01-24-110103-6148-1@4d3102f305d3_master/report-e8ff80.html @@ -0,0 +1,1340 @@ + + + +util.cpp + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rootdir/src/util.cpp
Warning:line 350, column 17
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name util.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/bin/../lib/clang/17 -D HAVE_CONFIG_H -I . -I .. -D PROCMAN_DATADIR="/usr/local/share/procman/" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -D PKGLIBEXECDIR="/usr/local/libexec/mate-system-monitor" -D LIBEXECDIR="/usr/local/libexec" -I /usr/include/librsvg-2.0 -I /usr/include/gtkmm-3.0 -I /usr/lib64/gtkmm-3.0/include -I /usr/include/libgtop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/atkmm-1.6 -I /usr/lib64/atkmm-1.6/include -I /usr/include/gtk-3.0/unix-print -I /usr/include/gdkmm-3.0 -I /usr/lib64/gdkmm-3.0/include -I /usr/include/pango-1.0 -I /usr/include/pangomm-1.4 -I /usr/lib64/pangomm-1.4/include -I /usr/include/cairo -I /usr/include/giomm-2.4 -I /usr/lib64/giomm-2.4/include -I /usr/include/cairomm-1.0 -I /usr/lib64/cairomm-1.0/include -I /usr/include/sigc++-2.0 -I /usr/lib64/sigc++-2.0/include -I /usr/include/glibmm-2.4 -I /usr/lib64/glibmm-2.4/include -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/at-spi2-atk/2.0 -I /usr/include/cloudproviders -I /usr/include/blkid -I /usr/include/at-spi-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/libmount -I /usr/include/pixman-1 -I /usr/include/fribidi -I /usr/include/sysprof-6 -I /usr/include/libpng16 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/bin/../lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdeprecated-macro -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-01-24-110103-6148-1 -x c++ util.cpp +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2
3#include <glib/gprintf.h>
4#include <glib/gi18n.h>
5#include <glib.h>
6#include <gtk/gtk.h>
7
8#include <glibtop/proctime.h>
9#include <glibtop/procstate.h>
10#include <unistd.h>
11
12#include <stddef.h>
13#include <cstring>
14
15#include "util.h"
16#include "procman.h"
17
18gchar *
19procman_format_date_for_display(time_t time_raw)
20{
21 gchar *result = NULL__null;
22 const char *format;
23 GDateTime *date_time, *today;
24 GTimeSpan date_age;
25
26 date_time = g_date_time_new_from_unix_local (time_raw);
27 today = g_date_time_new_now_local ();
28
29 date_age = g_date_time_difference (today, date_time);
30 if (date_age < G_TIME_SPAN_DAY((86400000000L))) {
31 format = _("Today %l:%M %p")gettext ("Today %l:%M %p");
32 } else if (date_age < 2 * G_TIME_SPAN_DAY((86400000000L))) {
33 format = _("Yesterday %l:%M %p")gettext ("Yesterday %l:%M %p");
34 } else if (date_age < 7 * G_TIME_SPAN_DAY((86400000000L))) {
35 format = _("%a %l:%M %p")gettext ("%a %l:%M %p");
36 } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
37 format = _("%b %d %l:%M %p")gettext ("%b %d %l:%M %p");
38 } else {
39 format = _("%b %d %Y")gettext ("%b %d %Y");
40 }
41
42 g_date_time_unref (today);
43 result = g_date_time_format (date_time, format);
44 g_date_time_unref (date_time);
45
46 return result;
47}
48
49const char*
50format_process_state(guint state)
51{
52 const char *status;
53
54 switch (state)
55 {
56 case GLIBTOP_PROCESS_RUNNING1:
57 status = _("Running")gettext ("Running");
58 break;
59
60 case GLIBTOP_PROCESS_STOPPED16:
61 status = _("Stopped")gettext ("Stopped");
62 break;
63
64 case GLIBTOP_PROCESS_ZOMBIE8:
65 status = _("Zombie")gettext ("Zombie");
66 break;
67
68 case GLIBTOP_PROCESS_UNINTERRUPTIBLE4:
69 status = _("Uninterruptible")gettext ("Uninterruptible");
70 break;
71
72 default:
73 status = _("Sleeping")gettext ("Sleeping");
74 break;
75 }
76
77 return status;
78}
79
80
81
82static char *
83mnemonic_safe_process_name(const char *process_name)
84{
85 const char *p;
86 GString *name;
87
88 name = g_string_new ("");
89
90 for(p = process_name; *p; ++p)
91 {
92 g_string_append_c (name, *p)g_string_append_c_inline (name, *p);
93
94 if(*p == '_')
95 g_string_append_c (name, '_')g_string_append_c_inline (name, '_');
96 }
97
98 return g_string_free (name, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((name
), ((0))) : g_string_free_and_steal (name)) : (g_string_free)
((name), ((0))))
;
99}
100
101
102
103static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
104{
105 *q = *r / d;
106 *r = *r % d;
107 return *q != 0;
108}
109
110
111/*
112 * @param d: duration in centiseconds
113 * @type d: unsigned
114 */
115gchar *
116procman::format_duration_for_display(unsigned centiseconds)
117{
118 unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
119
120 (void)(divide(&seconds, &centiseconds, 100)
121 && divide(&minutes, &seconds, 60)
122 && divide(&hours, &minutes, 60)
123 && divide(&days, &hours, 24)
124 && divide(&weeks, &days, 7));
125
126 if (weeks)
127 /* xgettext: weeks, days */
128 return g_strdup_printf(_("%uw%ud")gettext ("%uw%ud"), weeks, days);
129
130 if (days)
131 /* xgettext: days, hours (0 -> 23) */
132 return g_strdup_printf(_("%ud%02uh")gettext ("%ud%02uh"), days, hours);
133
134 if (hours)
135 /* xgettext: hours (0 -> 23), minutes, seconds */
136 return g_strdup_printf(_("%u:%02u:%02u")gettext ("%u:%02u:%02u"), hours, minutes, seconds);
137
138 /* xgettext: minutes, seconds, centiseconds */
139 return g_strdup_printf(_("%u:%02u.%02u")gettext ("%u:%02u.%02u"), minutes, seconds, centiseconds);
140}
141
142
143
144GtkWidget*
145procman_make_label_for_mmaps_or_ofiles(const char *format,
146 const char *process_name,
147 unsigned pid)
148{
149 GtkWidget *label;
150 char *name, *title;
151
152 name = mnemonic_safe_process_name (process_name);
153 title = g_strdup_printf(format, name, pid);
154 label = gtk_label_new_with_mnemonic (title);
155 gtk_label_set_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, 0.0);
156
157 g_free (title);
158 g_free (name);
159
160 return label;
161}
162
163gchar *
164procman::get_nice_level (gint nice)
165{
166 if (nice < -7)
167 return _("Very High")gettext ("Very High");
168 else if (nice < -2)
169 return _("High")gettext ("High");
170 else if (nice < 3)
171 return _("Normal")gettext ("Normal");
172 else if (nice < 7)
173 return _("Low")gettext ("Low");
174 else
175 return _("Very Low")gettext ("Very Low");
176}
177
178
179gboolean
180load_symbols(const char *module, ...)
181{
182 GModule *mod;
183 gboolean found_all = TRUE(!(0));
184 va_list args;
185
186 mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
187
188 if (!mod)
189 return FALSE(0);
190
191 procman_debug("Found %s", module)procman_debug_real("util.cpp", 191, __func__, "Found %s", module
)
;
192
193 va_start(args, module)__builtin_va_start(args, module);
194
195 while (1) {
196 const char *name;
197 void **symbol;
198
199 name = va_arg(args, char*)__builtin_va_arg(args, char*);
200
201 if (!name)
202 break;
203
204 symbol = va_arg(args, void**)__builtin_va_arg(args, void**);
205
206 if (g_module_symbol(mod, name, symbol)) {
207 procman_debug("Loaded %s from %s", name, module)procman_debug_real("util.cpp", 207, __func__, "Loaded %s from %s"
, name, module)
;
208 }
209 else {
210 procman_debug("Could not load %s from %s", name, module)procman_debug_real("util.cpp", 210, __func__, "Could not load %s from %s"
, name, module)
;
211 found_all = FALSE(0);
212 break;
213 }
214 }
215
216 va_end(args)__builtin_va_end(args);
217
218
219 if (found_all)
220 g_module_make_resident(mod);
221 else
222 g_module_close(mod);
223
224 return found_all;
225}
226
227
228static gboolean
229is_debug_enabled(void)
230{
231 static gboolean init;
232 static gboolean enabled;
233
234 if (!init) {
235 enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL__null;
236 init = TRUE(!(0));
237 }
238
239 return enabled;
240}
241
242
243#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 78 > (61)) || (2 == (2
) && 78 == (61) && 3 >= (2)))
244static gint64
245get_relative_time(void)
246{
247 static unsigned long start_time;
248 gint64 tv;
249
250 if (G_UNLIKELY(!start_time)(!start_time)) {
251 glibtop_proc_time buf;
252 glibtop_get_proc_time(&buf, getpid());
253 start_time = buf.start_time;
254 }
255
256 tv = g_get_real_time ();
257 return tv - (gint64) start_time;
258}
259#else
260static double
261get_relative_time(void)
262{
263 static unsigned long start_time;
264 GTimeVal tv;
265
266 if (G_UNLIKELY(!start_time)(!start_time)) {
267 glibtop_proc_time buf;
268 glibtop_get_proc_time(&buf, getpid());
269 start_time = buf.start_time;
270 }
271
272 g_get_current_time(&tv);
273 return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
274}
275#endif
276
277static guint64
278get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
279 const guint index)
280{
281 GValue value = { 0 };
282 gtk_tree_model_get_value(model, first, index, &value);
283
284 guint64 size;
285 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
286 case G_TYPE_UINT((GType) ((7) << (2))):
287 size = g_value_get_uint(&value);
288 break;
289 case G_TYPE_ULONG((GType) ((9) << (2))):
290 size = g_value_get_ulong(&value);
291 break;
292 case G_TYPE_UINT64((GType) ((11) << (2))):
293 size = g_value_get_uint64(&value);
294 break;
295 default:
296 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 296,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
297 }
298
299 g_value_unset(&value);
300 return size;
301}
302
303void
304procman_debug_real(const char *file, int line, const char *func,
305 const char *format, ...)
306{
307 va_list args;
308 char *msg;
309
310 if (G_LIKELY(!is_debug_enabled())(!is_debug_enabled()))
311 return;
312
313 va_start(args, format)__builtin_va_start(args, format);
314 msg = g_strdup_vprintf(format, args);
315 va_end(args)__builtin_va_end(args);
316
317#if GLIB_CHECK_VERSION(2,61,2)(2 > (2) || (2 == (2) && 78 > (61)) || (2 == (2
) && 78 == (61) && 3 >= (2)))
318 g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
319#else
320 g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
321#endif
322 g_free(msg);
323}
324
325
326
327namespace procman
328{
329 void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
330 GtkTreeModel *model, GtkTreeIter *iter,
331 gpointer user_data)
332 {
333 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
334
335 guint64 size;
336 GValue value = { 0 };
337
338 gtk_tree_model_get_value(model, iter, index, &value);
339
340 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
341 case G_TYPE_ULONG((GType) ((9) << (2))):
342 size = g_value_get_ulong(&value);
343 break;
344
345 case G_TYPE_UINT64((GType) ((11) << (2))):
346 size = g_value_get_uint64(&value);
347 break;
348
349 default:
350 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 350,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
This statement is never executed
351 }
352
353 g_value_unset(&value);
354
355 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
356 g_object_set(renderer, "text", str, NULL__null);
357 g_free(str);
358 }
359
360 /*
361 Same as above but handles size == 0 as not available
362 */
363 void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
364 GtkTreeModel *model, GtkTreeIter *iter,
365 gpointer user_data)
366 {
367 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
368
369 guint64 size;
370 GValue value = { 0 };
371
372 gtk_tree_model_get_value(model, iter, index, &value);
373
374 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
375 case G_TYPE_ULONG((GType) ((9) << (2))):
376 size = g_value_get_ulong(&value);
377 break;
378
379 case G_TYPE_UINT64((GType) ((11) << (2))):
380 size = g_value_get_uint64(&value);
381 break;
382
383 default:
384 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 384,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
385 }
386
387 g_value_unset(&value);
388
389 if (size == 0) {
390 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
391 g_object_set(renderer, "markup", str, NULL__null);
392 g_free(str);
393 }
394 else {
395 char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
396 g_object_set(renderer, "text", str, NULL__null);
397 g_free(str);
398 }
399 }
400
401 void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
402 GtkTreeModel *model, GtkTreeIter *iter,
403 gpointer user_data)
404 {
405 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
406
407 guint64 size;
408 GValue value = { 0 };
409
410 gtk_tree_model_get_value(model, iter, index, &value);
411
412 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
413 case G_TYPE_ULONG((GType) ((9) << (2))):
414 size = g_value_get_ulong(&value);
415 break;
416
417 case G_TYPE_UINT64((GType) ((11) << (2))):
418 size = g_value_get_uint64(&value);
419 break;
420
421 default:
422 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 422,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
423 }
424
425 g_value_unset(&value);
426
427 char *str = g_format_size(size);
428 g_object_set(renderer, "text", str, NULL__null);
429 g_free(str);
430 }
431
432 /*
433 Same as above but handles size == 0 as not available
434 */
435 void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
436 GtkTreeModel *model, GtkTreeIter *iter,
437 gpointer user_data)
438 {
439 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
440
441 guint64 size;
442 GValue value = { 0 };
443
444 gtk_tree_model_get_value(model, iter, index, &value);
445
446 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
447 case G_TYPE_ULONG((GType) ((9) << (2))):
448 size = g_value_get_ulong(&value);
449 break;
450
451 case G_TYPE_UINT64((GType) ((11) << (2))):
452 size = g_value_get_uint64(&value);
453 break;
454
455 default:
456 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 456,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
457 }
458
459 g_value_unset(&value);
460
461 if (size == 0) {
462 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
463 g_object_set(renderer, "markup", str, NULL__null);
464 g_free(str);
465 }
466 else {
467 char *str = g_format_size(size);
468 g_object_set(renderer, "text", str, NULL__null);
469 g_free(str);
470 }
471 }
472
473 void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
474 GtkTreeModel *model, GtkTreeIter *iter,
475 gpointer user_data)
476 {
477 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
478
479 guint64 size;
480 GValue value = { 0 };
481
482 gtk_tree_model_get_value(model, iter, index, &value);
483
484 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
485 case G_TYPE_ULONG((GType) ((9) << (2))):
486 size = g_value_get_ulong(&value);
487 break;
488
489 case G_TYPE_UINT64((GType) ((11) << (2))):
490 size = g_value_get_uint64(&value);
491 break;
492
493 default:
494 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 494,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
495 }
496
497 g_value_unset(&value);
498
499 if (size == 0) {
500 char *str = g_strdup_printf ("<i>%s</i>", _("N/A")gettext ("N/A"));
501 g_object_set(renderer, "markup", str, NULL__null);
502 g_free(str);
503 }
504 else {
505 char *str = g_format_size(size);
506 char *formatted_str = g_strdup_printf(_("%s/s")gettext ("%s/s"), str);
507 g_object_set(renderer, "text", formatted_str, NULL__null);
508 g_free(formatted_str);
509 g_free(str);
510 }
511
512 }
513
514 void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
515 GtkTreeModel *model, GtkTreeIter *iter,
516 gpointer user_data)
517 {
518 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
519
520 unsigned time;
521 GValue value = { 0 };
522
523 gtk_tree_model_get_value(model, iter, index, &value);
524
525 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
526 case G_TYPE_ULONG((GType) ((9) << (2))):
527 time = g_value_get_ulong(&value);
528 break;
529
530 case G_TYPE_UINT64((GType) ((11) << (2))):
531 time = g_value_get_uint64(&value);
532 break;
533
534 default:
535 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 535,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
536 }
537
538 g_value_unset(&value);
539
540 time = 100 * time / ProcData::get_instance()->frequency;
541 char *str = format_duration_for_display(time);
542 g_object_set(renderer, "text", str, NULL__null);
543 g_free(str);
544 }
545
546
547 void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
548 GtkTreeModel *model, GtkTreeIter *iter,
549 gpointer user_data)
550 {
551 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
552
553 time_t time;
554 GValue value = { 0 };
555
556 gtk_tree_model_get_value(model, iter, index, &value);
557
558 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
559 case G_TYPE_ULONG((GType) ((9) << (2))):
560 time = g_value_get_ulong(&value);
561 break;
562
563 default:
564 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 564,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
565 }
566
567 g_value_unset(&value);
568
569 gchar *str = procman_format_date_for_display(time);
570 g_object_set(renderer, "text", str, NULL__null);
571 g_free(str);
572 }
573
574 void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
575 GtkTreeModel *model, GtkTreeIter *iter,
576 gpointer user_data)
577 {
578 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
579
580 guint state;
581 GValue value = { 0 };
582
583 gtk_tree_model_get_value(model, iter, index, &value);
584
585 switch (G_VALUE_TYPE(&value)(((GValue*) (&value))->g_type)) {
586 case G_TYPE_UINT((GType) ((7) << (2))):
587 state = g_value_get_uint(&value);
588 break;
589
590 default:
591 g_assert_not_reached()do { g_assertion_message_expr (((gchar*) 0), "util.cpp", 591,
((const char*) (__PRETTY_FUNCTION__)), __null); } while (0)
;
592 }
593
594 g_value_unset(&value);
595
596 const char *str = format_process_state(state);
597 g_object_set(renderer, "text", str, NULL__null);
598 }
599
600 void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
601 GtkTreeModel *model, GtkTreeIter *iter,
602 gpointer user_data)
603 {
604 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
605
606 GValue value = { 0 };
607
608 gtk_tree_model_get_value(model, iter, index, &value);
609
610 gint priority = g_value_get_int(&value);
611
612 g_value_unset(&value);
613
614 g_object_set(renderer, "text", procman::get_nice_level(priority), NULL__null);
615
616 }
617
618 gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
619 GtkTreeIter* second, gpointer user_data)
620 {
621 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
622 GValue value1 = { 0 };
623 GValue value2 = { 0 };
624 gtk_tree_model_get_value(model, first, index, &value1);
625 gtk_tree_model_get_value(model, second, index, &value2);
626 gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
627 g_value_unset(&value1);
628 g_value_unset(&value2);
629 return result;
630 }
631
632 gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
633 GtkTreeIter* second, gpointer user_data)
634 {
635 const guint index = GPOINTER_TO_UINT(user_data)((guint) (gulong) (user_data));
636
637 guint64 size1, size2;
638 size1 = get_size_from_column(model, first, index);
639 size2 = get_size_from_column(model, second, index);
640
641 if ( size2 > size1 )
642 return 1;
643 else if ( size2 < size1 )
644 return -1;
645 return 0;
646 }
647
648 template<>
649 void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
650 {
651 char* current_value;
652
653 gtk_tree_model_get(model, iter, column, &current_value, -1);
654
655 if (g_strcmp0(current_value, new_value) != 0)
656 gtk_tree_store_set(GTK_TREE_STORE(model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter, column, new_value, -1);
657
658 g_free(current_value);
659 }
660}
diff --git a/2024-01-24-110103-6148-1@4d3102f305d3_master/scanview.css b/2024-01-24-110103-6148-1@4d3102f305d3_master/scanview.css new file mode 100644 index 00000000..cf8a5a6a --- /dev/null +++ b/2024-01-24-110103-6148-1@4d3102f305d3_master/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/2024-01-24-110103-6148-1@4d3102f305d3_master/sorttable.js b/2024-01-24-110103-6148-1@4d3102f305d3_master/sorttable.js new file mode 100644 index 00000000..32faa078 --- /dev/null +++ b/2024-01-24-110103-6148-1@4d3102f305d3_master/sorttable.js @@ -0,0 +1,492 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse',''); + cell.className = cell.className.replace('sorttable_sorted',''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j=0; j 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } + else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } + else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i=0; i=0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a,b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); + if (isNaN(bb)) bb = 0; + return aa-bb; + }, + sort_alpha: function(a,b) { + if (a[0]==b[0]) return 0; + if (a[0] 0 ) { + var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for(var i = t; i > b; --i) { + if ( comp_func(list[i], list[i-1]) < 0 ) { + var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write(" + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/optionentry.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+
+#include "argv.h"
+
+namespace procman
+{
+    OptionGroup::OptionGroup()
+        : Glib::OptionGroup("", ""),
+          show_system_tab(false),
+          show_processes_tab(false),
+          show_resources_tab(false),
+          show_file_systems_tab(false)
+    {
+        Glib::OptionEntry sys_tab;
+        sys_tab.set_long_name("show-system-tab");
+        sys_tab.set_short_name('s');
+        sys_tab.set_description(_("Show the System tab"));
+
+        Glib::OptionEntry proc_tab;
+        proc_tab.set_long_name("show-processes-tab");
+        proc_tab.set_short_name('p');
+        proc_tab.set_description(_("Show the Processes tab"));
+
+        Glib::OptionEntry res_tab;
+        res_tab.set_long_name("show-resources-tab");
+        res_tab.set_short_name('r');
+        res_tab.set_description(_("Show the Resources tab"));
+
+        Glib::OptionEntry fs_tab;
+        fs_tab.set_long_name("show-file-systems-tab");
+        fs_tab.set_short_name('f');
+        fs_tab.set_description(_("Show the File Systems tab"));
+
+        this->add_entry(sys_tab, this->show_system_tab);
+        this->add_entry(proc_tab, this->show_processes_tab);
+        this->add_entry(res_tab, this->show_resources_tab);
+        this->add_entry(fs_tab, this->show_file_systems_tab);
+    }
+}
+
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/1.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/1.html new file mode 100644 index 00000000..150a20c4 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/1.html @@ -0,0 +1,279 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
#ifndef H_PROCMAN_ARGV_1205873424
+#define H_PROCMAN_ARGV_1205873424
+
+#include <glibmm/optiongroup.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+namespace procman
+{
+    class OptionGroup
+        : public Glib::OptionGroup
+    {
+      public:
+        OptionGroup();
+
+        bool show_system_tab;
+        bool show_processes_tab;
+        bool show_resources_tab;
+        bool show_file_systems_tab;
+    };
+}
+
+#endif // H_PROCMAN_ARGV_1205873424
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/10.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/10.html new file mode 100644 index 00000000..7cf5e546 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/10.html @@ -0,0 +1,391 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
/* Procman - tree view
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef _PROCMAN_PROCTABLE_H_
+#define _PROCMAN_PROCTABLE_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+enum
+{
+    COL_NAME = 0,
+    COL_USER,
+    COL_STATUS,
+    COL_VMSIZE,
+    COL_MEMRES,
+    COL_MEMWRITABLE,
+    COL_MEMSHARED,
+    COL_MEMXSERVER,
+    COL_CPU,
+    COL_CPU_TIME,
+    COL_START_TIME,
+    COL_NICE,
+    COL_PID,
+    COL_SECURITYCONTEXT,
+    COL_ARGS,
+    COL_MEM,
+    COL_WCHAN,
+    COL_CGROUP,
+    COL_UNIT,
+    COL_SESSION,
+    COL_SEAT,
+    COL_OWNER,
+    COL_DISK_WRITE_TOTAL,
+    COL_DISK_READ_TOTAL,
+    COL_DISK_WRITE_CURRENT,
+    COL_DISK_READ_CURRENT,
+    COL_PRIORITY,
+    COL_SURFACE,
+    COL_POINTER,
+    COL_TOOLTIP,
+    NUM_COLUMNS
+};
+
+GtkWidget*      proctable_new (ProcData *data);
+void            proctable_update_table (ProcData *data);
+void            proctable_update (ProcData *data);
+void            proctable_clear_tree (ProcData *data);
+void            proctable_free_table (ProcData *data);
+
+GSList*         proctable_get_columns_order(GtkTreeView *treeview);
+void            proctable_set_columns_order(GtkTreeView *treeview, GSList *order);
+
+char*           make_loadavg_string(void);
+
+void            get_last_selected (GtkTreeModel *model, GtkTreePath *path,
+                                   GtkTreeIter *iter, gpointer data);
+
+#endif /* _PROCMAN_PROCTABLE_H_ */
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/11.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/11.html new file mode 100644 index 00000000..305358bf --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/11.html @@ -0,0 +1,499 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
// -*- mode: c++ -*-
+
+#ifndef H_MATE_SYSTEM_MONITOR_UTIL_1123178725
+#define H_MATE_SYSTEM_MONITOR_UTIL_1123178725
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+using std::string;
+
+/* check if logind is running */
+#define LOGIND_RUNNING() (access("/run/systemd/seats/", F_OK) >= 0)
+
+GtkWidget*
+procman_make_label_for_mmaps_or_ofiles(const char *format,
+                                       const char *process_name,
+                                       unsigned pid);
+
+gboolean
+load_symbols(const char *module, ...) G_GNUC_NULL_TERMINATED;
+
+gchar *
+procman_format_date_for_display(time_t time_raw);
+
+const char*
+format_process_state(guint state);
+
+void
+procman_debug_real(const char *file, int line, const char *func,
+                   const char *format, ...) G_GNUC_PRINTF(4, 5);
+
+#define procman_debug(FMT, ...) procman_debug_real(__FILE__, __LINE__, __func__, FMT, ##__VA_ARGS__)
+
+inline string make_string(char *c_str)
+{
+    if (!c_str) {
+        procman_debug("NULL string");
+        return string();
+    }
+
+    string s(c_str);
+    g_free(c_str);
+    return s;
+}
+
+namespace procman
+{
+    gchar* format_duration_for_display(unsigned centiseconds);
+
+    void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                    GtkTreeModel *model, GtkTreeIter *iter,
+                                    gpointer user_data);
+
+    void io_rate_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                GtkTreeModel *model, GtkTreeIter *iter,
+                                gpointer user_data);
+
+    void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                       GtkTreeModel *model, GtkTreeIter *iter,
+                                       gpointer user_data);
+
+    void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                     GtkTreeModel *model, GtkTreeIter *iter,
+                                     gpointer user_data);
+
+    void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                        GtkTreeModel *model, GtkTreeIter *iter,
+                                        gpointer user_data);
+
+    void duration_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                   GtkTreeModel *model, GtkTreeIter *iter,
+                   gpointer user_data);
+
+    void time_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                             GtkTreeModel *model, GtkTreeIter *iter,
+                             gpointer user_data);
+
+    void status_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                               GtkTreeModel *model, GtkTreeIter *iter,
+                               gpointer user_data);
+    void priority_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                               GtkTreeModel *model, GtkTreeIter *iter,
+                               gpointer user_data);
+    gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
+                            GtkTreeIter* second, gpointer user_data);
+    gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
+                            GtkTreeIter* second, gpointer user_data);
+
+    template<typename T>
+    void poison(T &t, char c)
+    {
+        memset(&t, c, sizeof t);
+    }
+
+    //
+    // Stuff to update a tree_store in a smart way
+    //
+
+    template<typename T>
+    void tree_store_update(GtkTreeModel* model, GtkTreeIter* iter, int column, const T& new_value)
+    {
+        T current_value;
+
+        gtk_tree_model_get(model, iter, column, &current_value, -1);
+
+        if (current_value != new_value)
+            gtk_tree_store_set(GTK_TREE_STORE(model), iter, column, new_value, -1);
+    }
+
+    // undefined
+    // catch every thing about pointers
+    // just to make sure i'm not doing anything wrong
+    template<typename T>
+    void tree_store_update(GtkTreeModel* model, GtkTreeIter* iter, int column, T* new_value);
+
+    // specialized versions for strings
+    template<>
+    void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value);
+
+    template<>
+    inline void tree_store_update<char>(GtkTreeModel* model, GtkTreeIter* iter, int column, char* new_value)<--- Parameter 'new_value' can be declared as pointer to const
+    {
+         tree_store_update<const char>(model, iter, column, new_value);
+    }
+
+    gchar* get_nice_level (gint nice);
+}
+
+#endif /* H_MATE_SYSTEM_MONITOR_UTIL_1123178725 */
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/12.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/12.html new file mode 100644 index 00000000..7e642be5 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/12.html @@ -0,0 +1,341 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
/* Procman - dialogs
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef _PROCDIALOGS_H_
+#define _PROCDIALOGS_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+/* These are the actual range of settable values. Values outside this range
+   are scaled back to these limits. So show these limits in the slider
+*/
+#ifdef __linux__
+#define RENICE_VAL_MIN -20
+#define RENICE_VAL_MAX 19
+#else /* ! linux */
+#define RENICE_VAL_MIN -20
+#define RENICE_VAL_MAX 20
+#endif
+
+typedef enum
+{
+    PROCMAN_ACTION_RENICE,
+    PROCMAN_ACTION_KILL
+} ProcmanActionType;
+
+void                    procdialog_create_kill_dialog (ProcData *data, int signal);
+void                    procdialog_create_renice_dialog (ProcData *data);
+gboolean                procdialog_create_root_password_dialog (ProcmanActionType type,
+                                                                ProcData *procdata,
+                                                                gint pid, gint extra_value);
+void                    procdialog_create_memmaps_dialog (ProcData *data);
+void                    procdialog_create_preferences_dialog (ProcData *data);
+
+#endif
+
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/13.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/13.html new file mode 100644 index 00000000..f363ef46 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/13.html @@ -0,0 +1,255 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
1
+2
+3
+4
+5
+6
+7
+8
+9
#ifndef _PROCMAN_MEMMAPS_H_
+#define _PROCMAN_MEMMAPS_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+void            create_memmaps_dialog (ProcData *procdata);
+
+#endif /* _PROCMAN_MEMMAPS_H_ */
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/14.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/14.html new file mode 100644 index 00000000..cb428136 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/14.html @@ -0,0 +1,257 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
#ifndef _OPENFILES_H_
+#define _OPENFILES_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+void            create_openfiles_dialog (ProcData *procdata);
+
+#endif
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/15.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/15.html new file mode 100644 index 00000000..84c677ee --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/15.html @@ -0,0 +1,299 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
/* Process properties dialog
+ * Copyright (C) 2010 Krishnan Parthasarathi <krishnan.parthasarathi@gmail.com>
+ *                    Robert Ancell <robert.ancell@canonical.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef _PROCPROPERTIES_H_
+#define _PROCPROPERTIES_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+void create_procproperties_dialog (ProcData *procdata);
+
+#endif
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/16.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/16.html new file mode 100644 index 00000000..f3ab4340 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/16.html @@ -0,0 +1,489 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
#ifndef _PROCMAN_LOAD_GRAPH_H_
+#define _PROCMAN_LOAD_GRAPH_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+enum
+{
+    LOAD_GRAPH_CPU,
+    LOAD_GRAPH_MEM,
+    LOAD_GRAPH_NET
+};
+
+enum {
+    CPU_TOTAL,
+    CPU_USED,
+    N_CPU_STATES
+};
+
+struct LoadGraphLabels
+{
+    GtkWidget *cpu[GLIBTOP_NCPU];
+    GtkWidget *memory;
+    GtkWidget *swap;
+    GtkWidget *net_in;
+    GtkWidget *net_in_total;
+    GtkWidget *net_out;
+    GtkWidget *net_out_total;
+};
+
+struct LoadGraph {
+
+    static const unsigned NUM_POINTS = 60 + 2;
+    static const unsigned GRAPH_MIN_HEIGHT = 40;
+
+    LoadGraph(guint type);
+    ~LoadGraph();
+
+    unsigned num_bars() const;
+    void clear_background();
+
+    double fontsize;
+    double rmargin;
+    double indent;
+
+    guint n;
+    gint type;
+    guint speed;
+    guint draw_width, draw_height;
+    guint render_counter;
+    guint frames_per_unit;
+    guint graph_dely;
+    guint real_draw_height;
+    double graph_delx;
+    guint graph_buffer_offset;
+
+    std::vector<GdkRGBA> colors;
+
+    std::vector<float> data_block;
+    gfloat* data[NUM_POINTS];
+
+    GtkWidget *main_widget;
+    GtkWidget *disp;
+
+    cairo_pattern_t *background;
+
+    guint timer_index;
+
+    gboolean draw;
+
+    LoadGraphLabels labels;
+    GtkWidget *mem_color_picker;
+    GtkWidget *swap_color_picker;
+
+    /* union { */
+        struct {
+            guint now; /* 0 -> current, 1 -> last
+                    now ^ 1 each time */
+            /* times[now], times[now ^ 1] is last */
+            guint64 times[2][GLIBTOP_NCPU][N_CPU_STATES];
+        } cpu;
+
+        struct {
+            guint64 last_in, last_out;
+#if GLIB_CHECK_VERSION(2,61,2)
+            gint64 time;
+#else
+            GTimeVal time;
+#endif
+            guint64 max;
+            unsigned values[NUM_POINTS];
+            size_t cur;
+        } net;
+    /* }; */
+};
+
+/* Force a drawing update */
+void
+load_graph_queue_draw (LoadGraph *g);
+
+/* Start load graph. */
+void
+load_graph_start (LoadGraph *g);
+
+/* Stop load graph. */
+void
+load_graph_stop (LoadGraph *g);
+
+/* Change load graph speed and restart it if it has been previously started */
+void
+load_graph_change_speed (LoadGraph *g,
+                         guint new_speed);
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *g) G_GNUC_CONST;
+
+#endif /* _PROCMAN_LOAD_GRAPH_H_ */
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/17.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/17.html new file mode 100644 index 00000000..7f5c0635 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/17.html @@ -0,0 +1,255 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
1
+2
+3
+4
+5
+6
+7
+8
+9
#ifndef H_PROCMAN_LSOF_1161179202
+#define H_PROCMAN_LSOF_1161179202
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+void procman_lsof(ProcData *data);
+
+#endif /* H_PROCMAN_LSOF_1161179202 */
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/18.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/18.html new file mode 100644 index 00000000..9eba0f6b --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/18.html @@ -0,0 +1,645 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <cstring><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "cgroups.h"
+#include "util.h"
+
+gboolean
+cgroups_enabled(void)
+{
+    static gboolean initialized = FALSE;
+    static gboolean has_cgroups;
+
+    if (!initialized) {
+        initialized = TRUE;
+        has_cgroups = g_file_test("/proc/cgroups", G_FILE_TEST_EXISTS);
+    }
+
+    return has_cgroups;
+}
+
+static void
+append_cgroup_name(char *line, gchar **current_cgroup_name)
+{
+    gchar *controller, *path, *tmp, *path_plus_space;
+    int paren_offset, off, tmp_size;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return;
+
+    *(path - 1) = '\0';
+    g_strdelimit(controller, ",", '/');
+
+    if ((std::strcmp(path, "/") == 0) || (std::strncmp(controller, "name=", 5) == 0))
+        return;
+
+    if (*current_cgroup_name == NULL) {
+        *current_cgroup_name = g_strdup_printf("%s (%s)", path, controller);
+        return;
+    }
+
+    /* add a space to the end of the path string */
+    path_plus_space = g_strdup_printf("%s ", path);
+
+    if ((tmp = g_strstr_len(*current_cgroup_name, -1, path_plus_space))) {
+        tmp_size = strlen(*current_cgroup_name) + strlen(controller) + 1;
+        paren_offset = g_strstr_len(tmp + strlen(path), -1, ")") - *current_cgroup_name;
+        *(*current_cgroup_name + paren_offset) = '\0';
+        tmp = (gchar *)g_strnfill(tmp_size, '\0');
+        off = g_strlcat(tmp, *current_cgroup_name, tmp_size);
+        *(tmp + off) = '/';
+        off++;
+        off += g_strlcat(tmp + off, controller, tmp_size);
+        *(tmp + off) = ')';
+        off++;
+        g_strlcat(tmp + off, *current_cgroup_name + paren_offset + 1, tmp_size);
+    } else
+        tmp = g_strdup_printf("%s, %s(%s)", *current_cgroup_name, path_plus_space, controller);
+
+    g_free(path_plus_space);
+    g_free(*current_cgroup_name);
+    *current_cgroup_name = tmp;
+}
+
+static int
+check_cgroup_changed(gchar *line, gchar *current_cgroup_set)
+{
+    /* check if line is contained in current_cgroup_set */
+    gchar *controller, *path, *tmp, *found, *close_paren, *open_paren;<--- Variable 'open_paren' can be declared as pointer to const
+    int ret = 0;
+
+    controller = g_strstr_len(line, -1, ":") + 1;
+    if (!controller)
+        return 1;
+
+    path = g_strstr_len(controller, -1, ":") + 1;
+    if (!path)
+        return 1;
+
+    *(path - 1) = '\0';
+
+    if (std::strncmp(controller, "name=", 5) == 0)
+        goto out;
+
+    /* if there are multiple controllers just report string has changed */
+    if (g_strstr_len(controller, -1, ",")) {
+        ret = 1;
+        goto out;
+    }
+
+    if (!current_cgroup_set) {
+        if (std::strcmp(path, "/") != 0)
+            ret = 1;
+        goto out;
+    }
+
+    /* special case for root cgroup */
+    tmp = current_cgroup_set;
+    if (std::strcmp(path, "/") == 0) {
+        while ((found = g_strstr_len(tmp, -1, controller))) {
+            close_paren = g_strstr_len(found, -1, ")");
+            open_paren = g_strstr_len(found, -1, "(");
+            if (close_paren) {
+                if (!open_paren || (close_paren < open_paren)) {
+                    ret = 1;
+                    goto out;
+                }
+            }
+            tmp = found + strlen(controller);
+        }
+        goto out;
+    }
+
+    tmp = current_cgroup_set;
+    while ((found = g_strstr_len(tmp, -1, path))) {
+            found = found + strlen(path);
+            close_paren = g_strstr_len(found, -1, ")");
+            if (*found == ' ') {
+                if (g_strstr_len(found + 1, close_paren - found, controller))
+                    goto out;
+            }
+            tmp = close_paren + 1;
+    }
+    ret = 1;
+out:
+    *(path - 1) = ':';
+    return ret;
+}
+
+void
+get_process_cgroup_info(ProcInfo *info)
+{
+    gchar *path;
+    gchar *cgroup_name = NULL;
+    int cgroups_changed = 0;
+    gchar *text;
+    char **lines;
+    int i;
+
+    if (!cgroups_enabled())
+        return;
+
+    /* read out of /proc/pid/cgroup */
+    path = g_strdup_printf("/proc/%d/cgroup", info->pid);
+    if (!path)
+        return;
+    if(!g_file_get_contents(path, &text, NULL, NULL))
+        goto out;
+    lines = g_strsplit(text, "\n", -1);
+    g_free(text);
+    if (!lines)
+        goto out;
+
+    for (i = 0; lines[i] != NULL; i++) {
+        if (lines[i][0] == '\0')
+            continue;
+        if (check_cgroup_changed(lines[i], info->cgroup_name)) {
+            cgroups_changed = 1;
+            break;
+        }
+    }
+
+    if (cgroups_changed) {
+        for (i = 0; lines[i] != NULL; i++) {
+            if (lines[i][0] == '\0')
+                continue;
+            append_cgroup_name(lines[i], &cgroup_name);
+        }
+        if (info->cgroup_name)
+            g_free(info->cgroup_name);
+        if (!cgroup_name)
+            info->cgroup_name = g_strdup("");
+        else
+            info->cgroup_name = cgroup_name;
+    }
+
+    g_strfreev(lines);
+out:
+    g_free(path);
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/19.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/19.html new file mode 100644 index 00000000..3a2fca7c --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/19.html @@ -0,0 +1,261 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
#ifndef PROCMAN_CGROUP_H_20111103
+#define PROCMAN_CGROUP_H_20111103
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+void get_process_cgroup_info (ProcInfo *info);
+
+gboolean cgroups_enabled (void);
+
+#endif /* PROCMAN_CGROUP_H_20111103 */
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/2.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/2.html new file mode 100644 index 00000000..f9a212d8 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/2.html @@ -0,0 +1,1289 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
/* Procman - callbacks
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <giomm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "callbacks.h"
+#include "interface.h"
+#include "proctable.h"
+#include "util.h"
+#include "procactions.h"
+#include "procman.h"
+#include "procdialogs.h"
+#include "memmaps.h"
+#include "openfiles.h"
+#include "procproperties.h"
+#include "load-graph.h"
+#include "disks.h"
+#include "lsof.h"
+#include "sysinfo.h"
+
+void
+cb_kill_sigstop(GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    /* no confirmation */
+    kill_process (procdata, SIGSTOP);
+}
+
+
+
+
+void
+cb_kill_sigcont(GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    /* no confirmation */
+    kill_process (procdata, SIGCONT);
+}
+
+
+
+
+static void
+kill_process_helper(ProcData *procdata, int sig)
+{
+    if (procdata->config.show_kill_warning)
+        procdialog_create_kill_dialog (procdata, sig);
+    else
+        kill_process (procdata, sig);
+}
+
+
+void
+cb_edit_preferences (GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdialog_create_preferences_dialog (procdata);
+}
+
+
+void
+cb_renice (GtkAction *action, GtkRadioAction *current, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    gint selected = gtk_radio_action_get_current_value(current);
+
+    if (selected == CUSTOM_PRIORITY)
+    {
+       procdialog_create_renice_dialog (procdata);
+    } else {
+       gint new_nice_value = 0;
+       switch (selected) {
+           case VERY_HIGH_PRIORITY: new_nice_value = -20; break;
+           case HIGH_PRIORITY: new_nice_value = -5; break;
+           case NORMAL_PRIORITY: new_nice_value = 0; break;
+           case LOW_PRIORITY: new_nice_value = 5; break;
+           case VERY_LOW_PRIORITY: new_nice_value = 19; break;
+       }
+       renice(procdata, new_nice_value);
+    }
+}
+
+
+void
+cb_end_process (GtkAction *action, gpointer data)
+{
+    kill_process_helper(static_cast<ProcData*>(data), SIGTERM);
+}
+
+
+void
+cb_kill_process (GtkAction *action, gpointer data)
+{
+    kill_process_helper(static_cast<ProcData*>(data), SIGKILL);
+}
+
+
+void
+cb_show_memory_maps (GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    create_memmaps_dialog (procdata);
+}
+
+void
+cb_show_open_files (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    create_openfiles_dialog (procdata);
+}
+
+void
+cb_show_process_properties (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    create_procproperties_dialog (procdata);
+}
+
+void
+cb_show_lsof(GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    procman_lsof(procdata);
+}
+
+
+void
+cb_about (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    const gchar * const authors[] = {
+        "Adam Erdman <hekel@archlinux.info>",
+        "Alexander Pyhalov <apyhalov@gmail.com>",
+        "Andreas Nilsson <nisses.mail@home.se>",
+        "Benoît Dejean <bdejean@gmail.com>",
+        "Chris Kühl <chrisk@openismus.com>",
+        "Clement Lefebvre <clement.lefebvre@linuxmint.com>",
+        "Elias Aebi <user142@hotmail.com>",
+        "Erik Johnsson",
+        "Jorgen Scheibengruber",
+        "Karl Lattimer",
+        "Kevin Vandersloot",
+        "Laurent Napias <tamplan@free.fr>",
+        "Marcel Dijkstra <marcel.dykstra@gmail.com>",
+        "Martin Wimpress <martin@mate-desktop.org>",
+        "Matias De lellis <mati86dl@gmail.com>",
+        "Mike Gabriel <mike.gabriel@das-netzwerkteam.de>",
+        "Nelson Marques <nmo.marques@gmail.com>",
+        "Obata Akio https://github.com/obache",
+        "Pablo Barciela <scow@riseup.net>",
+        "Paolo Borelli",
+        "Perberos <perberos@gmail.com>",
+        "Piotr DrÄ…g <piotrdrag@gmail.com>",
+        "Robert Buj <robert.buj@gmail.com>",
+        "Sander Sweers <infirit@gmail.com>",
+        "Scott Balneaves <sbalneav@alburg.net>",
+        "Soong Noonien https://github.com/SoongNoonien",
+        "Stefano Karapetsas <stefano@karapetsas.com>",
+        "Steve Zesch <stevezesch2@gmail.com>",
+        "Victor Kareh <vkareh@redhat.com>",
+        "Vlad Orlov <monsta@inbox.ru>",
+        "Wolfgang Ulbrich <mate@raveit.de>",
+        "Wu Xiaotian <yetist@gmail.com>",
+        "Yaakov Selkowitz <yselkowitz@users.sourceforge.net>",
+        "Youri Mouton <youri@NetBSD.org>",
+        NULL
+    };
+
+    const gchar * const documenters[] = {
+        "Bill Day",
+        "Sun Microsystems",
+        NULL
+    };
+
+    const gchar * const artists[] = {
+        "Baptiste Mille-Mathias",
+        NULL
+    };
+
+    const gchar * license[] = {
+        N_("System Monitor is free software; you can redistribute it and/or modify "
+        "it under the terms of the GNU General Public License as published by "
+        "the Free Software Foundation; either version 2 of the License, or "
+        "(at your option) any later version."),
+        N_("System Monitor is distributed in the hope that it will be useful, "
+        "but WITHOUT ANY WARRANTY; without even the implied warranty of "
+        "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the "
+        "GNU General Public License for more details."),
+        N_("You should have received a copy of the GNU General Public License "
+        "along with System Monitor; if not, write to the Free Software Foundation, Inc., "
+        "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA")
+    };
+
+    gchar *license_trans;
+    license_trans = g_strjoin ("\n\n", _(license[0]), _(license[1]), _(license[2]), NULL);
+
+    gtk_show_about_dialog (
+        GTK_WINDOW (procdata->app),
+        "program-name",       _("System Monitor"),
+        "version",            VERSION,
+        "title",              _("About System Monitor"),
+        "comments",           _("View current processes and monitor system state"),
+        "copyright",          _("Copyright \xc2\xa9 2001-2004 Kevin Vandersloot\n"
+                                "Copyright \xc2\xa9 2005-2007 Benoît Dejean\n"
+                                "Copyright \xc2\xa9 2011-2020 MATE developers"),
+        "logo-icon-name",     "utilities-system-monitor",
+        "authors",            authors,
+        "artists",            artists,
+        "documenters",        documenters,
+        "translator-credits", _("translator-credits"),
+        "license",            license_trans,
+        "wrap-license",       TRUE,
+        "website",            PACKAGE_URL,
+        NULL
+        );
+
+    g_free (license_trans);
+}
+
+
+void
+cb_help_contents (GtkAction *action, gpointer data)
+{
+    GError* error = 0;
+    if (!g_app_info_launch_default_for_uri("help:mate-system-monitor", NULL, &error)) {
+        g_warning("Could not display help : %s", error->message);
+        g_error_free(error);
+    }
+}
+
+
+void
+cb_app_exit (GtkAction *action, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    cb_app_delete (NULL, NULL, procdata);
+    gtk_widget_destroy (procdata->app);
+}
+
+
+gboolean
+cb_app_delete (GtkWidget *window, GdkEventAny *event, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procman_save_config (procdata);
+    if (procdata->timeout)
+        g_source_remove (procdata->timeout);
+    if (procdata->disk_timeout)
+        g_source_remove (procdata->disk_timeout);
+
+    procdata->terminating = TRUE;
+
+    return FALSE;
+}
+
+
+
+void
+cb_end_process_button_pressed (GtkButton *button, gpointer data)
+{
+    kill_process_helper(static_cast<ProcData*>(data), SIGTERM);
+}
+
+
+static void change_settings_color(GSettings *settings, const char *key,
+                   GSMColorButton *cp)
+{
+    GdkRGBA c;
+    char *color;
+
+    gsm_color_button_get_color(cp, &c);
+    color = gdk_rgba_to_string (&c);
+    g_settings_set_string (settings, key, color);
+    g_free (color);
+}
+
+
+void
+cb_cpu_color_changed (GSMColorButton *cp, gpointer data)
+{
+    char key[80];
+    gint i = GPOINTER_TO_INT (data);
+    GSettings *settings = g_settings_new (GSM_GSETTINGS_SCHEMA);
+
+    g_snprintf(key, sizeof key, "cpu-color%d", i);
+
+    change_settings_color(settings, key, cp);
+}
+
+void
+cb_mem_color_changed (GSMColorButton *cp, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    change_settings_color(procdata->settings, "mem-color", cp);
+}
+
+
+void
+cb_swap_color_changed (GSMColorButton *cp, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    change_settings_color(procdata->settings, "swap-color", cp);
+}
+
+void
+cb_net_in_color_changed (GSMColorButton *cp, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    change_settings_color(procdata->settings, "net-in-color", cp);
+}
+
+void
+cb_net_out_color_changed (GSMColorButton *cp, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    change_settings_color(procdata->settings, "net-out-color", cp);
+}
+
+void
+cb_row_selected (GtkTreeSelection *selection, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->selection = selection;
+
+    procdata->selected_process = NULL;
+
+    /* get the most recent selected process and determine if there are
+    ** no selected processes
+    */
+    gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                         &procdata->selected_process);
+    if (procdata->selected_process) {
+        gint value;
+        gint nice = procdata->selected_process->nice;
+        if (nice < -7)
+            value = VERY_HIGH_PRIORITY;
+        else if (nice < -2)
+            value = HIGH_PRIORITY;
+        else if (nice < 3)
+            value = NORMAL_PRIORITY;
+        else if (nice < 7)
+            value = LOW_PRIORITY;
+        else
+            value = VERY_LOW_PRIORITY;
+
+        GtkRadioAction* normal = GTK_RADIO_ACTION(gtk_action_group_get_action(procdata->action_group, "Normal"));
+        block_priority_changed_handlers(procdata, TRUE);
+        gtk_radio_action_set_current_value(normal, value);
+        block_priority_changed_handlers(procdata, FALSE);
+
+    }
+    update_sensitivity(procdata);
+}
+
+
+gboolean
+cb_tree_button_pressed (GtkWidget *widget,
+            GdkEventButton *event,
+            gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
+        do_popup_menu (procdata, event);
+
+    return FALSE;
+}
+
+
+gboolean
+cb_tree_popup_menu (GtkWidget *widget, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    do_popup_menu (procdata, NULL);
+
+    return TRUE;
+}
+
+
+void
+cb_switch_page (GtkNotebook *nb, GtkWidget *page,
+        gint num, gpointer data)
+{
+    cb_change_current_page (nb, num, data);
+}
+
+void
+cb_change_current_page (GtkNotebook *nb, gint num, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->config.current_tab = num;
+
+
+    if (num == PROCMAN_TAB_PROCESSES) {
+
+        cb_timeout (procdata);
+
+        if (!procdata->timeout)
+            procdata->timeout = g_timeout_add (
+                procdata->config.update_interval,
+                cb_timeout, procdata);
+
+        update_sensitivity(procdata);
+    }
+    else {
+        if (procdata->timeout) {
+            g_source_remove (procdata->timeout);
+            procdata->timeout = 0;
+        }
+
+        update_sensitivity(procdata);
+    }
+
+
+    if (num == PROCMAN_TAB_RESOURCES) {
+        load_graph_start (procdata->cpu_graph);
+        load_graph_start (procdata->mem_graph);
+        load_graph_start (procdata->net_graph);
+    }
+    else {
+        load_graph_stop (procdata->cpu_graph);
+        load_graph_stop (procdata->mem_graph);
+        load_graph_stop (procdata->net_graph);
+    }
+
+
+    if (num == PROCMAN_TAB_DISKS) {
+
+        cb_update_disks (procdata);
+
+        if(!procdata->disk_timeout) {
+            procdata->disk_timeout =
+                g_timeout_add (procdata->config.disks_update_interval,
+                           cb_update_disks,
+                           procdata);
+        }
+    }
+    else {
+        if(procdata->disk_timeout) {
+            g_source_remove (procdata->disk_timeout);
+            procdata->disk_timeout = 0;
+        }
+    }
+
+    if (num == PROCMAN_TAB_SYSINFO) {
+        procman::build_sysinfo_ui();
+    }
+}
+
+
+
+gint
+cb_user_refresh (GtkAction*, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    proctable_update (procdata);
+    return FALSE;
+}
+
+
+gint
+cb_timeout (gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    guint new_interval;
+
+    if (!procdata->terminating) {
+        proctable_update (procdata);
+
+        if (procdata->smooth_refresh->get(new_interval))
+        {
+            procdata->timeout = g_timeout_add(new_interval,
+                                              cb_timeout,
+                                              procdata);
+            return FALSE;
+        }
+    }
+    return TRUE;
+}
+
+
+void
+cb_radio_processes(GtkAction *action, GtkRadioAction *current, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->config.whose_process = gtk_radio_action_get_current_value(current);
+
+    g_settings_set_int (procdata->settings, "view-as",
+                  procdata->config.whose_process);
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/20.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/20.html new file mode 100644 index 00000000..b439e9a1 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/20.html @@ -0,0 +1,1277 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __linux__
+#include <mntent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif // __linux__
+
+#include <giomm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/themedicon.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mountlist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/fsusage.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "disks.h"
+#include "util.h"
+#include "interface.h"
+#include "iconthemewrapper.h"
+
+namespace
+{
+  const unsigned DISK_ICON_SIZE = 24;
+}
+
+enum DiskColumns
+{
+    /* string columns* */
+    DISK_DEVICE,
+    DISK_DIR,
+    DISK_TYPE,
+    DISK_SUBVOLUME,
+    DISK_TOTAL,
+    DISK_FREE,
+    DISK_AVAIL,
+    /* USED has to be the last column */
+    DISK_USED,
+    // then unvisible columns
+    /* Surface column */
+    DISK_ICON,
+    /* numeric columns */
+    DISK_USED_PERCENTAGE,
+    DISK_N_COLUMNS
+};
+
+
+
+static void
+fsusage_stats(const glibtop_fsusage *buf,
+              guint64 *bused, guint64 *bfree, guint64 *bavail, guint64 *btotal,
+              gint *percentage)
+{
+    guint64 total = buf->blocks * buf->block_size;
+
+    if (!total) {
+        /* not a real device */
+        *btotal = *bfree = *bavail = *bused = 0ULL;
+        *percentage = 0;
+    } else {
+        int percent;
+        *btotal = total;
+        *bfree = buf->bfree * buf->block_size;
+        *bavail = buf->bavail * buf->block_size;
+        *bused = *btotal - *bfree;
+        /* percent = 100.0f * *bused / *btotal; */
+        percent = 100 * *bused / (*bused + *bavail);
+        *percentage = CLAMP(percent, 0, 100);
+    }
+}
+
+
+namespace
+{
+    string get_icon_for_path(const std::string& path)
+    {
+        using namespace Glib;
+        using namespace Gio;
+
+        // FIXME: I don't know whether i should use Volume or Mount or UnixMount
+        // all i need an icon name.
+        RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+        std::vector<RefPtr<Mount> > mounts = monitor->get_mounts();
+
+        for (size_t i = 0; i != mounts.size(); ++i) {
+            if (mounts[i]->get_name() != path)
+                continue;
+
+            RefPtr<Icon> icon = mounts[i]->get_icon();
+            RefPtr<ThemedIcon> themed_icon = RefPtr<ThemedIcon>::cast_dynamic(icon);
+
+            if (themed_icon) {
+                char* name = 0;
+                // FIXME: not wrapped yet
+                g_object_get(G_OBJECT(themed_icon->gobj()), "name", &name, NULL);
+                return make_string(name);
+            }
+        }
+
+        return "";
+    }
+}
+
+
+static Glib::RefPtr<Gdk::Pixbuf>
+get_icon_for_device(const char *mountpoint)
+{
+    procman::IconThemeWrapper icon_theme;
+    string icon_name = get_icon_for_path(mountpoint);
+    if (icon_name == "")
+        // FIXME: defaults to a safe value
+        icon_name = "drive-harddisk"; // get_icon_for_path("/");
+    return icon_theme->load_icon(icon_name, DISK_ICON_SIZE);
+}
+
+
+static gboolean
+find_disk_in_model(GtkTreeModel *model, const char *mountpoint,
+                   GtkTreeIter *result)
+{
+    GtkTreeIter iter;
+    gboolean found = FALSE;
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        do {
+            char *dir;
+
+            gtk_tree_model_get(model, &iter,
+                               DISK_DIR, &dir,
+                               -1);
+
+            if (dir && !strcmp(dir, mountpoint)) {
+                *result = iter;
+                found = TRUE;
+            }
+
+            g_free(dir);
+
+        } while (!found && gtk_tree_model_iter_next(model, &iter));
+    }
+
+    return found;
+}
+
+
+
+static void
+remove_old_disks(GtkTreeModel *model, const glibtop_mountentry *entries, guint n)
+{
+    GtkTreeIter iter;
+
+    if (!gtk_tree_model_get_iter_first(model, &iter))
+        return;
+
+    while (true) {
+        char *dir;
+        guint i;
+        gboolean found = FALSE;
+
+        gtk_tree_model_get(model, &iter,
+                           DISK_DIR, &dir,
+                           -1);
+
+        for (i = 0; i != n; ++i) {
+            if (!strcmp(dir, entries[i].mountdir)) {
+                found = TRUE;
+                break;
+            }
+        }
+
+        g_free(dir);
+
+        if (!found) {
+            if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                break;
+            else
+                continue;
+        }
+
+        if (!gtk_tree_model_iter_next(model, &iter))
+            break;
+    }
+}
+
+#ifdef __linux__
+static char *
+get_mount_opt(const glibtop_mountentry *entry, const char* opt)
+{
+    char *opt_value = NULL;
+    const struct mntent *mnt;
+    FILE *fp;
+
+    if (!(fp = setmntent(MOUNTED, "r"))) {
+        goto out;
+    }
+
+    while ((mnt = getmntent(fp))) {
+        if ((g_strcmp0(entry->mountdir, mnt->mnt_dir) == 0) &&
+            (g_strcmp0(entry->devname, mnt->mnt_fsname) == 0)) {
+            char *res;
+
+            res = hasmntopt(mnt, "subvol");<--- res is assigned
+            if ((res = hasmntopt(mnt, "subvol")) != NULL) {<--- res is overwritten
+                char **strs = g_strsplit_set(res, "=", 2);
+
+                if (g_strv_length(strs) == 2) {
+                    char *value = strs[1];
+                    if (g_strcmp0 (value,"/root") == 0)
+                       opt_value = g_strdup("/");
+                    else
+                        opt_value = g_strdup(strs[1]);
+                    g_strfreev(strs);
+                }
+            }
+            break;
+        }
+    }
+
+    endmntent(fp);
+
+  out:
+     return opt_value;
+}
+#endif // __linux__
+
+
+static void
+add_disk(GtkListStore *list, const glibtop_mountentry *entry, bool show_all_fs)
+{
+    Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+    cairo_surface_t *surface;
+    GtkTreeIter iter;
+    glibtop_fsusage usage;
+    guint64 bused, bfree, bavail, btotal;
+    gint percentage;
+#ifdef __linux__
+    char *subvol = NULL;
+#endif // __linux__
+
+    glibtop_get_fsusage(&usage, entry->mountdir);
+
+    if (not show_all_fs and usage.blocks == 0) {
+        if (find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+            gtk_list_store_remove(list, &iter);
+        return;
+    }
+
+    fsusage_stats(&usage, &bused, &bfree, &bavail, &btotal, &percentage);
+#ifdef __linux__
+    subvol = get_mount_opt(entry, "subvol");
+#endif // __linux__
+    pixbuf = get_icon_for_device(entry->mountdir);
+    surface = gdk_cairo_surface_create_from_pixbuf (pixbuf->gobj(), 0, NULL);
+
+    /* if we can find a row with the same mountpoint, we get it but we
+       still need to update all the fields.
+       This makes selection persistent.
+    */
+    if (!find_disk_in_model(GTK_TREE_MODEL(list), entry->mountdir, &iter))
+        gtk_list_store_append(list, &iter);
+
+    gtk_list_store_set(list, &iter,
+                       DISK_ICON, surface,
+                       DISK_DEVICE, entry->devname,
+                       DISK_DIR, entry->mountdir,
+                       DISK_TYPE, entry->type,
+#ifdef __linux__
+
+                       DISK_SUBVOLUME, subvol != NULL ? subvol : "",
+#else
+                       DISK_SUBVOLUME, "",
+#endif // __linux__
+                       DISK_USED_PERCENTAGE, percentage,
+                       DISK_TOTAL, btotal,
+                       DISK_FREE, bfree,
+                       DISK_AVAIL, bavail,
+                       DISK_USED, bused,
+                       -1);
+#ifdef __linux__
+    g_free (subvol);
+#endif // __linux__
+}
+
+
+
+int
+cb_update_disks(gpointer data)
+{
+    ProcData *const procdata = static_cast<ProcData*>(data);
+
+    GtkListStore *list;
+    glibtop_mountentry * entries;
+    glibtop_mountlist mountlist;
+    guint i;
+
+    list = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->disk_list)));
+
+    entries = glibtop_get_mountlist(&mountlist, procdata->config.show_all_fs);
+
+    remove_old_disks(GTK_TREE_MODEL(list), entries, mountlist.number);
+
+    for (i = 0; i < mountlist.number; i++)
+        add_disk(list, &entries[i], procdata->config.show_all_fs);
+
+    g_free(entries);
+
+    return TRUE;
+}
+
+
+static void
+cb_disk_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "disktreenew");
+}
+
+
+static void
+open_dir(GtkTreeView       *tree_view,
+         GtkTreePath       *path,
+         GtkTreeViewColumn *column,
+         gpointer           user_data)
+{
+    GtkTreeIter iter;
+    GtkTreeModel *model;
+    char *dir, *url;
+
+    model = gtk_tree_view_get_model(tree_view);
+
+    if (!gtk_tree_model_get_iter(model, &iter, path)) {
+        char *p;
+        p = gtk_tree_path_to_string(path);
+        g_warning("Cannot get iter for path '%s'\n", p);
+        g_free(p);
+        return;
+    }
+
+    gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);
+
+    url = g_strdup_printf("file://%s", dir);
+
+    GError* error = 0;
+    if (!g_app_info_launch_default_for_uri(url, NULL, &error)) {
+        g_warning("Cannot open '%s' : %s\n", url, error->message);
+        g_error_free(error);
+    }
+
+    g_free(url);
+    g_free(dir);
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "disktreenew");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_disks_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+void
+create_disk_view(ProcData *procdata, GtkBuilder *builder)
+{
+    GtkWidget *scrolled;
+    GtkWidget *disk_tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *col;
+    GtkCellRenderer *cell;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Device"),
+        N_("Directory"),
+        N_("Type"),
+        N_("SubVolume"),
+        N_("Total"),
+        N_("Free"),
+        N_("Available"),
+        N_("Used")
+    };
+
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "disks_scrolled"));
+
+    model = gtk_list_store_new(DISK_N_COLUMNS,             /* n columns */
+                               G_TYPE_STRING,              /* DISK_DEVICE */
+                               G_TYPE_STRING,              /* DISK_DIR */
+                               G_TYPE_STRING,              /* DISK_TYPE */
+                               G_TYPE_STRING,              /* DISK_SUBVOLUME */
+                               G_TYPE_UINT64,              /* DISK_TOTAL */
+                               G_TYPE_UINT64,              /* DISK_FREE */
+                               G_TYPE_UINT64,              /* DISK_AVAIL */
+                               G_TYPE_UINT64,              /* DISK_USED */
+                               CAIRO_GOBJECT_TYPE_SURFACE, /* DISK_ICON */
+                               G_TYPE_INT);                /* DISK_USED_PERCENTAGE */
+
+    disk_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_signal_connect(G_OBJECT(disk_tree), "row-activated", G_CALLBACK(open_dir), NULL);
+    procdata->disk_list = disk_tree;
+    gtk_container_add(GTK_CONTAINER(scrolled), disk_tree);
+    g_object_unref(G_OBJECT(model));
+
+    /* icon + device */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "surface", DISK_ICON,
+                                        NULL);
+
+    cell = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_attributes(col, cell, "text", DISK_DEVICE,
+                                        NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_DEVICE]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_DEVICE);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 30);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* sizes - used */
+
+    for (i = DISK_DIR; i <= DISK_AVAIL; i++) {
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_min_width (col, 30);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+        switch (i) {
+            case DISK_TOTAL:
+            case DISK_FREE:
+            case DISK_AVAIL:
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+        default:
+            gtk_tree_view_column_set_attributes(col, cell,
+                                                "text", i,
+                                                NULL);
+            break;
+        }
+    }
+
+    /* used + percentage */
+
+    col = gtk_tree_view_column_new();
+    cell = gtk_cell_renderer_text_new();
+    g_object_set(cell, "xalign", 1.0f, NULL);
+    gtk_tree_view_column_pack_start(col, cell, FALSE);
+    gtk_tree_view_column_set_cell_data_func(col, cell,
+                                            &procman::storage_size_cell_data_func,
+                                            GUINT_TO_POINTER(DISK_USED),
+                                            NULL);
+
+    cell = gtk_cell_renderer_progress_new();
+    gtk_tree_view_column_pack_start(col, cell, TRUE);
+    gtk_tree_view_column_set_attributes(col, cell, "value",
+                                        DISK_USED_PERCENTAGE, NULL);
+    gtk_tree_view_column_set_title(col, _(titles[DISK_USED]));
+    gtk_tree_view_column_set_sort_column_id(col, DISK_USED);
+    gtk_tree_view_column_set_reorderable(col, TRUE);
+    gtk_tree_view_column_set_resizable(col, TRUE);
+    gtk_tree_view_column_set_min_width (col, 150);
+    gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+    g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_disks_column_resized), procdata->settings);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(disk_tree), col);
+
+    /* numeric sort */
+
+    procman_get_tree_state(procdata->settings, disk_tree,
+                   "disktreenew");
+
+    g_signal_connect (G_OBJECT(disk_tree), "columns-changed",
+                      G_CALLBACK(cb_disk_columns_changed), procdata);
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/21.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/21.html new file mode 100644 index 00000000..16e22246 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/21.html @@ -0,0 +1,2141 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
+852
+853
+854
+855
+856
+857
+858
+859
+860
+861
+862
+863
+864
+865
+866
+867
+868
+869
+870
+871
+872
+873
+874
+875
+876
+877
+878
+879
+880
+881
+882
+883
+884
+885
+886
+887
+888
+889
+890
+891
+892
+893
+894
+895
+896
+897
+898
+899
+900
+901
+902
+903
+904
+905
+906
+907
+908
+909
+910
+911
+912
+913
+914
+915
+916
+917
+918
+919
+920
+921
+922
+923
+924
+925
+926
+927
+928
+929
+930
+931
+932
+933
+934
+935
+936
+937
+938
+939
+940
+941
+942
+943
+944
+945
+946
/*
+ * Mate system monitor color pickers
+ * Copyright (C) 2007 Karl Lattimer <karl@qdh.org.uk>
+ * Copyright (C) 2012-2021 MATE Developers
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with the software; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkkeysyms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <cairo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <librsvg/rsvg.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm_color_button.h"
+
+typedef struct {
+    GtkWidget *cc_dialog;		/* Color chooser dialog */
+
+    gchar *title;            /* Title for the color selection window */
+
+    GdkRGBA color;
+
+    gdouble fraction;        /* Only used by GSMCP_TYPE_PIE */
+    guint type;
+    cairo_surface_t *image_buffer;
+    gdouble highlight;
+    gboolean button_down;
+    gboolean in_button;
+} GSMColorButtonPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GSMColorButton, gsm_color_button, GTK_TYPE_DRAWING_AREA)
+
+/* Properties */
+enum
+{
+    PROP_0,
+    PROP_PERCENTAGE,
+    PROP_TITLE,
+    PROP_COLOR,
+    PROP_TYPE
+};
+
+/* Signals */
+enum
+{
+    COLOR_SET,
+    LAST_SIGNAL
+};
+
+#define GSMCP_MIN_WIDTH 15
+#define GSMCP_MIN_HEIGHT 15
+
+static void gsm_color_button_finalize (GObject * object);
+static void gsm_color_button_set_property (GObject * object, guint param_id,
+                                           const GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_get_property (GObject * object, guint param_id,
+                                           GValue * value,
+                                           GParamSpec * pspec);
+static void gsm_color_button_realize (GtkWidget * widget);
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width);
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height);
+static void gsm_color_button_size_allocate (GtkWidget * widget,
+                                            GtkAllocation * allocation);
+static void gsm_color_button_unrealize (GtkWidget * widget);
+static void gsm_color_button_state_changed (GtkWidget * widget,
+                                            GtkStateType previous_state);
+static void gsm_color_button_style_set (GtkWidget * widget,
+                                        GtkStyle * previous_style);
+static gint gsm_color_button_pressed (GtkWidget * widget,
+                                      GdkEventButton * event);
+static gint gsm_color_button_released (GtkWidget * widget,
+                                       GdkEventButton * event);
+static gboolean gsm_color_button_enter_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+static gboolean gsm_color_button_leave_notify (GtkWidget * widget,
+                                               GdkEventCrossing * event);
+/* source side drag signals */
+static void gsm_color_button_drag_begin (GtkWidget * widget,
+                                         GdkDragContext * context,
+                                         gpointer data);
+static void gsm_color_button_drag_data_get (GtkWidget * widget,
+                                            GdkDragContext * context,
+                                            GtkSelectionData * selection_data,
+                                            guint info, guint time,
+                                            GSMColorButton * color_button);
+
+/* target side drag signals */
+static void gsm_color_button_drag_data_received (GtkWidget * widget,
+                                                 GdkDragContext * context,
+                                                 gint x,
+                                                 gint y,
+                                                 GtkSelectionData *
+                                                 selection_data, guint info,
+                                                 guint32 time,
+                                                 GSMColorButton *
+                                                 color_button);
+
+static guint color_button_signals[LAST_SIGNAL] = { 0 };
+
+static const GtkTargetEntry drop_types[] = { {"application/x-color", 0, 0} };
+
+static void
+gsm_color_button_class_init (GSMColorButtonClass * klass)
+{
+    GObjectClass *gobject_class;
+    GtkWidgetClass *widget_class;
+
+    gobject_class = G_OBJECT_CLASS (klass);
+    widget_class = GTK_WIDGET_CLASS (klass);
+
+    gobject_class->get_property = gsm_color_button_get_property;
+    gobject_class->set_property = gsm_color_button_set_property;
+    gobject_class->finalize = gsm_color_button_finalize;
+    widget_class->state_changed = gsm_color_button_state_changed;
+    widget_class->get_preferred_width = gsm_color_button_get_preferred_width;
+    widget_class->get_preferred_height = gsm_color_button_get_preferred_height;
+    widget_class->size_allocate = gsm_color_button_size_allocate;
+    widget_class->realize = gsm_color_button_realize;
+    widget_class->unrealize = gsm_color_button_unrealize;
+    widget_class->style_set = gsm_color_button_style_set;
+    widget_class->button_release_event = gsm_color_button_released;
+    widget_class->button_press_event = gsm_color_button_pressed;<--- You might need to cast the function pointer here
+    widget_class->enter_notify_event = gsm_color_button_enter_notify;
+    widget_class->leave_notify_event = gsm_color_button_leave_notify;
+
+    klass->color_set = NULL;
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_PERCENTAGE,
+                                     g_param_spec_double ("fraction",
+                                                          _("Fraction"),
+                                     // TRANSLATORS: description of the pie color picker's (mem, swap) filled percentage property
+                                                          _("Percentage full for pie color pickers"),
+                                                          0, 1, 0.5,
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TITLE,
+                                     g_param_spec_string ("title",
+                                                          _("Title"),
+                                                          _("The title of the color selection dialog"),
+                                                          _("Pick a Color"),
+                                                          G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_COLOR,
+                                     g_param_spec_boxed ("color",
+                                                         _("Current Color"),
+                                                         _("The selected color"),
+                                                         GDK_TYPE_RGBA,
+                                                         G_PARAM_READWRITE));
+
+    g_object_class_install_property (gobject_class,
+                                     PROP_TYPE,
+                                     g_param_spec_uint ("type", _("Type"),
+                                                        _("Type of color picker"),
+                                                        0, 4, 0,
+                                                        G_PARAM_READWRITE));
+
+    color_button_signals[COLOR_SET] = g_signal_new ("color_set",
+                                                    G_TYPE_FROM_CLASS
+                                                    (gobject_class),
+                                                    G_SIGNAL_RUN_FIRST,
+                                                    G_STRUCT_OFFSET
+                                                    (GSMColorButtonClass,
+                                                    color_set), NULL, NULL,
+                                                    g_cclosure_marshal_VOID__VOID,
+                                                    G_TYPE_NONE, 0);
+
+}
+
+static cairo_surface_t *
+fill_image_buffer_from_file (cairo_t *cr, const char *filePath)
+{
+    GError *error = NULL;
+    RsvgHandle *handle;
+    cairo_surface_t *tmp_surface;
+    cairo_t *tmp_cr;
+
+    handle = rsvg_handle_new_from_file (filePath, &error);
+
+    if (handle == NULL) {
+        g_warning("rsvg_handle_new_from_file(\"%s\") failed: %s",
+              filePath, (error ? error->message : "unknown error"));
+    if (error)
+          g_error_free(error);
+    return NULL;
+    }
+
+    tmp_surface = cairo_surface_create_similar (cairo_get_target (cr),
+                                                CAIRO_CONTENT_COLOR_ALPHA,
+                                                32, 32);
+    tmp_cr = cairo_create (tmp_surface);
+    rsvg_handle_render_cairo (handle, tmp_cr);
+    cairo_destroy (tmp_cr);
+    g_object_unref (handle);
+    return tmp_surface;
+}
+
+static void
+render (GtkWidget * widget)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GdkRGBA *color;
+    GdkRGBA tmp_color = priv->color;
+    color = &tmp_color;
+    cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
+    cairo_path_t *path = NULL;
+    gint width, height;
+    gdouble radius, arc_start, arc_end;
+    gdouble highlight_factor;
+
+    if (priv->highlight > 0) {
+        highlight_factor = 0.125 * priv->highlight;
+
+    if (color->red + highlight_factor > 1.0)
+        color->red = 1.0;
+    else
+        color->red = color->red + highlight_factor;
+
+    if (color->blue + highlight_factor > 1.0)
+        color->blue = 1.0;
+    else
+      color->blue = color->blue + highlight_factor;
+
+    if (color->green + highlight_factor > 1.0)
+        color->green = 1.0;
+    else
+        color->green = color->green + highlight_factor;
+    }
+    gdk_cairo_set_source_rgba (cr, color);
+
+    width = gdk_window_get_width(gtk_widget_get_window(widget));
+    height = gdk_window_get_height(gtk_widget_get_window(widget));
+
+    switch (priv->type)
+        {
+        case GSMCP_TYPE_CPU:
+            //gtk_widget_set_size_request (widget, GSMCP_MIN_WIDTH, GSMCP_MIN_HEIGHT);
+            cairo_paint (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1);
+            cairo_stroke (cr);
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.4);
+            cairo_rectangle (cr, 1.5, 1.5, width - 3, height - 3);
+            cairo_stroke (cr);
+            break;
+        case GSMCP_TYPE_PIE:
+            if (width < 32)        // 32px minimum size
+                gtk_widget_set_size_request (widget, 32, 32);
+            if (width < height)
+                radius = width / 2;
+            else
+                radius = height / 2;
+
+            arc_start = -G_PI_2 + 2 * G_PI * priv->fraction;
+            arc_end = -G_PI_2;
+
+            cairo_set_line_width (cr, 1);
+
+            // Draw external stroke and fill
+            if (priv->fraction < 0.01) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_end);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 4.5,
+                    arc_end, arc_start);
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 2.25,
+                    arc_start, arc_start);
+            }
+            cairo_fill_preserve (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.7);
+            cairo_stroke (cr);
+
+            // Draw internal highlight
+            cairo_set_source_rgba (cr, 1, 1, 1, 0.45);
+            cairo_set_line_width (cr, 1);
+
+            if (priv->fraction < 0.03) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    0, 2 * G_PI);
+            } else if (priv->fraction > 0.99) {
+                cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    0, 2 * G_PI);
+            } else {
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_end - (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, 3.25,
+                    arc_end - (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+                cairo_arc_negative (cr, (width / 2) + .5, (height / 2) + .5, radius - 3.5,
+                    arc_start + (1 / (radius - 3.75)),
+                    arc_start + (1 / (radius - 3.75)));
+            }
+            cairo_stroke (cr);
+
+            // Draw external shape
+            cairo_set_line_width (cr, 1);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.2);
+            cairo_arc (cr, (width / 2) + .5, (height / 2) + .5, radius - 1.25, 0,
+                G_PI * 2);
+            cairo_stroke (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_IN:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                    fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/download.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 8.5, 1.5);
+            cairo_line_to (cr, 23.5, 1.5);
+            cairo_line_to (cr, 23.5, 11.5);
+            cairo_line_to (cr, 29.5, 11.5);
+            cairo_line_to (cr, 16.5, 27.5);
+            cairo_line_to (cr, 15.5, 27.5);
+            cairo_line_to (cr, 2.5, 11.5);
+            cairo_line_to (cr, 8.5, 11.5);
+            cairo_line_to (cr, 8.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        case GSMCP_TYPE_NETWORK_OUT:
+            if (priv->image_buffer == NULL)
+                priv->image_buffer =
+                fill_image_buffer_from_file (cr, DATADIR "/pixmaps/mate-system-monitor/upload.svg");
+            gtk_widget_set_size_request (widget, 32, 32);
+            cairo_move_to (cr, 16.5, 1.5);
+            cairo_line_to (cr, 29.5, 17.5);
+            cairo_line_to (cr, 23.5, 17.5);
+            cairo_line_to (cr, 23.5, 27.5);
+            cairo_line_to (cr, 8.5, 27.5);
+            cairo_line_to (cr, 8.5, 17.5);
+            cairo_line_to (cr, 2.5, 17.5);
+            cairo_line_to (cr, 15.5, 1.5);
+            cairo_line_to (cr, 16.5, 1.5);
+            cairo_close_path (cr);
+            path = cairo_copy_path (cr);
+            cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+            cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
+            cairo_set_line_width (cr, 1);
+            cairo_fill_preserve (cr);
+            cairo_set_miter_limit (cr, 5.0);
+            cairo_stroke (cr);
+            cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+            cairo_append_path (cr, path);
+            cairo_path_destroy(path);
+            cairo_stroke (cr);
+            cairo_set_source_surface (cr, priv->image_buffer, 0.0,
+                0.0);
+            cairo_paint (cr);
+
+            break;
+        }
+    cairo_destroy (cr);
+}
+
+/* Handle exposure events for the color picker's drawing area */
+static gboolean draw (GtkWidget * widget, cairo_t * cr, gpointer data)
+{
+    render (GTK_WIDGET (data));
+
+    return FALSE;
+}
+
+static void
+gsm_color_button_realize (GtkWidget * widget)
+{
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->realize (widget);
+    render (widget);
+}
+
+static void gsm_color_button_get_preferred_width (GtkWidget * widget, gint * minimum_width, gint * natural_width)
+{
+    g_return_if_fail (widget != NULL && minimum_width != NULL && natural_width != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_width = GSMCP_MIN_WIDTH;
+    *natural_width = GSMCP_MIN_WIDTH;
+}
+static void gsm_color_button_get_preferred_height (GtkWidget * widget, gint * minimum_height, gint * natural_height)
+{
+    g_return_if_fail (widget != NULL && minimum_height != NULL && natural_height != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    *minimum_height = GSMCP_MIN_HEIGHT;
+    *natural_height = GSMCP_MIN_HEIGHT;
+}
+
+static void
+gsm_color_button_size_allocate (GtkWidget * widget,
+                                GtkAllocation * allocation)
+{
+    g_return_if_fail (widget != NULL || allocation != NULL);
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
+
+    gtk_widget_set_allocation (widget, allocation);
+
+    if (gtk_widget_get_realized (widget))
+    {
+        gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y,
+                                allocation->width, allocation->height);
+    }
+}
+
+static void
+gsm_color_button_unrealize (GtkWidget * widget)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->unrealize (widget);
+}
+
+static void
+gsm_color_button_style_set (GtkWidget * widget, GtkStyle * previous_style)
+{
+
+    GTK_WIDGET_CLASS (gsm_color_button_parent_class)->style_set (widget,
+                                                                 previous_style);
+
+}
+
+static void
+gsm_color_button_state_changed (GtkWidget * widget,
+                                GtkStateType previous_state)
+{
+}
+
+static void
+gsm_color_button_drag_data_received (GtkWidget * widget,
+                                     GdkDragContext * context,
+                                     gint x,
+                                     gint y,
+                                     GtkSelectionData * selection_data,
+                                     guint info,
+                                     guint32 time,
+                                     GSMColorButton * color_button)
+{
+    gint length;
+    guint16 *dropped;
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    length = gtk_selection_data_get_length (selection_data);
+
+    if (length < 0)
+        return;
+
+    /* We accept drops with the wrong format, since the KDE color
+     * chooser incorrectly drops application/x-color with format 8.
+     */
+    if (length != 8)
+    {
+        g_warning (_("Received invalid color data\n"));
+        return;
+    }
+
+    dropped = (guint16 *) gtk_selection_data_get_data (selection_data);
+
+    priv->color.red =   ((double) dropped[0]) / 65535.0;
+    priv->color.green = ((double) dropped[1]) / 65535.0;
+    priv->color.blue =  ((double) dropped[2]) / 65535.0;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+    g_object_freeze_notify (G_OBJECT (color_button));
+    g_object_notify (G_OBJECT (color_button), "color");
+    g_object_thaw_notify (G_OBJECT (color_button));
+}
+
+static void
+set_color_icon (GdkDragContext * context, GdkRGBA * color)<--- Parameter 'color' can be declared as pointer to const
+{
+    GdkPixbuf *pixbuf;
+    guint32 pixel;
+
+    pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 48, 32);
+
+    pixel = ((guint32)(color->red * 0xff) << 24) |
+            ((guint32)(color->green * 0xff) << 16) |
+            ((guint32)(color->blue * 0xff) << 8);
+
+    gdk_pixbuf_fill (pixbuf, pixel);
+
+    gtk_drag_set_icon_pixbuf (context, pixbuf, -2, -2);
+    g_object_unref (pixbuf);
+}
+
+static void
+gsm_color_button_drag_begin (GtkWidget * widget,
+                             GdkDragContext * context, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = data;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    set_color_icon (context, &priv->color);
+}
+
+static void
+gsm_color_button_drag_data_get (GtkWidget * widget,
+                                GdkDragContext * context,
+                                GtkSelectionData * selection_data,
+                                guint info,
+                                guint time, GSMColorButton * color_button)
+{
+    guint16 dropped[4];
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    dropped[0] = (guint16) (65535.0 * priv->color.red);
+    dropped[1] = (guint16) (65535.0 * priv->color.green);
+    dropped[2] = (guint16) (65535.0 * priv->color.blue);
+    dropped[3] = 65535;        // This widget doesn't care about alpha
+
+    gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data),
+                            16, (guchar *) dropped, 8);
+}
+
+static void
+gsm_color_button_init (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = 0;
+    priv->color.green = 0;
+    priv->color.blue = 0;
+    priv->fraction = 0.5;
+    priv->type = GSMCP_TYPE_CPU;
+    priv->image_buffer = NULL;
+    priv->title = g_strdup (_("Pick a Color"));     /* default title */
+    priv->in_button = FALSE;
+    priv->button_down = FALSE;
+
+    gtk_drag_dest_set (GTK_WIDGET (color_button),
+                       GTK_DEST_DEFAULT_MOTION |
+                       GTK_DEST_DEFAULT_HIGHLIGHT |
+                       GTK_DEST_DEFAULT_DROP, drop_types, 1, GDK_ACTION_COPY);
+    gtk_drag_source_set (GTK_WIDGET (color_button),
+                         GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
+                         drop_types, 1, GDK_ACTION_COPY);
+    g_signal_connect (color_button, "drag_begin",
+                      G_CALLBACK (gsm_color_button_drag_begin), color_button);
+    g_signal_connect (color_button, "drag_data_received",
+                      G_CALLBACK (gsm_color_button_drag_data_received),
+                      color_button);
+    g_signal_connect (color_button, "drag_data_get",
+                      G_CALLBACK (gsm_color_button_drag_data_get),
+                      color_button);
+
+    gtk_widget_add_events (GTK_WIDGET(color_button), GDK_ENTER_NOTIFY_MASK
+                              | GDK_LEAVE_NOTIFY_MASK);
+
+    gtk_widget_set_tooltip_text (GTK_WIDGET(color_button), _("Click to set graph colors"));
+
+    g_signal_connect (color_button, "draw", G_CALLBACK (draw), color_button);
+}
+
+static void
+gsm_color_button_finalize (GObject * object)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    if (priv->cc_dialog != NULL)
+        gtk_widget_destroy (priv->cc_dialog);
+    priv->cc_dialog = NULL;
+
+    g_free (priv->title);
+    priv->title = NULL;
+
+    cairo_surface_destroy (priv->image_buffer);
+    priv->image_buffer = NULL;
+
+    G_OBJECT_CLASS (gsm_color_button_parent_class)->finalize (object);
+}
+
+GtkWidget *
+gsm_color_button_new (const GdkRGBA * color, guint type)
+{
+    return g_object_new (GSM_TYPE_COLOR_BUTTON, "color", color, "type", type,
+                         NULL);
+}
+
+static void
+dialog_response (GtkWidget * widget, GtkResponseType response, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    GtkColorChooser *color_chooser;
+
+    if (response == GTK_RESPONSE_OK) {
+        color_chooser = GTK_COLOR_CHOOSER (priv->cc_dialog);
+
+        gtk_color_chooser_get_rgba (color_chooser, &priv->color);
+
+        gtk_widget_hide (priv->cc_dialog);
+
+        gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+        g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+        g_object_freeze_notify (G_OBJECT (color_button));
+        g_object_notify (G_OBJECT (color_button), "color");
+        g_object_thaw_notify (G_OBJECT (color_button));
+    }
+    else  /* (response == GTK_RESPONSE_CANCEL) */
+        gtk_widget_hide (priv->cc_dialog);
+}
+
+static gboolean
+dialog_destroy (GtkWidget * widget, gpointer data)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (data);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->cc_dialog = NULL;
+
+    return FALSE;
+}
+
+static gint
+gsm_color_button_clicked (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    /* if dialog already exists, make sure it's shown and raised */
+    if (!priv->cc_dialog)
+    {
+        /* Create the dialog and connects its buttons */
+        GtkWidget *cc_dialog;
+        GtkWidget *parent;
+
+        parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));
+        if (!gtk_widget_is_toplevel (parent))
+            parent = NULL;
+
+        cc_dialog = gtk_color_chooser_dialog_new (priv->title, GTK_WINDOW (parent));
+
+        gtk_window_set_modal (GTK_WINDOW (cc_dialog), TRUE);
+
+        g_signal_connect (cc_dialog, "response",
+                          G_CALLBACK (dialog_response), color_button);
+
+        g_signal_connect (cc_dialog, "destroy",
+                          G_CALLBACK (dialog_destroy), color_button);
+
+        priv->cc_dialog = cc_dialog;
+    }
+
+    gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (priv->cc_dialog),
+                                &priv->color);
+
+    gtk_window_present (GTK_WINDOW (priv->cc_dialog));
+
+    return 0;
+}
+
+static gint
+gsm_color_button_pressed (GtkWidget * widget, GdkEventButton * event)<--- Parameter 'event' can be declared as pointer to const
+{
+    if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) )
+    {
+	GSMColorButtonPrivate *priv;
+        GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+	priv = gsm_color_button_get_instance_private (color_button);
+	priv->button_down = TRUE;
+    }
+  return 0;
+}
+
+static gint
+gsm_color_button_released (GtkWidget * widget, GdkEventButton * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    if (priv->button_down && priv->in_button)
+        gsm_color_button_clicked (widget, event);
+    priv->button_down = FALSE;
+    return 0;
+}
+
+static gboolean
+gsm_color_button_enter_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButtonPrivate *priv;
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 1.0;
+    priv->in_button = TRUE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+static gboolean
+gsm_color_button_leave_notify (GtkWidget * widget, GdkEventCrossing * event)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (widget);
+    GSMColorButtonPrivate *priv;
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    priv->highlight = 0;
+    priv->in_button = FALSE;
+    gtk_widget_queue_draw(widget);
+    return FALSE;
+}
+
+guint
+gsm_color_button_get_cbtype (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;<--- Variable 'priv' can be declared as pointer to const
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->type;
+}
+
+void
+gsm_color_button_set_cbtype (GSMColorButton * color_button, guint type)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->type = type;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "type");
+}
+
+gdouble
+gsm_color_button_get_fraction (GSMColorButton * color_button)
+{
+    GSMColorButtonPrivate *priv;<--- Variable 'priv' can be declared as pointer to const
+    g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->fraction;
+}
+
+void
+gsm_color_button_set_fraction (GSMColorButton * color_button,
+                               gdouble fraction)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->fraction = fraction;
+
+    gtk_widget_queue_draw (GTK_WIDGET(color_button));
+
+    g_object_notify (G_OBJECT (color_button), "fraction");
+}
+
+void
+gsm_color_button_get_color (GSMColorButton * color_button, GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+
+    priv = gsm_color_button_get_instance_private (color_button);
+    color->red = priv->color.red;
+    color->green = priv->color.green;
+    color->blue = priv->color.blue;
+    color->alpha = priv->color.alpha;
+}
+
+void
+gsm_color_button_set_color (GSMColorButton * color_button,
+                            const GdkRGBA * color)
+{
+    GSMColorButtonPrivate *priv;
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    g_return_if_fail (color != NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    priv->color.red = color->red;
+    priv->color.green = color->green;
+    priv->color.blue = color->blue;
+    priv->color.alpha = color->alpha;
+
+    gtk_widget_queue_draw (GTK_WIDGET (color_button));
+
+    g_object_notify (G_OBJECT (color_button), "color");
+}
+
+void
+gsm_color_button_set_title (GSMColorButton * color_button,
+                            const gchar * title)
+{
+    gchar *old_title;
+    GSMColorButtonPrivate *priv;
+
+    g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    old_title = priv->title;
+    priv->title = g_strdup (title);
+    g_free (old_title);
+
+    if (priv->cc_dialog)
+        gtk_window_set_title (GTK_WINDOW (priv->cc_dialog),
+                              priv->title);
+
+    g_object_notify (G_OBJECT (color_button), "title");
+}
+
+const gchar* gsm_color_button_get_title(GSMColorButton* color_button)
+{
+    GSMColorButtonPrivate *priv;<--- Variable 'priv' can be declared as pointer to const
+    g_return_val_if_fail(GSM_IS_COLOR_BUTTON(color_button), NULL);
+
+    priv = gsm_color_button_get_instance_private (color_button);
+
+    return priv->title;
+}
+
+static void
+gsm_color_button_set_property (GObject * object,
+                               guint param_id,
+                               const GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            gsm_color_button_set_fraction (color_button,
+                                           g_value_get_double (value));
+            break;
+        case PROP_TITLE:
+            gsm_color_button_set_title (color_button, g_value_get_string (value));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_set_color (color_button, g_value_get_boxed (value));
+            break;
+        case PROP_TYPE:
+            gsm_color_button_set_cbtype (color_button, g_value_get_uint (value));
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+static void
+gsm_color_button_get_property (GObject * object,
+                               guint param_id,
+                               GValue * value, GParamSpec * pspec)
+{
+    GSMColorButton *color_button = GSM_COLOR_BUTTON (object);
+    GdkRGBA color;
+
+    switch (param_id)
+    {
+        case PROP_PERCENTAGE:
+            g_value_set_double (value,
+                                gsm_color_button_get_fraction (color_button));
+            break;
+        case PROP_TITLE:
+            g_value_set_string (value, gsm_color_button_get_title (color_button));
+            break;
+        case PROP_COLOR:
+            gsm_color_button_get_color (color_button, &color);
+                                        g_value_set_boxed (value, &color);
+            break;
+        case PROP_TYPE:
+            g_value_set_uint (value, gsm_color_button_get_cbtype (color_button));
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+            break;
+    }
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/22.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/22.html new file mode 100644 index 00000000..2b023104 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/22.html @@ -0,0 +1,351 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtkmm/icontheme.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/error.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "iconthemewrapper.h"
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+procman::IconThemeWrapper::load_icon(const Glib::ustring& icon_name, int size) const
+{
+    gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
+    try
+    {
+      return Gtk::IconTheme::get_default()->load_icon(icon_name, size, scale, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
+    }
+    catch (Gtk::IconThemeError &error)
+    {
+        if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
+            g_error("Cannot load icon '%s' from theme: %s", icon_name.c_str(), error.what().c_str());
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+    catch (Gio::Error &error)
+    {
+        g_debug("Could not load icon '%s' : %s", icon_name.c_str(), error.what().c_str());
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+}
+
+Glib::RefPtr<Gdk::Pixbuf>
+procman::IconThemeWrapper::load_gicon(const Glib::RefPtr<Gio::Icon>& gicon,
+                                      int size, Gtk::IconLookupFlags flags) const
+{
+    Gtk::IconInfo icon_info;
+    gint scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
+    icon_info = Gtk::IconTheme::get_default()->lookup_icon(gicon, size, scale, flags);
+
+    if (!icon_info) {
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+
+    try
+    {
+        return icon_info.load_icon();
+    }
+    catch (Gtk::IconThemeError &error)
+    {
+        if (error.code() != Gtk::IconThemeError::ICON_THEME_NOT_FOUND)
+            g_error("Cannot load gicon from theme: %s", error.what().c_str());
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+    catch (Gio::Error &error)
+    {
+        g_debug("Could not load gicon: %s", error.what().c_str());
+        return Glib::RefPtr<Gdk::Pixbuf>();
+    }
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/23.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/23.html new file mode 100644 index 00000000..33a85a1c --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/23.html @@ -0,0 +1,1599 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
/* Procman - main window
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkkeysyms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "callbacks.h"
+#include "interface.h"
+#include "proctable.h"
+#include "procactions.h"
+#include "load-graph.h"
+#include "util.h"
+#include "disks.h"
+#include "sysinfo.h"
+#include "gsm_color_button.h"
+
+static void    cb_toggle_tree (GtkAction *action, gpointer data);
+static void    cb_proc_goto_tab (gint tab);
+
+static const GtkActionEntry menu_entries[] =
+{
+    // xgettext: noun, top level menu.
+    // "File" did not make sense for system-monitor
+    { "Monitor", NULL, N_("_Monitor") },
+    { "Edit", NULL, N_("_Edit") },
+    { "View", NULL, N_("_View") },
+    { "Help", NULL, N_("_Help") },
+
+    { "Lsof", "edit-find", N_("Search for _Open Files"), "<control>O",
+      N_("Search for open files"), G_CALLBACK(cb_show_lsof) },
+    { "Quit", "application-exit", N_("_Quit"), "<control>Q",
+      N_("Quit the program"), G_CALLBACK (cb_app_exit) },
+
+
+    { "StopProcess", NULL, N_("_Stop Process"), "<control>S",
+      N_("Stop process"), G_CALLBACK(cb_kill_sigstop) },
+    { "ContProcess", NULL, N_("_Continue Process"), "<control>C",
+      N_("Continue process if stopped"), G_CALLBACK(cb_kill_sigcont) },
+
+    { "EndProcess", NULL, N_("_End Process"), "<control>E",
+      N_("Force process to finish normally"), G_CALLBACK (cb_end_process) },
+    { "KillProcess", NULL, N_("_Kill Process"), "<control>K",
+      N_("Force process to finish immediately"), G_CALLBACK (cb_kill_process) },
+    { "ChangePriority", NULL, N_("_Change Priority"), NULL,
+      N_("Change the order of priority of process"), NULL },
+    { "Preferences", "preferences-desktop", N_("_Preferences"), NULL,
+      N_("Configure the application"), G_CALLBACK (cb_edit_preferences) },
+
+    { "Refresh", "view-refresh", N_("_Refresh"), "<control>R",
+      N_("Refresh the process list"), G_CALLBACK(cb_user_refresh) },
+
+    { "MemoryMaps", NULL, N_("_Memory Maps"), "<control>M",
+      N_("Open the memory maps associated with a process"), G_CALLBACK (cb_show_memory_maps) },
+    // Translators: this means 'Files that are open' (open is no verb here
+    { "OpenFiles", NULL, N_("Open _Files"), "<control>F",
+      N_("View the files opened by a process"), G_CALLBACK (cb_show_open_files) },
+    { "ProcessProperties", NULL, N_("_Properties"), NULL,
+      N_("View additional information about a process"), G_CALLBACK (cb_show_process_properties) },
+
+
+    { "HelpContents", "help-browser", N_("_Contents"), "F1",
+      N_("Open the manual"), G_CALLBACK (cb_help_contents) },
+    { "About", "help-about", N_("_About"), NULL,
+      N_("About this application"), G_CALLBACK (cb_about) }
+};
+
+static const GtkToggleActionEntry toggle_menu_entries[] =
+{
+    { "ShowDependencies", NULL, N_("_Dependencies"), "<control>D",
+      N_("Show parent/child relationship between processes"),
+      G_CALLBACK (cb_toggle_tree), TRUE },
+};
+
+
+static const GtkRadioActionEntry radio_menu_entries[] =
+{
+  { "ShowActiveProcesses", NULL, N_("_Active Processes"), NULL,
+    N_("Show active processes"), ACTIVE_PROCESSES },
+  { "ShowAllProcesses", NULL, N_("A_ll Processes"), NULL,
+    N_("Show all processes"), ALL_PROCESSES },
+  { "ShowMyProcesses", NULL, N_("M_y Processes"), NULL,
+    N_("Show only user-owned processes"), MY_PROCESSES }
+};
+
+static const GtkRadioActionEntry priority_menu_entries[] =
+{
+    { "VeryHigh", NULL, N_("Very High"), NULL,
+      N_("Set process priority to very high"), VERY_HIGH_PRIORITY },
+    { "High", NULL, N_("High"), NULL,
+      N_("Set process priority to high"), HIGH_PRIORITY },
+    { "Normal", NULL, N_("Normal"), NULL,
+      N_("Set process priority to normal"), NORMAL_PRIORITY },
+    { "Low", NULL, N_("Low"), NULL,
+      N_("Set process priority to low"), LOW_PRIORITY },
+    { "VeryLow", NULL, N_("Very Low"), NULL,
+      N_("Set process priority to very low"), VERY_LOW_PRIORITY },
+    { "Custom", NULL, N_("Custom"), NULL,
+      N_("Set process priority manually"), CUSTOM_PRIORITY }
+};
+
+
+static const char ui_info[] =
+    "  <menubar name=\"MenuBar\">"
+    "    <menu name=\"MonitorMenu\" action=\"Monitor\">"
+    "      <menuitem name=\"MonitorLsofMenu\" action=\"Lsof\" />"
+    "      <menuitem name=\"MonitorQuitMenu\" action=\"Quit\" />"
+    "    </menu>"
+    "    <menu name=\"EditMenu\" action=\"Edit\">"
+    "      <menuitem name=\"EditStopProcessMenu\" action=\"StopProcess\" />"
+    "      <menuitem name=\"EditContProcessMenu\" action=\"ContProcess\" />"
+    "      <separator />"
+    "      <menuitem name=\"EditEndProcessMenu\" action=\"EndProcess\" />"
+    "      <menuitem name=\"EditKillProcessMenu\" action=\"KillProcess\" />"
+    "      <separator />"
+    "      <menu name=\"EditChangePriorityMenu\" action=\"ChangePriority\" >"
+    "        <menuitem action=\"VeryHigh\" />"
+    "        <menuitem action=\"High\" />"
+    "        <menuitem action=\"Normal\" />"
+    "        <menuitem action=\"Low\" />"
+    "        <menuitem action=\"VeryLow\" />"
+    "        <separator />"
+    "        <menuitem action=\"Custom\"/>"
+    "      </menu>"
+    "      <separator />"
+    "      <menuitem name=\"EditPreferencesMenu\" action=\"Preferences\" />"
+    "    </menu>"
+    "    <menu name=\"ViewMenu\" action=\"View\">"
+    "      <menuitem name=\"ViewActiveProcesses\" action=\"ShowActiveProcesses\" />"
+    "      <menuitem name=\"ViewAllProcesses\" action=\"ShowAllProcesses\" />"
+    "      <menuitem name=\"ViewMyProcesses\" action=\"ShowMyProcesses\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewDependenciesMenu\" action=\"ShowDependencies\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewMemoryMapsMenu\" action=\"MemoryMaps\" />"
+    "      <menuitem name=\"ViewOpenFilesMenu\" action=\"OpenFiles\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewProcessPropertiesMenu\" action=\"ProcessProperties\" />"
+    "      <separator />"
+    "      <menuitem name=\"ViewRefresh\" action=\"Refresh\" />"
+    "    </menu>"
+    "    <menu name=\"HelpMenu\" action=\"Help\">"
+    "      <menuitem name=\"HelpContentsMenu\" action=\"HelpContents\" />"
+    "      <menuitem name=\"HelpAboutMenu\" action=\"About\" />"
+    "    </menu>"
+    "  </menubar>"
+    "  <popup name=\"PopupMenu\" action=\"Popup\">"
+    "    <menuitem action=\"StopProcess\" />"
+    "    <menuitem action=\"ContProcess\" />"
+    "    <separator />"
+    "    <menuitem action=\"EndProcess\" />"
+    "    <menuitem action=\"KillProcess\" />"
+    "    <separator />"
+    "    <menu name=\"ChangePriorityMenu\" action=\"ChangePriority\" >"
+    "      <menuitem action=\"VeryHigh\" />"
+    "      <menuitem action=\"High\" />"
+    "      <menuitem action=\"Normal\" />"
+    "      <menuitem action=\"Low\" />"
+    "      <menuitem action=\"VeryLow\" />"
+    "      <separator />"
+    "      <menuitem action=\"Custom\"/>"
+    "    </menu>"
+    "    <separator />"
+    "    <menuitem action=\"MemoryMaps\" />"
+    "    <menuitem action=\"OpenFiles\" />"
+    "    <separator />"
+    "    <menuitem action=\"ProcessProperties\" />"
+
+    "  </popup>";
+
+
+static void
+create_proc_view(ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *proctree;
+    GtkWidget *scrolled;
+    char* string;
+
+    /* create the processes tab */
+    string = make_loadavg_string ();
+    procdata->loadavg = GTK_WIDGET (gtk_builder_get_object (builder, "load_avg_label"));
+    gtk_label_set_text (GTK_LABEL (procdata->loadavg), string);
+    g_free (string);
+
+    proctree = proctable_new (procdata);
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "processes_scrolled"));
+
+    gtk_container_add (GTK_CONTAINER (scrolled), proctree);
+
+    procdata->endprocessbutton = GTK_WIDGET (gtk_builder_get_object (builder, "endprocessbutton"));
+    g_signal_connect (G_OBJECT (procdata->endprocessbutton), "clicked",
+                      G_CALLBACK (cb_end_process_button_pressed), procdata);
+
+    /* create popup_menu for the processes tab */
+    procdata->popup_menu = gtk_ui_manager_get_widget (procdata->uimanager, "/PopupMenu");
+}
+
+
+GtkWidget *
+make_title_label (const char *text)
+{
+    GtkWidget *label;
+    char *full;
+
+    full = g_strdup_printf ("<span weight=\"bold\">%s</span>", text);
+    label = gtk_label_new (full);
+    g_free (full);
+
+    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+
+    return label;
+}
+
+
+static void
+create_sys_view (ProcData *procdata, GtkBuilder * builder)
+{
+    GtkWidget *cpu_graph_box, *mem_graph_box, *net_graph_box;
+    GtkWidget *label,*cpu_label;
+    GtkWidget *table;
+    GtkWidget *color_picker;
+    GtkWidget *picker_alignment;
+    LoadGraph *cpu_graph, *mem_graph, *net_graph;
+
+    gint i;
+    gchar *title_text;
+    gchar *label_text;
+    gchar *title_template;
+
+    // Translators: color picker title, %s is CPU, Memory, Swap, Receiving, Sending
+    title_template = g_strdup(_("Pick a Color for '%s'"));
+
+    /* The CPU BOX */
+
+    cpu_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_graph_box"));
+
+    cpu_graph = new LoadGraph(LOAD_GRAPH_CPU);
+    gtk_box_pack_start (GTK_BOX (cpu_graph_box),
+                        load_graph_get_widget(cpu_graph),
+                        TRUE,
+                        TRUE,
+                         0);
+
+    GtkWidget* flowbox = GTK_WIDGET (gtk_builder_get_object (builder, "cpu_flow_box"));
+    gtk_box_reorder_child (GTK_BOX (cpu_graph_box), flowbox, 1);
+    for (i=0;i<procdata->config.num_cpus; i++) {
+        GtkWidget *temp_hbox;
+
+        temp_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
+        gtk_container_add (GTK_CONTAINER (flowbox), temp_hbox);
+
+        color_picker = gsm_color_button_new (&cpu_graph->colors.at(i), GSMCP_TYPE_CPU);
+        g_signal_connect (G_OBJECT (color_picker), "color_set",
+                          G_CALLBACK (cb_cpu_color_changed), GINT_TO_POINTER (i));
+        gtk_box_pack_start (GTK_BOX (temp_hbox), color_picker, FALSE, TRUE, 0);
+        gtk_widget_set_size_request(GTK_WIDGET(color_picker), 32, -1);
+        if(procdata->config.num_cpus == 1) {
+            label_text = g_strdup (_("CPU"));
+        } else {
+            label_text = g_strdup_printf (_("CPU%d"), i+1);
+        }
+        title_text = g_strdup_printf(title_template, label_text);
+        label = gtk_label_new (label_text);
+        gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+        g_free(title_text);
+        gtk_box_pack_start (GTK_BOX (temp_hbox), label, FALSE, FALSE, 6);
+        g_free (label_text);
+
+        cpu_label = gtk_label_new (NULL);
+        gtk_label_set_width_chars (GTK_LABEL (cpu_label), 7);
+        gtk_label_set_xalign (GTK_LABEL (cpu_label), 0.0);
+
+        gtk_box_pack_start (GTK_BOX (temp_hbox), cpu_label, TRUE, TRUE, 0);
+        load_graph_get_labels(cpu_graph)->cpu[i] = cpu_label;
+
+    }
+
+    procdata->cpu_graph = cpu_graph;
+
+    /** The memory box */
+    mem_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "mem_graph_box"));
+
+    mem_graph = new LoadGraph(LOAD_GRAPH_MEM);
+    gtk_box_pack_start (GTK_BOX (mem_graph_box),
+                        load_graph_get_widget(mem_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "mem_table"));
+
+    color_picker = load_graph_get_mem_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_mem_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Memory"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 0, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->memory;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 1, 1, 1, 1);
+
+    color_picker = load_graph_get_swap_color_picker(mem_graph);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                      G_CALLBACK (cb_swap_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Swap"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    gtk_grid_attach (GTK_GRID (table), color_picker, 2, 0, 1, 2);
+
+    label = load_graph_get_labels(mem_graph)->swap;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 3, 1, 1, 1);
+
+    procdata->mem_graph = mem_graph;
+
+    /* The net box */
+    net_graph_box = GTK_WIDGET (gtk_builder_get_object (builder, "net_graph_box"));
+
+    net_graph = new LoadGraph(LOAD_GRAPH_NET);
+    gtk_box_pack_start (GTK_BOX (net_graph_box),
+                        load_graph_get_widget(net_graph),
+                        TRUE,
+                        TRUE,
+                        0);
+
+    table = GTK_WIDGET (gtk_builder_get_object (builder, "net_table"));
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(0), GSMCP_TYPE_NETWORK_IN);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_in_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Receiving"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "receiving_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_in;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_in_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 2, 1, 1, 1);
+
+    color_picker = gsm_color_button_new (
+        &net_graph->colors.at(1), GSMCP_TYPE_NETWORK_OUT);
+    g_signal_connect (G_OBJECT (color_picker), "color_set",
+                G_CALLBACK (cb_net_out_color_changed), procdata);
+    title_text = g_strdup_printf(title_template, _("Sending"));
+    gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
+    g_free(title_text);
+
+    picker_alignment = GTK_WIDGET (gtk_builder_get_object (builder, "sending_picker_alignment"));
+    gtk_container_add (GTK_CONTAINER (picker_alignment), color_picker);
+
+    label = load_graph_get_labels(net_graph)->net_out;
+    gtk_label_set_xalign(GTK_LABEL(label), 0);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 0, 1, 1);
+
+    label = load_graph_get_labels(net_graph)->net_out_total;
+    gtk_label_set_xalign(GTK_LABEL(label), 1);
+    gtk_grid_attach (GTK_GRID (table), label, 6, 1, 1, 1);
+
+    procdata->net_graph = net_graph;
+    g_free(title_template);
+}
+
+static void
+menu_item_select_cb (GtkMenuItem *proxy,
+                     ProcData *procdata)
+{
+    GtkAction *action;
+    char *message;
+
+    action = gtk_activatable_get_related_action (GTK_ACTIVATABLE(proxy));
+    g_assert(action);
+
+    g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
+    if (message)
+    {
+        gtk_statusbar_push (GTK_STATUSBAR (procdata->statusbar),
+                    procdata->tip_message_cid, message);
+        g_free (message);
+    }
+}
+
+static void
+menu_item_deselect_cb (GtkMenuItem *proxy,
+                       ProcData *procdata)
+{
+    gtk_statusbar_pop (GTK_STATUSBAR (procdata->statusbar),
+               procdata->tip_message_cid);
+}
+
+static void
+connect_proxy_cb (GtkUIManager *manager,
+                  GtkAction *action,
+                  GtkWidget *proxy,
+                  ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_connect (proxy, "select",
+                          G_CALLBACK (menu_item_select_cb), procdata);
+        g_signal_connect (proxy, "deselect",
+                          G_CALLBACK (menu_item_deselect_cb), procdata);
+    }
+}
+
+static void
+disconnect_proxy_cb (GtkUIManager *manager,
+                     GtkAction *action,
+                     GtkWidget *proxy,
+                     ProcData *procdata)
+{
+    if (GTK_IS_MENU_ITEM (proxy)) {
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_select_cb)), procdata);
+        g_signal_handlers_disconnect_by_func
+            (proxy, (void*)(G_CALLBACK(menu_item_deselect_cb)), procdata);
+    }
+}
+
+void
+create_main_window (ProcData *procdata)
+{
+    gint i;
+    gint width, height, xpos, ypos;
+    GtkWidget *app;
+    GtkAction *action;
+    GtkWidget *menubar;
+    GtkWidget *main_box;
+    GtkWidget *notebook;
+    GtkBuilder *builder;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/interface.ui");
+
+    app = GTK_WIDGET (gtk_builder_get_object (builder, "main_window"));
+    main_box = GTK_WIDGET (gtk_builder_get_object (builder, "main_box"));
+
+    GdkScreen* screen = gtk_widget_get_screen(app);
+    /* use visual, if available */
+    GdkVisual* visual = gdk_screen_get_rgba_visual(screen);
+    if (visual)
+        gtk_widget_set_visual(app, visual);
+
+    width = procdata->config.width;
+    height = procdata->config.height;
+    xpos = procdata->config.xpos;
+    ypos = procdata->config.ypos;
+    gtk_window_set_default_size (GTK_WINDOW (app), width, height);
+    gtk_window_move(GTK_WINDOW (app), xpos, ypos);
+
+    if (procdata->config.maximized) {
+        gtk_window_maximize(GTK_WINDOW(app));
+    }
+
+    /* create the menubar */
+    procdata->uimanager = gtk_ui_manager_new ();
+
+    /* show tooltips in the statusbar */
+    g_signal_connect (procdata->uimanager, "connect_proxy",
+                      G_CALLBACK (connect_proxy_cb), procdata);
+    g_signal_connect (procdata->uimanager, "disconnect_proxy",
+                      G_CALLBACK (disconnect_proxy_cb), procdata);
+
+    gtk_window_add_accel_group (GTK_WINDOW (app),
+                                gtk_ui_manager_get_accel_group (procdata->uimanager));
+
+    if (!gtk_ui_manager_add_ui_from_string (procdata->uimanager,
+                                            ui_info,
+                                            -1,
+                                            NULL)) {
+        g_error("building menus failed");
+    }
+
+    procdata->action_group = gtk_action_group_new ("ProcmanActions");
+    gtk_action_group_set_translation_domain (procdata->action_group, NULL);
+    gtk_action_group_add_actions (procdata->action_group,
+                                  menu_entries,
+                                  G_N_ELEMENTS (menu_entries),
+                                  procdata);
+    gtk_action_group_add_toggle_actions (procdata->action_group,
+                                         toggle_menu_entries,
+                                         G_N_ELEMENTS (toggle_menu_entries),
+                                         procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                        radio_menu_entries,
+                        G_N_ELEMENTS (radio_menu_entries),
+                        procdata->config.whose_process,
+                        G_CALLBACK(cb_radio_processes),
+                        procdata);
+
+    gtk_action_group_add_radio_actions (procdata->action_group,
+                                        priority_menu_entries,
+                                        G_N_ELEMENTS (priority_menu_entries),
+                                        NORMAL_PRIORITY,
+                                        G_CALLBACK(cb_renice),
+                                        procdata);
+
+    gtk_ui_manager_insert_action_group (procdata->uimanager,
+                                        procdata->action_group,
+                                        0);
+
+    menubar = gtk_ui_manager_get_widget (procdata->uimanager, "/MenuBar");
+    gtk_box_pack_start (GTK_BOX (main_box), menubar, FALSE, FALSE, 0);
+    gtk_box_reorder_child (GTK_BOX (main_box), menubar, 0);
+
+    /* create the main notebook */
+    procdata->notebook = notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
+
+    create_proc_view(procdata, builder);
+    create_sys_view (procdata, builder);
+    create_disk_view (procdata, builder);
+
+    g_signal_connect (G_OBJECT (notebook), "switch-page",
+              G_CALLBACK (cb_switch_page), procdata);
+    g_signal_connect (G_OBJECT (notebook), "change-current-page",
+              G_CALLBACK (cb_change_current_page), procdata);
+
+    gtk_widget_show_all(notebook); // need to make page switch work
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab);
+    cb_change_current_page (GTK_NOTEBOOK (notebook), procdata->config.current_tab, procdata);
+    g_signal_connect (G_OBJECT (app), "delete_event",
+                      G_CALLBACK (cb_app_delete),
+                      procdata);
+
+    GtkAccelGroup *accel_group;
+    GClosure *goto_tab_closure[4];
+    accel_group = gtk_accel_group_new ();
+    gtk_window_add_accel_group (GTK_WINDOW(app), accel_group);
+    for (i = 0; i < 4; ++i) {
+        goto_tab_closure[i] = g_cclosure_new_swap (G_CALLBACK (cb_proc_goto_tab),
+                                                   GINT_TO_POINTER (i), NULL);
+        gtk_accel_group_connect (accel_group, '0'+(i+1),
+                                 GDK_MOD1_MASK, GTK_ACCEL_VISIBLE,
+                                 goto_tab_closure[i]);
+    }
+
+    /* create the statusbar */
+    procdata->statusbar = GTK_WIDGET (gtk_builder_get_object (builder, "statusbar"));
+    procdata->tip_message_cid = gtk_statusbar_get_context_id
+        (GTK_STATUSBAR (procdata->statusbar), "tip_message");
+
+    action = gtk_action_group_get_action (procdata->action_group, "ShowDependencies");
+    gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+                      procdata->config.show_tree);
+
+    gtk_builder_connect_signals (builder, NULL);
+
+    gtk_widget_show_all(app);
+    procdata->app = app;
+
+    g_object_unref (G_OBJECT (builder));
+}
+
+void
+do_popup_menu (ProcData *procdata, GdkEventButton *event)
+{
+    gtk_menu_popup_at_pointer (GTK_MENU (procdata->popup_menu), NULL);
+}
+
+void
+update_sensitivity(ProcData *data)
+{
+    const char * const selected_actions[] = { "StopProcess",
+                                              "ContProcess",
+                                              "EndProcess",
+                                              "KillProcess",
+                                              "ChangePriority",
+                                              "MemoryMaps",
+                                              "OpenFiles",
+                                              "ProcessProperties" };
+
+    const char * const processes_actions[] = { "ShowActiveProcesses",
+                                               "ShowAllProcesses",
+                                               "ShowMyProcesses",
+                                               "ShowDependencies",
+                                               "Refresh"
+    };
+
+    size_t i;
+    gboolean processes_sensitivity, selected_sensitivity;
+    GtkAction *action;
+
+    processes_sensitivity = (data->config.current_tab == PROCMAN_TAB_PROCESSES);
+    selected_sensitivity = (processes_sensitivity && data->selection && gtk_tree_selection_count_selected_rows (data->selection) > 0);
+
+    if(data->endprocessbutton) {
+        /* avoid error on startup if endprocessbutton
+           has not been built yet */
+        gtk_widget_set_sensitive(data->endprocessbutton, selected_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(processes_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             processes_actions[i]);
+        gtk_action_set_sensitive(action, processes_sensitivity);
+    }
+
+    for (i = 0; i != G_N_ELEMENTS(selected_actions); ++i) {
+        action = gtk_action_group_get_action(data->action_group,
+                                             selected_actions[i]);
+        gtk_action_set_sensitive(action, selected_sensitivity);
+    }
+}
+
+void
+block_priority_changed_handlers(ProcData *data, bool block)
+{
+    gint i;
+    if (block) {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_block_by_func(action, (gpointer)cb_renice, data);
+        }
+    } else {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_unblock_by_func(action, (gpointer)cb_renice, data);
+        }
+    }
+}
+
+static void
+cb_toggle_tree (GtkAction *action, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GSettings *settings = procdata->settings;
+    gboolean show;
+
+    show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+    if (show == procdata->config.show_tree)
+        return;
+
+    g_settings_set_boolean (settings, "show-tree", show);
+}
+
+static void
+cb_proc_goto_tab (gint tab)
+{
+    ProcData *data = ProcData::get_instance ();
+    gtk_notebook_set_current_page (GTK_NOTEBOOK (data->notebook), tab);
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/24.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/24.html new file mode 100644 index 00000000..3a91a1d8 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/24.html @@ -0,0 +1,1939 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gdkmm/pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dirent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibtop.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/swap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/netload.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/netlist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <algorithm><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "load-graph.h"
+#include "util.h"
+#include "gsm_color_button.h"
+
+void LoadGraph::clear_background()
+{
+    if (background) {
+        cairo_pattern_destroy (background);
+        this->background = NULL;
+    }
+}
+
+
+unsigned LoadGraph::num_bars() const
+{
+    unsigned n;
+
+    // keep 100 % num_bars == 0
+    switch (static_cast<int>(this->draw_height / (fontsize + 14)))
+    {
+    case 0:
+    case 1:
+        n = 1;
+        break;
+    case 2:
+    case 3:
+        n = 2;
+        break;
+    case 4:
+        n = 4;
+        break;
+    default:
+        n = 5;
+    }
+
+    return n;
+}
+
+
+
+#define FRAME_WIDTH 4
+static void draw_background(LoadGraph *graph) {
+    GtkAllocation allocation;
+    cairo_t *cr;
+    guint i;
+    unsigned num_bars;
+    g_autofree gchar *caption;
+    PangoLayout* layout;
+    PangoFontDescription* font_desc;
+    PangoRectangle extents;
+    cairo_surface_t *surface;
+    GdkRGBA fg, bg;
+
+    num_bars = graph->num_bars();
+    graph->graph_dely = (graph->draw_height - 15) / num_bars; /* round to int to avoid AA blur */
+    graph->real_draw_height = graph->graph_dely * num_bars;
+    graph->graph_delx = (graph->draw_width - 2.0 - graph->rmargin - graph->indent) / (LoadGraph::NUM_POINTS - 3);
+    graph->graph_buffer_offset = (int) (1.5 * graph->graph_delx) + FRAME_WIDTH ;
+
+    gtk_widget_get_allocation (graph->disp, &allocation);
+    surface = gdk_window_create_similar_surface (gtk_widget_get_window (graph->disp), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height);
+    cr = cairo_create (surface);
+
+    GtkStyleContext *context = gtk_widget_get_style_context (ProcData::get_instance()->notebook);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get_background_color (context, gtk_style_context_get_state (context), &bg);
+    gtk_style_context_get_color (context, gtk_style_context_get_state (context), &fg);
+    gtk_style_context_restore (context);
+
+    // set the background color
+    gdk_cairo_set_source_rgba (cr, &bg);
+    cairo_paint (cr);
+
+    layout = pango_cairo_create_layout (cr);
+    gtk_style_context_save (context);
+    gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+    gtk_style_context_get (context,
+                           gtk_style_context_get_state (context),
+                           GTK_STYLE_PROPERTY_FONT,
+                           &font_desc, NULL);
+    gtk_style_context_restore (context);
+    pango_font_description_set_size (font_desc, 0.8 * graph->fontsize * PANGO_SCALE);
+    pango_layout_set_font_description (layout, font_desc);
+    pango_font_description_free (font_desc);
+
+    /* draw frame */
+    cairo_translate (cr, FRAME_WIDTH, FRAME_WIDTH);
+
+    /* Draw background rectangle */
+    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+    cairo_rectangle (cr, graph->rmargin + graph->indent, 0,
+                     graph->draw_width - graph->rmargin - graph->indent, graph->real_draw_height);
+    cairo_fill(cr);
+
+    cairo_set_line_width (cr, 1.0);
+    cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    for (i = 0; i <= num_bars; ++i) {
+        double y;
+
+        if (i == 0)
+            y = 0.5 + graph->fontsize / 2.0;
+        else if (i == num_bars)
+            y = i * graph->graph_dely + 0.5;
+        else
+            y = i * graph->graph_dely + graph->fontsize / 2.0;
+
+        gdk_cairo_set_source_rgba (cr, &fg);
+        if (graph->type == LOAD_GRAPH_NET) {
+            // operation orders matters so it's 0 if i == num_bars
+            guint64 rate = graph->net.max - (i * graph->net.max / num_bars);
+            caption = g_format_size_full (network_in_bits ? rate*8 : rate, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        } else {
+            // operation orders matters so it's 0 if i == num_bars
+            caption = g_strdup_printf("%d%%", 100 - i * (100 / num_bars));
+            pango_layout_set_text (layout, caption, -1);
+            pango_layout_get_extents (layout, NULL, &extents);
+            cairo_move_to (cr, graph->indent - 1.0 * extents.width / PANGO_SCALE + 20, y - 1.0 * extents.height / PANGO_SCALE / 2);
+            pango_cairo_show_layout (cr, layout);
+        }
+
+        if (i==0 || i==num_bars)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, graph->rmargin + graph->indent - 3, i * graph->graph_dely + 0.5);
+        cairo_line_to (cr, graph->draw_width - 0.5, i * graph->graph_dely + 0.5);
+        cairo_stroke (cr);
+    }
+
+    const unsigned total_seconds = graph->speed * (LoadGraph::NUM_POINTS - 2) / 1000;
+
+    for (unsigned int i = 0; i < 7; i++) {
+        double x = (i) * (graph->draw_width - graph->rmargin - graph->indent) / 6;
+        if (i==0 || i==6)
+          cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
+        else
+          cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
+        cairo_move_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, 0.5);
+        cairo_line_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, graph->real_draw_height + 4.5);
+        cairo_stroke(cr);
+        unsigned seconds = total_seconds - i * total_seconds / 6;
+        const char* format;
+        if (i == 0)
+            format = dngettext(GETTEXT_PACKAGE, "%u second", "%u seconds", seconds);
+        else
+            format = "%u";
+        caption = g_strdup_printf(format, seconds);
+        pango_layout_set_text (layout, caption, -1);
+        pango_layout_get_extents (layout, NULL, &extents);
+        cairo_move_to (cr, ((ceil(x) + 0.5) + graph->rmargin + graph->indent) - (1.0 * extents.width / PANGO_SCALE/2), graph->draw_height - 1.0 * extents.height / PANGO_SCALE);
+        gdk_cairo_set_source_rgba (cr, &fg);
+        pango_cairo_show_layout (cr, layout);
+    }
+    g_object_unref(layout);
+    cairo_stroke (cr);
+    cairo_destroy (cr);
+    graph->background = cairo_pattern_create_for_surface (surface);
+    cairo_surface_destroy (surface);
+}
+
+/* Redraws the backing buffer for the load graph and updates the window */
+void
+load_graph_queue_draw (LoadGraph *graph)
+{
+    /* repaint */
+    gtk_widget_queue_draw (graph->disp);
+}
+
+static int load_graph_update (gpointer user_data); // predeclare load_graph_update so we can compile ;)
+
+static gboolean
+load_graph_configure (GtkWidget *widget,
+                      GdkEventConfigure *event,
+                      gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    gtk_widget_get_allocation (widget, &allocation);
+    graph->draw_width = allocation.width - 2 * FRAME_WIDTH;
+    graph->draw_height = allocation.height - 2 * FRAME_WIDTH;
+
+    graph->clear_background();
+
+    load_graph_queue_draw (graph);
+
+    return TRUE;
+}
+
+static gboolean load_graph_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+    GdkWindow *window;
+
+    guint i, j;
+    gdouble sample_width, x_offset;
+
+    window = gtk_widget_get_window (graph->disp);
+
+    /* Number of pixels wide for one graph point */
+    sample_width = (float)(graph->draw_width - graph->rmargin - graph->indent) / (float)LoadGraph::NUM_POINTS;
+    /* General offset */
+    x_offset = graph->draw_width - graph->rmargin + (sample_width*2);
+
+    /* Subframe offset */
+    x_offset += graph->rmargin - ((sample_width / graph->frames_per_unit) * graph->render_counter);
+
+    /* draw the graph */
+    cairo_t* cr;
+
+    cr = gdk_cairo_create (window);
+
+    if (graph->background == NULL) {
+        draw_background(graph);
+    }
+    cairo_set_source (cr, graph->background);
+    cairo_paint (cr);
+
+    cairo_set_line_width (cr, 1);
+    cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+    cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
+    cairo_rectangle (cr, graph->rmargin + graph->indent + FRAME_WIDTH + 1, FRAME_WIDTH - 1,
+             graph->draw_width - graph->rmargin - graph->indent - 1, graph->real_draw_height + FRAME_WIDTH - 1);
+    cairo_clip(cr);
+
+    for (j = 0; j < graph->n; ++j) {
+        cairo_move_to (cr, x_offset, (1.0f - graph->data[0][j]) * graph->real_draw_height);
+        gdk_cairo_set_source_rgba (cr, &(graph->colors [j]));
+
+        for (i = 1; i < LoadGraph::NUM_POINTS; ++i) {
+            if (graph->data[i][j] == -1.0f)
+                continue;
+            cairo_curve_to (cr,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i-1][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - ((i - 0.5f) * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f,
+                       x_offset - (i * graph->graph_delx),
+                       (1.0f - graph->data[i][j]) * graph->real_draw_height + 3.5f);
+        }
+        cairo_stroke (cr);
+
+    }
+
+    cairo_destroy (cr);
+
+    return TRUE;
+}
+
+static void
+get_load (LoadGraph *graph)
+{
+    guint i;
+    glibtop_cpu cpu;
+
+    glibtop_get_cpu (&cpu);
+
+#undef NOW
+#undef LAST
+#define NOW  (graph->cpu.times[graph->cpu.now])
+#define LAST (graph->cpu.times[graph->cpu.now ^ 1])
+
+    if (graph->n == 1) {
+        NOW[0][CPU_TOTAL] = cpu.total;
+        NOW[0][CPU_USED] = cpu.user + cpu.nice + cpu.sys;
+    } else {
+        for (i = 0; i < graph->n; i++) {
+            NOW[i][CPU_TOTAL] = cpu.xcpu_total[i];
+            NOW[i][CPU_USED] = cpu.xcpu_user[i] + cpu.xcpu_nice[i]
+                + cpu.xcpu_sys[i];
+        }
+    }
+
+    // on the first call, LAST is 0
+    // which means data is set to the average load since boot
+    // that value has no meaning, we just want all the
+    // graphs to be aligned, so the CPU graph needs to start
+    // immediately
+
+    for (i = 0; i < graph->n; i++) {
+        float load;
+        float total, used;
+        gchar *text;
+
+        total = NOW[i][CPU_TOTAL] - LAST[i][CPU_TOTAL];
+        used  = NOW[i][CPU_USED]  - LAST[i][CPU_USED];
+
+        load = used / MAX(total, 1.0f);
+        graph->data[0][i] = load;
+
+        /* Update label */
+        text = g_strdup_printf("%.1f%%", load * 100.0f);
+        gtk_label_set_text(GTK_LABEL(graph->labels.cpu[i]), text);
+        g_free(text);
+    }
+
+    graph->cpu.now ^= 1;
+
+#undef NOW
+#undef LAST
+}
+
+
+namespace
+{
+
+    void set_memory_label_and_picker(GtkLabel* label, GSMColorButton* picker,
+                                   guint64 used, guint64 total, double percent)
+    {
+        char* used_text;
+        char* total_text;
+        char* text;
+
+        used_text = g_format_size_full(used, G_FORMAT_SIZE_IEC_UNITS);
+        total_text = g_format_size_full(total, G_FORMAT_SIZE_IEC_UNITS);
+        if (total == 0) {
+            text = g_strdup(_("not available"));
+        } else {
+            // xgettext: 540MiB (53 %) of 1.0 GiB
+            text = g_strdup_printf(_("%s (%.1f%%) of %s"), used_text, 100.0 * percent, total_text);
+        }
+        gtk_label_set_text(label, text);
+        g_free(used_text);
+        g_free(total_text);
+        g_free(text);
+
+        if (picker)
+            gsm_color_button_set_fraction(picker, percent);
+    }
+}
+
+static void
+get_memory (LoadGraph *graph)
+{
+    float mempercent, swappercent;
+
+    glibtop_mem mem;
+    glibtop_swap swap;
+
+    glibtop_get_mem (&mem);
+    glibtop_get_swap (&swap);
+
+    /* There's no swap on LiveCD : 0.0f is better than NaN :) */
+    swappercent = (swap.total ? (float)swap.used / (float)swap.total : 0.0f);
+    mempercent  = (float)mem.user  / (float)mem.total;
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.memory),
+                                GSM_COLOR_BUTTON(graph->mem_color_picker),
+                                mem.user, mem.total, mempercent);
+
+    set_memory_label_and_picker(GTK_LABEL(graph->labels.swap),
+                                GSM_COLOR_BUTTON(graph->swap_color_picker),
+                                swap.used, swap.total, swappercent);
+
+    graph->data[0][0] = mempercent;
+    graph->data[0][1] = swappercent;
+}
+
+/* Nice Numbers for Graph Labels after Paul Heckbert
+   nicenum: find a "nice" number approximately equal to x.
+   Round the number if round=1, take ceiling if round=0    */
+
+static double
+nicenum (double x, int round)
+{
+    int expv;				/* exponent of x */
+    double f;				/* fractional part of x */
+    double nf;				/* nice, rounded fraction */
+
+    expv = floor( log10(x) );
+    f = x/pow( 10.0, expv );		/* between 1 and 10 */
+    if (round) {
+        if ( f < 1.5 ) nf = 1.0;
+        else if ( f < 3.0 ) nf = 2.0;
+        else if ( f < 7.0 ) nf = 5.0;
+        else nf = 10.0;
+    } else {
+        if ( f <= 1.0 ) nf = 1.0;
+        else if ( f <= 2.0 ) nf = 2.0;
+        else if ( f <= 5.0 ) nf = 5.0;
+        else nf = 10.0;
+    }
+    return nf * pow(10.0, expv);
+}
+
+static void
+net_scale (LoadGraph *graph, guint64 din, guint64 dout)
+{
+    graph->data[0][0] = 1.0f * din / graph->net.max;
+    graph->data[0][1] = 1.0f * dout / graph->net.max;
+
+    guint64 dmax = std::max(din, dout);
+    graph->net.values[graph->net.cur] = dmax;
+    graph->net.cur = (graph->net.cur + 1) % LoadGraph::NUM_POINTS;
+
+    guint64 new_max;
+    // both way, new_max is the greatest value
+    if (dmax >= graph->net.max)
+        new_max = dmax;
+    else
+        new_max = *std::max_element(&graph->net.values[0],
+                                    &graph->net.values[LoadGraph::NUM_POINTS]);
+
+    //
+    // Round network maximum
+    //
+
+    const guint64 bak_max(new_max);
+
+    if (ProcData::get_instance()->config.network_in_bits) {
+        // nice number is for the ticks
+        unsigned ticks = graph->num_bars();
+
+        // gets messy at low values due to division by 8
+        guint64 bit_max = std::max( new_max*8, G_GUINT64_CONSTANT(10000) );
+
+        // our tick size leads to max
+        double d = nicenum(bit_max/ticks, 0);
+        bit_max = ticks * d;
+        new_max = bit_max / 8;
+
+        procman_debug("bak*8 %" G_GUINT64_FORMAT ", ticks %d, d %f"<--- There is an unknown macro here somewhere. Configuration is required. If G_GUINT64_FORMAT is a macro then please configure it.
+                      ", bit_max %" G_GUINT64_FORMAT ", new_max %" G_GUINT64_FORMAT,
+                      bak_max*8, ticks, d, bit_max, new_max );
+    } else {
+        // round up to get some extra space
+        // yes, it can overflow
+        new_max = 1.1 * new_max;
+        // make sure max is not 0 to avoid / 0
+        // default to 1 KiB
+        new_max = std::max(new_max, G_GUINT64_CONSTANT(1024));
+
+        // decompose new_max = coef10 * 2**(base10 * 10)
+        // where coef10 and base10 are integers and coef10 < 2**10
+        //
+        // e.g: ceil(100.5 KiB) = 101 KiB = 101 * 2**(1 * 10)
+        //      where base10 = 1, coef10 = 101, pow2 = 16
+
+        guint64 pow2 = std::floor(log2(new_max));
+        guint64 base10 = pow2 / 10.0;
+        guint64 coef10 = std::ceil(new_max / double(G_GUINT64_CONSTANT(1) << (base10 * 10)));
+        g_assert(new_max <= (coef10 * (G_GUINT64_CONSTANT(1) << (base10 * 10))));
+
+        // then decompose coef10 = x * 10**factor10
+        // where factor10 is integer and x < 10
+        // so we new_max has only 1 significant digit
+
+        guint64 factor10 = std::pow(10.0, std::floor(std::log10(coef10)));
+        coef10 = std::ceil(coef10 / double(factor10)) * factor10;
+
+        // then make coef10 divisible by num_bars
+        if (coef10 % graph->num_bars() != 0)
+            coef10 = coef10 + (graph->num_bars() - coef10 % graph->num_bars());
+        g_assert(coef10 % graph->num_bars() == 0);
+        new_max = coef10 * (G_GUINT64_CONSTANT(1) << guint64(base10 * 10));
+        procman_debug("bak %" G_GUINT64_FORMAT " new_max %" G_GUINT64_FORMAT
+                      "pow2 %" G_GUINT64_FORMAT " coef10 %" G_GUINT64_FORMAT,
+                      bak_max, new_max, pow2, coef10);
+    }
+
+    if (bak_max > new_max) {
+        procman_debug("overflow detected: bak=%" G_GUINT64_FORMAT
+                      " new=%" G_GUINT64_FORMAT,
+                      bak_max, new_max);
+        new_max = bak_max;
+    }
+
+    // if max is the same or has decreased but not so much, don't
+    // do anything to avoid rescaling
+    if ((0.8 * graph->net.max) < new_max && new_max <= graph->net.max)
+        return;
+
+    const double scale = 1.0f * graph->net.max / new_max;
+
+    for (size_t i = 0; i < LoadGraph::NUM_POINTS; i++) {
+        if (graph->data[i][0] >= 0.0f) {
+            graph->data[i][0] *= scale;
+            graph->data[i][1] *= scale;
+        }
+    }
+
+    procman_debug("rescale dmax = %" G_GUINT64_FORMAT
+                  " max = %" G_GUINT64_FORMAT
+                  " new_max = %" G_GUINT64_FORMAT,
+                  dmax, graph->net.max, new_max);
+
+    graph->net.max = new_max;
+
+    // force the graph background to be redrawn now that scale has changed
+    graph->clear_background();
+}
+
+static void
+get_net (LoadGraph *graph)
+{
+    glibtop_netlist netlist;
+    char **ifnames;
+    guint32 i;
+    guint64 in = 0, out = 0;
+#if GLIB_CHECK_VERSION(2,61,2)
+    gint64 time;
+#else
+    GTimeVal time;
+#endif
+    guint64 din, dout;
+
+    ifnames = glibtop_get_netlist(&netlist);
+
+    for (i = 0; i < netlist.number; ++i)
+    {
+        glibtop_netload netload;
+        glibtop_get_netload (&netload, ifnames[i]);
+
+        if (netload.if_flags & (1 << GLIBTOP_IF_FLAGS_LOOPBACK))
+            continue;
+
+        /* Skip interfaces without any IPv4/IPv6 address (or
+         those with only a LINK ipv6 addr) However we need to
+         be able to exclude these while still keeping the
+         value so when they get online (with NetworkManager
+         for example) we don't get a suddent peak.  Once we're
+         able to get this, ignoring down interfaces will be
+         possible too.  */
+        if (not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS6)
+             and netload.scope6 != GLIBTOP_IF_IN6_SCOPE_LINK)
+            and not (netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS)))
+            continue;
+
+        /* Don't skip interfaces that are down (GLIBTOP_IF_FLAGS_UP)
+           to avoid spikes when they are brought up */
+
+        in  += netload.bytes_in;
+        out += netload.bytes_out;
+    }
+
+    g_strfreev(ifnames);
+
+#if GLIB_CHECK_VERSION(2,61,2)
+    time = g_get_real_time ();
+
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time != 0) {
+        float dtime = (double) (time - graph->net.time) / G_USEC_PER_SEC;
+#else
+    g_get_current_time (&time);
+    if (in >= graph->net.last_in && out >= graph->net.last_out &&
+        graph->net.time.tv_sec != 0) {
+        float dtime;
+        dtime = time.tv_sec - graph->net.time.tv_sec +
+            (double) (time.tv_usec - graph->net.time.tv_usec) / G_USEC_PER_SEC;
+#endif
+        din   = static_cast<guint64>((in  - graph->net.last_in)  / dtime);
+        dout  = static_cast<guint64>((out - graph->net.last_out) / dtime);
+    } else {
+        /* Don't calc anything if new data is less than old (interface
+           removed, counters reset, ...) or if it is the first time */
+        din  = 0;
+        dout = 0;
+    }
+
+    graph->net.last_in  = in;
+    graph->net.last_out = out;
+    graph->net.time     = time;
+
+    net_scale(graph, din, dout);
+
+    bool network_in_bits = ProcData::get_instance()->config.network_in_bits;
+    g_autofree gchar *str=NULL, *formatted_str=NULL;
+
+    str = g_format_size_full (network_in_bits ? din*8 : din, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? in*8 : in, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_in_total), str);
+
+    str = g_format_size_full (network_in_bits ? dout*8 : dout, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    formatted_str = g_strdup_printf(_("%s/s"), str);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out), formatted_str);
+
+    str = g_format_size_full (network_in_bits ? out*8 : out, network_in_bits ? G_FORMAT_SIZE_BITS : G_FORMAT_SIZE_DEFAULT);
+    gtk_label_set_text (GTK_LABEL (graph->labels.net_out_total), str);
+}
+
+
+/* Updates the load graph when the timeout expires */
+static gboolean
+load_graph_update (gpointer user_data)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(user_data);
+
+    if (graph->render_counter == graph->frames_per_unit - 1) {
+        std::rotate(&graph->data[0], &graph->data[LoadGraph::NUM_POINTS - 1], &graph->data[LoadGraph::NUM_POINTS]);
+
+        switch (graph->type) {
+        case LOAD_GRAPH_CPU:
+            get_load(graph);
+            break;
+        case LOAD_GRAPH_MEM:
+            get_memory(graph);
+            break;
+        case LOAD_GRAPH_NET:
+            get_net(graph);
+            break;
+        default:
+            g_assert_not_reached();
+        }
+    }
+
+    if (graph->draw)
+        load_graph_queue_draw (graph);
+
+    graph->render_counter++;
+
+    if (graph->render_counter >= graph->frames_per_unit)
+        graph->render_counter = 0;
+
+    return TRUE;
+}
+
+
+
+LoadGraph::~LoadGraph()
+{
+  load_graph_stop(this);
+
+  if (timer_index)
+    g_source_remove(timer_index);
+
+  clear_background();
+}
+
+
+
+static gboolean
+load_graph_destroy (GtkWidget *widget, gpointer data_ptr)
+{
+    LoadGraph * const graph = static_cast<LoadGraph*>(data_ptr);
+
+    delete graph;
+
+    return FALSE;
+}
+
+
+LoadGraph::LoadGraph(guint type)
+  : fontsize(8.0),
+    rmargin(3.5 * fontsize),
+    indent(24.0),
+    n(0),
+    type(type),
+    speed(0),
+    draw_width(0),
+    draw_height(0),
+    render_counter(0),
+    frames_per_unit(10), // this will be changed but needs initialising
+    graph_dely(0),
+    real_draw_height(0),
+    graph_delx(0.0),
+    graph_buffer_offset(0),
+    main_widget(NULL),
+    disp(NULL),
+    background(NULL),
+    timer_index(0),
+    draw(FALSE),
+    mem_color_picker(NULL),
+    swap_color_picker(NULL)
+{
+    LoadGraph * const graph = this;
+
+    // FIXME:
+    // on configure, graph->frames_per_unit = graph->draw_width/(LoadGraph::NUM_POINTS);
+    // knock FRAMES down to 5 until cairo gets faster
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memset(&cpu, 0, sizeof cpu);
+        n = ProcData::get_instance()->config.num_cpus;
+
+        for(guint i = 0; i < G_N_ELEMENTS(labels.cpu); ++i)
+            labels.cpu[i] = gtk_label_new(NULL);
+
+        break;
+
+    case LOAD_GRAPH_MEM:
+        n = 2;
+        labels.memory = gtk_label_new(NULL);
+        labels.swap = gtk_label_new(NULL);
+        break;
+
+    case LOAD_GRAPH_NET:
+        memset(&net, 0, sizeof net);
+        n = 2;
+        net.max = 1;
+        labels.net_in = gtk_label_new(NULL);
+        labels.net_in_total = gtk_label_new(NULL);
+        labels.net_out = gtk_label_new(NULL);
+        labels.net_out_total = gtk_label_new(NULL);
+        break;
+    }
+
+    speed  = ProcData::get_instance()->config.graph_update_interval;
+
+    colors.resize(n);
+
+    switch (type) {
+    case LOAD_GRAPH_CPU:
+        memcpy(&colors[0], ProcData::get_instance()->config.cpu_color,
+               n * sizeof colors[0]);
+        break;
+    case LOAD_GRAPH_MEM:
+        colors[0] = ProcData::get_instance()->config.mem_color;
+        colors[1] = ProcData::get_instance()->config.swap_color;
+        mem_color_picker = gsm_color_button_new (&colors[0],
+                                                 GSMCP_TYPE_PIE);
+        swap_color_picker = gsm_color_button_new (&colors[1],
+                                                  GSMCP_TYPE_PIE);
+        break;
+    case LOAD_GRAPH_NET:
+        colors[0] = ProcData::get_instance()->config.net_in_color;
+        colors[1] = ProcData::get_instance()->config.net_out_color;
+        break;
+    }
+
+    timer_index = 0;
+    render_counter = (frames_per_unit - 1);
+    draw = FALSE;
+
+    main_widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+    gtk_widget_set_size_request(main_widget, -1, LoadGraph::GRAPH_MIN_HEIGHT);
+    gtk_widget_show (main_widget);
+
+    disp = gtk_drawing_area_new ();
+    gtk_widget_show (disp);
+    g_signal_connect (G_OBJECT (disp), "draw", G_CALLBACK (load_graph_draw), graph);
+    g_signal_connect (G_OBJECT(disp), "configure_event",
+                      G_CALLBACK (load_graph_configure), graph);
+    g_signal_connect (G_OBJECT(disp), "destroy",
+                      G_CALLBACK (load_graph_destroy), graph);
+
+    gtk_widget_set_events (disp, GDK_EXPOSURE_MASK);
+
+    gtk_box_pack_start (GTK_BOX (main_widget), disp, TRUE, TRUE, 0);
+
+
+    /* Allocate data in a contiguous block */
+    data_block = std::vector<float>(n * LoadGraph::NUM_POINTS, -1.0f);
+
+    for (guint i = 0; i < LoadGraph::NUM_POINTS; ++i)
+        data[i] = &data_block[0] + i * n;
+
+    gtk_widget_show_all (main_widget);
+}
+
+void
+load_graph_start (LoadGraph *graph)
+{
+    if(!graph->timer_index) {
+
+        load_graph_update(graph);
+
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->draw = TRUE;
+}
+
+void
+load_graph_stop (LoadGraph *graph)
+{
+    /* don't draw anymore, but continue to poll */
+    graph->draw = FALSE;
+}
+
+void
+load_graph_change_speed (LoadGraph *graph,
+             guint new_speed)
+{
+    if (graph->speed == new_speed)
+        return;
+
+    graph->speed = new_speed;
+
+    if(graph->timer_index) {
+        g_source_remove (graph->timer_index);
+        graph->timer_index = g_timeout_add (graph->speed / graph->frames_per_unit,
+                                        load_graph_update,
+                                        graph);
+    }
+
+    graph->clear_background();
+}
+
+
+LoadGraphLabels*
+load_graph_get_labels (LoadGraph *graph)
+{
+    return &graph->labels;
+}
+
+GtkWidget*
+load_graph_get_widget (LoadGraph *graph)
+{
+    return graph->main_widget;
+}
+
+GtkWidget*
+load_graph_get_mem_color_picker(LoadGraph *graph)
+{
+    return graph->mem_color_picker;
+}
+
+GtkWidget*
+load_graph_get_swap_color_picker(LoadGraph *graph)
+{
+    return graph->swap_color_picker;
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/25.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/25.html new file mode 100644 index 00000000..6cf33ee0 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/25.html @@ -0,0 +1,1075 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtkmm/messagedialog.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/regex.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procopenfiles.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <sys/wait.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <set><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sstream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <iterator><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibmm/regex.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "lsof.h"
+#include "util.h"
+
+
+using std::string;
+
+
+namespace
+{
+
+    class Lsof
+    {
+        Glib::RefPtr<Glib::Regex> re;
+
+        bool matches(const string &filename) const
+        {
+            return this->re->match(filename);
+        }
+
+    public:
+
+        Lsof(const string &pattern, bool caseless)
+        {
+            Glib::RegexCompileFlags flags = static_cast<Glib::RegexCompileFlags>(0);
+
+            if (caseless)
+                flags |= Glib::REGEX_CASELESS;
+
+            this->re = Glib::Regex::create(pattern, flags);
+        }
+
+
+        template<typename OutputIterator>
+        void search(const ProcInfo &info, OutputIterator out) const
+        {
+            glibtop_open_files_entry *entries;
+            glibtop_proc_open_files buf;
+
+            entries = glibtop_get_proc_open_files(&buf, info.pid);
+
+            for (unsigned i = 0; i != buf.number; ++i) {
+                if (entries[i].type & GLIBTOP_FILE_TYPE_FILE) {
+                    const string filename(entries[i].info.file.name);
+                    if (this->matches(filename))
+                        *out++ = filename;
+                }
+            }
+
+            g_free(entries);
+        }
+    };
+
+
+
+    // GUI Stuff
+
+
+    enum ProcmanLsof {
+        PROCMAN_LSOF_COL_SURFACE,
+        PROCMAN_LSOF_COL_PROCESS,
+        PROCMAN_LSOF_COL_PID,
+        PROCMAN_LSOF_COL_FILENAME,
+        PROCMAN_LSOF_NCOLS
+    };
+
+
+    struct GUI {
+
+        GtkListStore *model;
+        GtkEntry *entry;
+        GtkWindow *window;
+        GtkLabel *count;<--- Shadowed declaration
+        ProcData *procdata;
+        bool case_insensitive;
+
+
+        GUI()
+        {
+            procman_debug("New Lsof GUI %p", this);
+        }
+
+
+        ~GUI()
+        {
+            procman_debug("Destroying Lsof GUI %p", this);
+        }
+
+
+        void clear_results()
+        {
+            gtk_list_store_clear(this->model);
+            gtk_label_set_text(this->count, "");
+        }
+
+
+        void clear()
+        {
+            this->clear_results();
+            gtk_entry_set_text(this->entry, "");
+        }
+
+
+        void display_regex_error(const Glib::RegexError& error)
+        {
+            char * msg = g_strdup_printf ("<b>%s</b>\n%s\n%s",
+                                          _("Error"),
+                                          _("'%s' is not a valid Perl regular expression."),
+                                          "%s");
+            std::string message = make_string(g_strdup_printf(msg, this->pattern().c_str(), error.what().c_str()));
+            g_free(msg);
+
+            Gtk::MessageDialog dialog(message,
+                                      true, // use markup
+                                      Gtk::MESSAGE_ERROR,
+                                      Gtk::BUTTONS_OK,
+                                      true); // modal
+            dialog.run();
+        }
+
+
+        void update_count(unsigned count)
+        {
+            std::ostringstream ss;
+            ss << count;
+            string s = ss.str();
+            gtk_label_set_text(this->count, s.c_str());
+        }
+
+
+        string pattern() const
+        {
+            return gtk_entry_get_text(this->entry);
+        }
+
+
+        void search()
+        {
+            typedef std::set<string> MatchSet;
+            typedef MatchSet::const_iterator iterator;
+
+            this->clear_results();
+
+
+            try {
+                Lsof lsof(this->pattern(), this->case_insensitive);
+
+                unsigned count = 0;<--- Shadow variable
+
+                for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it) {
+                    const ProcInfo &info(*it->second);
+
+                    MatchSet matches;
+                    lsof.search(info, std::inserter(matches, matches.begin()));
+                    count += matches.size();
+
+                    for (iterator it(matches.begin()), end(matches.end()); it != end; ++it) {
+                        GtkTreeIter file;
+                        gtk_list_store_append(this->model, &file);
+                        gtk_list_store_set(this->model, &file,
+                                           PROCMAN_LSOF_COL_SURFACE, info.surface,
+                                           PROCMAN_LSOF_COL_PROCESS, info.name,
+                                           PROCMAN_LSOF_COL_PID, info.pid,
+                                           PROCMAN_LSOF_COL_FILENAME, it->c_str(),
+                                           -1);
+                    }
+                }
+
+                this->update_count(count);
+            }
+            catch (Glib::RegexError& error) {
+                this->display_regex_error(error);
+            }
+        }
+
+
+        static void search_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void search_entry_activate(GtkEntry *, gpointer data)
+        {
+            static_cast<GUI*>(data)->search();
+        }
+
+
+        static void clear_button_clicked(GtkButton *, gpointer data)
+        {
+            static_cast<GUI*>(data)->clear();
+        }
+
+
+        static void close_button_clicked(GtkButton *, gpointer data)
+        {
+            GUI *gui = static_cast<GUI*>(data);
+            gtk_widget_destroy(GTK_WIDGET(gui->window));
+            delete gui;
+        }
+
+
+        static void case_button_toggled(GtkToggleButton *button, gpointer data)
+        {
+            bool state = gtk_toggle_button_get_active(button);
+            static_cast<GUI*>(data)->case_insensitive = state;
+        }
+
+
+        static gboolean window_delete_event(GtkWidget *, GdkEvent *, gpointer data)
+        {
+            delete static_cast<GUI*>(data);
+            return FALSE;
+        }
+
+    };
+}
+
+
+
+
+void procman_lsof(ProcData *procdata)
+{
+    GtkListStore *model = \
+        gtk_list_store_new(PROCMAN_LSOF_NCOLS,
+                           CAIRO_GOBJECT_TYPE_SURFACE, // PROCMAN_LSOF_COL_SURFACE
+                           G_TYPE_STRING,              // PROCMAN_LSOF_COL_PROCESS
+                           G_TYPE_UINT,                // PROCMAN_LSOF_COL_PID
+                           G_TYPE_STRING               // PROCMAN_LSOF_COL_FILENAME
+        );
+
+    GtkWidget *tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+    g_object_unref(model);
+
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *renderer;
+
+    // SURFACE / PROCESS
+
+    column = gtk_tree_view_column_new();
+
+    renderer = gtk_cell_renderer_pixbuf_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "surface", PROCMAN_LSOF_COL_SURFACE,
+                                        NULL);
+
+    renderer = gtk_cell_renderer_text_new();
+    gtk_tree_view_column_pack_start(column, renderer, FALSE);
+    gtk_tree_view_column_set_attributes(column, renderer,
+                                        "text", PROCMAN_LSOF_COL_PROCESS,
+                                        NULL);
+
+    gtk_tree_view_column_set_title(column, _("Process"));
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PROCESS);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_column_set_min_width(column, 10);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), PROCMAN_LSOF_COL_PROCESS,
+                                         GTK_SORT_ASCENDING);
+
+
+    // PID
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("PID"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_PID,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_PID);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    // FILENAME
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(_("Filename"), renderer,
+                                                      "text", PROCMAN_LSOF_COL_FILENAME,
+                                                      NULL);
+    gtk_tree_view_column_set_sort_column_id(column, PROCMAN_LSOF_COL_FILENAME);
+    gtk_tree_view_column_set_resizable(column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+
+    GtkWidget *dialog; /* = gtk_dialog_new_with_buttons(_("Search for Open Files"), NULL,
+                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+                                                        NULL); */
+    dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(procdata->app));
+    gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
+    // gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_title(GTK_WINDOW(dialog), _("Search for Open Files"));
+
+    // g_signal_connect(G_OBJECT(dialog), "response",
+    //                           G_CALLBACK(close_dialog), NULL);
+    gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(dialog), 575, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(dialog), 12);
+    GtkWidget *mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_add(GTK_CONTAINER(dialog), mainbox);
+    gtk_box_set_spacing(GTK_BOX(mainbox), 6);
+
+
+    // Label, entry and search button
+
+    GtkWidget *hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), hbox1, FALSE, FALSE, 0);
+
+    GtkWidget *image = gtk_image_new_from_icon_name("edit-find", GTK_ICON_SIZE_DIALOG);
+    gtk_box_pack_start(GTK_BOX(hbox1), image, FALSE, FALSE, 0);
+
+
+    GtkWidget *vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox1), vbox2, TRUE, TRUE, 0);
+
+
+    GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox, TRUE, TRUE, 0);
+    GtkWidget *label = gtk_label_new_with_mnemonic(_("_Name contains:"));
+    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+    GtkWidget *entry = gtk_entry_new();
+
+    gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
+
+    GtkWidget *search_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                         "label", "gtk-find",
+                                                         "use-stock", TRUE,
+                                                         "use-underline", TRUE,
+                                                         NULL));
+
+    gtk_box_pack_start(GTK_BOX(hbox), search_button, FALSE, FALSE, 0);
+
+    GtkWidget *clear_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-clear",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    /* The default accelerator collides with the default close accelerator. */
+    gtk_button_set_label(GTK_BUTTON(clear_button), _("C_lear"));
+    gtk_box_pack_start(GTK_BOX(hbox), clear_button, FALSE, FALSE, 0);
+
+
+    GtkWidget *case_button = gtk_check_button_new_with_mnemonic(_("Case insensitive matching"));
+    GtkWidget *hbox3 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(hbox3), case_button, FALSE, FALSE, 0);
+    gtk_box_pack_start(GTK_BOX(vbox2), hbox3, FALSE, FALSE, 0);
+
+
+    GtkWidget *results_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start(GTK_BOX(mainbox), results_box, FALSE, FALSE, 0);
+    GtkWidget *results_label = gtk_label_new_with_mnemonic(_("S_earch results:"));
+    gtk_box_pack_start(GTK_BOX(results_box), results_label, FALSE, FALSE, 0);
+    GtkWidget *count_label = gtk_label_new(NULL);
+    gtk_box_pack_end(GTK_BOX(results_box), count_label, FALSE, FALSE, 0);
+
+    // Scrolled TreeView
+    GtkWidget *scrolled = gtk_scrolled_window_new(NULL, NULL);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
+                                   GTK_POLICY_AUTOMATIC,
+                                   GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled),
+                                        GTK_SHADOW_IN);
+    gtk_container_add(GTK_CONTAINER(scrolled), tree);
+    gtk_box_pack_start(GTK_BOX(mainbox), scrolled, TRUE, TRUE, 0);
+
+    GtkWidget *bottom_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+
+    GtkWidget *close_button = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", "gtk-close",
+                                                        "use-stock", TRUE,
+                                                        "use-underline", TRUE,
+                                                        NULL));
+
+    gtk_box_pack_start(GTK_BOX(mainbox), bottom_box, FALSE, FALSE, 0);
+    gtk_box_pack_end(GTK_BOX(bottom_box), close_button, FALSE, FALSE, 0);
+
+
+    GUI *gui = new GUI; // wil be deleted by the close button or delete-event
+    gui->procdata = procdata;
+    gui->model = model;
+    gui->window = GTK_WINDOW(dialog);
+    gui->entry = GTK_ENTRY(entry);
+    gui->count = GTK_LABEL(count_label);
+
+    g_signal_connect(G_OBJECT(entry), "activate",
+                     G_CALLBACK(GUI::search_entry_activate), gui);
+    g_signal_connect(G_OBJECT(clear_button), "clicked",
+                     G_CALLBACK(GUI::clear_button_clicked), gui);
+    g_signal_connect(G_OBJECT(search_button), "clicked",
+                     G_CALLBACK(GUI::search_button_clicked), gui);
+    g_signal_connect(G_OBJECT(close_button), "clicked",
+                     G_CALLBACK(GUI::close_button_clicked), gui);
+    g_signal_connect(G_OBJECT(case_button), "toggled",
+                     G_CALLBACK(GUI::case_button_toggled), gui);
+    g_signal_connect(G_OBJECT(dialog), "delete-event",
+                     G_CALLBACK(GUI::window_delete_event), gui);
+
+
+    gtk_widget_show_all(dialog);
+}
+
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/26.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/26.html new file mode 100644 index 00000000..1115c16e --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/26.html @@ -0,0 +1,1197 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibtop/procmap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mountlist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <map><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sstream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <iomanip><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdexcept><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+using std::string;
+
+
+#include "procman.h"
+#include "memmaps.h"
+#include "proctable.h"
+#include "util.h"
+
+
+/* be careful with this enum, you could break the column names */
+enum
+{
+    MMAP_COL_FILENAME,
+    MMAP_COL_VMSTART,
+    MMAP_COL_VMEND,
+    MMAP_COL_VMSZ,
+    MMAP_COL_FLAGS,
+    MMAP_COL_VMOFFSET,
+    MMAP_COL_PRIVATE_CLEAN,
+    MMAP_COL_PRIVATE_DIRTY,
+    MMAP_COL_SHARED_CLEAN,
+    MMAP_COL_SHARED_DIRTY,
+    MMAP_COL_DEVICE,
+    MMAP_COL_INODE,
+    MMAP_COL_MAX
+};
+
+
+namespace
+{
+    class OffsetFormater
+    {
+        string format;
+
+    public:
+
+        void set(const glibtop_map_entry &last_map)
+        {
+            this->format = (last_map.end <= G_MAXUINT32) ? "%08" G_GINT64_MODIFIER "x" : "%016" G_GINT64_MODIFIER "x";<--- There is an unknown macro here somewhere. Configuration is required. If G_GINT64_MODIFIER is a macro then please configure it.
+        }
+
+        string operator()(guint64 v) const
+        {
+            char buffer[17];
+            g_snprintf(buffer, sizeof buffer, this->format.c_str(), v);
+            return buffer;
+        }
+    };
+
+
+    class InodeDevices
+    {
+        typedef std::map<guint16, string> Map;
+        Map devices;
+
+    public:
+
+        void update()
+        {
+            this->devices.clear();
+
+            glibtop_mountlist list;
+            glibtop_mountentry *entries = glibtop_get_mountlist(&list, 1);
+
+            for (unsigned i = 0; i != list.number; ++i) {
+                struct stat buf;
+
+                if (stat(entries[i].devname, &buf) != -1)
+                    this->devices[buf.st_rdev] = entries[i].devname;
+            }
+
+            g_free(entries);
+        }
+
+        string get(guint64 dev64)
+        {
+            if (dev64 == 0)
+                return "";
+
+            guint16 dev = dev64 & 0xffff;
+
+            if (dev != dev64)
+                g_warning("weird device %" G_GINT64_MODIFIER "x", dev64);
+
+            Map::iterator it(this->devices.find(dev));
+
+            if (it != this->devices.end())
+                return it->second;
+
+            guint8 major, minor;
+            major = dev >> 8;
+            minor = dev;
+
+            std::ostringstream out;
+            out << std::hex
+                << std::setfill('0')
+                << std::setw(2) << unsigned(major)
+                << ':'
+                << std::setw(2) << unsigned(minor);
+
+            this->devices[dev] = out.str();
+            return out.str();
+        }
+    };
+
+
+    class MemMapsData
+    {
+    public:
+        guint timer;
+        GtkWidget *tree;
+        GSettings *settings;
+        ProcInfo *info;
+        OffsetFormater format;
+        mutable InodeDevices devices;
+        const char * const schema;
+
+        MemMapsData(GtkWidget *a_tree, GSettings *a_settings)
+            : tree(a_tree),
+            settings(a_settings),
+            schema("memmapstree")
+        {
+            procman_get_tree_state(this->settings, this->tree, this->schema);
+        }
+
+        ~MemMapsData()
+        {
+            procman_save_tree_state(this->settings, this->tree, this->schema);
+        }
+    };
+}
+
+
+struct glibtop_map_entry_cmp
+{
+    bool operator()(const glibtop_map_entry &a, const guint64 start) const
+    {
+        return a.start < start;
+    }
+
+    bool operator()(const guint64 &start, const glibtop_map_entry &a) const
+    {
+        return start < a.start;
+    }
+
+};
+
+
+static void
+update_row(GtkTreeModel *model, GtkTreeIter &row, const MemMapsData &mm, const glibtop_map_entry *memmaps)
+{
+    guint64 size;
+    string filename, device;
+    string vmstart, vmend, vmoffset;
+    char flags[5] = "----";
+
+    size = memmaps->end - memmaps->start;
+
+    if(memmaps->perm & GLIBTOP_MAP_PERM_READ)    flags [0] = 'r';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_WRITE)   flags [1] = 'w';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_EXECUTE) flags [2] = 'x';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_SHARED)  flags [3] = 's';
+    if(memmaps->perm & GLIBTOP_MAP_PERM_PRIVATE) flags [3] = 'p';
+
+    if (memmaps->flags & (1 << GLIBTOP_MAP_ENTRY_FILENAME))
+      filename = memmaps->filename;
+
+    vmstart  = mm.format(memmaps->start);
+    vmend    = mm.format(memmaps->end);
+    vmoffset = mm.format(memmaps->offset);
+    device   = mm.devices.get(memmaps->device);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        MMAP_COL_FILENAME, filename.c_str(),
+                        MMAP_COL_VMSTART, vmstart.c_str(),
+                        MMAP_COL_VMEND, vmend.c_str(),
+                        MMAP_COL_VMSZ, size,
+                        MMAP_COL_FLAGS, flags,
+                        MMAP_COL_VMOFFSET, vmoffset.c_str(),
+                        MMAP_COL_PRIVATE_CLEAN, memmaps->private_clean,
+                        MMAP_COL_PRIVATE_DIRTY, memmaps->private_dirty,
+                        MMAP_COL_SHARED_CLEAN, memmaps->shared_clean,
+                        MMAP_COL_SHARED_DIRTY, memmaps->shared_dirty,
+                        MMAP_COL_DEVICE, device.c_str(),
+                        MMAP_COL_INODE, memmaps->inode,
+                        -1);
+}
+
+
+
+
+static void
+update_memmaps_dialog (MemMapsData *mmdata)
+{
+    GtkTreeModel *model;
+    glibtop_map_entry *memmaps;
+    glibtop_proc_map procmap;
+
+    memmaps = glibtop_get_proc_map (&procmap, mmdata->info->pid);
+    /* process has disappeared */
+    if(!memmaps or procmap.number == 0) return;
+
+    mmdata->format.set(memmaps[procmap.number - 1]);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+
+    GtkTreeIter iter;
+
+    typedef std::map<guint64, GtkTreeIter> IterCache;
+    IterCache iter_cache;
+
+    /*
+      removes the old maps and
+      also fills a cache of start -> iter in order to speed
+      up add
+    */
+
+    if (gtk_tree_model_get_iter_first(model, &iter)) {
+        while (true) {
+            char *vmstart = 0;
+            guint64 start;
+            gtk_tree_model_get(model, &iter,
+                               MMAP_COL_VMSTART, &vmstart,
+                               -1);
+
+            try {
+                std::istringstream(vmstart) >> std::hex >> start;
+            } catch (std::logic_error &e) {
+                g_warning("Could not parse %s", vmstart);
+                start = 0;
+            }
+
+            g_free(vmstart);
+
+            bool found = std::binary_search(memmaps, memmaps + procmap.number,
+                                            start, glibtop_map_entry_cmp());
+
+            if (found) {
+                iter_cache[start] = iter;
+                if (!gtk_tree_model_iter_next(model, &iter))
+                    break;
+            } else {
+                if (!gtk_list_store_remove(GTK_LIST_STORE(model), &iter))
+                    break;
+            }
+        }
+    }
+
+    mmdata->devices.update();
+
+    /*
+      add the new maps
+    */
+
+    for (guint i = 0; i != procmap.number; i++) {
+        GtkTreeIter iter;
+        IterCache::iterator it(iter_cache.find(memmaps[i].start));
+
+        if (it != iter_cache.end())
+            iter = it->second;
+        else
+            gtk_list_store_prepend(GTK_LIST_STORE(model), &iter);
+
+        update_row(model, iter, *mmdata, &memmaps[i]);
+    }
+
+    g_free (memmaps);
+}
+
+
+
+static void
+dialog_response (GtkDialog * dialog, gint response_id, gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+
+    g_source_remove (mmdata->timer);
+
+    delete mmdata;
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+
+static MemMapsData*
+create_memmapsdata (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    guint i;
+
+    const gchar * const titles[] = {
+        N_("Filename"),
+        // xgettext: virtual memory start
+        N_("VM Start"),
+        // xgettext: virtual memory end
+        N_("VM End"),
+        // xgettext: virtual memory syze
+        N_("VM Size"),
+        N_("Flags"),
+        // xgettext: virtual memory offset
+        N_("VM Offset"),
+        // xgettext: memory that has not been modified since
+        // it has been allocated
+        N_("Private clean"),
+        // xgettext: memory that has been modified since it
+        // has been allocated
+        N_("Private dirty"),
+        // xgettext: shared memory that has not been modified
+        // since it has been allocated
+        N_("Shared clean"),
+        // xgettext: shared memory that has been modified
+        // since it has been allocated
+        N_("Shared dirty"),
+        N_("Device"),
+        N_("Inode")
+    };
+
+    model = gtk_list_store_new (MMAP_COL_MAX,
+                                G_TYPE_STRING, /* MMAP_COL_FILENAME  */
+                                G_TYPE_STRING, /* MMAP_COL_VMSTART     */
+                                G_TYPE_STRING, /* MMAP_COL_VMEND     */
+                                G_TYPE_UINT64, /* MMAP_COL_VMSZ     */
+                                G_TYPE_STRING, /* MMAP_COL_FLAGS     */
+                                G_TYPE_STRING, /* MMAP_COL_VMOFFSET  */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_PRIVATE_DIRTY */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_CLEAN */
+                                G_TYPE_UINT64, /* MMAP_COL_SHARED_DIRTY */
+                                G_TYPE_STRING, /* MMAP_COL_DEVICE     */
+                                G_TYPE_UINT64 /* MMAP_COL_INODE     */
+                                );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < MMAP_COL_MAX; i++) {
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(tree), col);
+
+        switch (i) {
+            case MMAP_COL_PRIVATE_CLEAN:
+            case MMAP_COL_PRIVATE_DIRTY:
+            case MMAP_COL_SHARED_CLEAN:
+            case MMAP_COL_SHARED_DIRTY:
+            case MMAP_COL_VMSZ:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                         &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+
+                g_object_set(cell, "xalign", 1.0f, NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+                break;
+        }
+
+
+        switch (i) {
+            case MMAP_COL_VMSTART:
+            case MMAP_COL_VMEND:
+            case MMAP_COL_FLAGS:
+            case MMAP_COL_VMOFFSET:
+            case MMAP_COL_DEVICE:
+                g_object_set(cell, "family", "monospace", NULL);
+                break;
+        }
+    }
+
+    return new MemMapsData(tree, procdata->settings);
+}
+
+
+static gboolean
+memmaps_timer (gpointer data)
+{
+    MemMapsData * const mmdata = static_cast<MemMapsData*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (mmdata->tree));
+    g_assert(model);
+
+    update_memmaps_dialog (mmdata);
+
+    return TRUE;
+}
+
+
+static void
+create_single_memmaps_dialog (GtkTreeModel *model, GtkTreePath *path,
+                              GtkTreeIter *iter, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    MemMapsData *mmdata;
+    GtkWidget *memmapsdialog;
+    GtkWidget *dialog_vbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    ProcInfo *info;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    mmdata = create_memmapsdata (procdata);
+    mmdata->info = info;
+
+    memmapsdialog = gtk_dialog_new_with_buttons (_("Memory Maps"), GTK_WINDOW (procdata->app),
+                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                 "gtk-close", GTK_RESPONSE_CLOSE,
+                                                 NULL);
+    gtk_window_set_resizable(GTK_WINDOW(memmapsdialog), TRUE);
+    gtk_window_set_default_size(GTK_WINDOW(memmapsdialog), 620, 400);
+    gtk_container_set_border_width(GTK_CONTAINER(memmapsdialog), 5);
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG(memmapsdialog));
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Memory maps for process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), label, FALSE, TRUE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    gtk_container_add (GTK_CONTAINER (scrolled), mmdata->tree);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), mmdata->tree);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+
+    g_signal_connect(G_OBJECT(memmapsdialog), "response",
+                              G_CALLBACK(dialog_response), mmdata);
+
+    gtk_widget_show_all (memmapsdialog);
+
+    mmdata->timer = g_timeout_add_seconds (5, memmaps_timer, mmdata);
+
+    update_memmaps_dialog (mmdata);
+}
+
+
+void
+create_memmaps_dialog (ProcData *procdata)
+{
+    /* TODO: do we really want to open multiple dialogs ? */
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_memmaps_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/27.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/27.html new file mode 100644 index 00000000..3b2e16f5 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/27.html @@ -0,0 +1,1071 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#if defined (__ELF__) && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
+# define SECTION __attribute__ ((section (".gresource.msm"), aligned (8)))
+#else
+# define SECTION
+#endif
+
+static const SECTION union { const guint8 data[3353]; const double alignment; void * const ptr;}  msm_resource_data = { {<--- union member 'Anonymous0::alignment' is never used.<--- union member 'Anonymous0::ptr' is never used.
+  0107, 0126, 0141, 0162, 0151, 0141, 0156, 0164, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0030, 0000, 0000, 0000, 0310, 0000, 0000, 0000, 0000, 0000, 0000, 0050, 0006, 0000, 0000, 0000, 
+  0000, 0000, 0000, 0000, 0001, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0005, 0000, 0000, 0000, 0376, 0236, 0033, 0101, 0005, 0000, 0000, 0000, 
+  0310, 0000, 0000, 0000, 0024, 0000, 0114, 0000, 0334, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 
+  0113, 0120, 0220, 0013, 0002, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 0004, 0000, 0114, 0000, 
+  0350, 0000, 0000, 0000, 0354, 0000, 0000, 0000, 0324, 0265, 0002, 0000, 0377, 0377, 0377, 0377, 
+  0354, 0000, 0000, 0000, 0001, 0000, 0114, 0000, 0360, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 
+  0173, 0250, 0316, 0037, 0000, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 0014, 0000, 0166, 0000, 
+  0000, 0001, 0000, 0000, 0034, 0006, 0000, 0000, 0234, 0164, 0275, 0021, 0000, 0000, 0000, 0000, 
+  0034, 0006, 0000, 0000, 0016, 0000, 0166, 0000, 0060, 0006, 0000, 0000, 0017, 0015, 0000, 0000, 
+  0201, 0321, 0040, 0031, 0001, 0000, 0000, 0000, 0017, 0015, 0000, 0000, 0005, 0000, 0114, 0000, 
+  0024, 0015, 0000, 0000, 0030, 0015, 0000, 0000, 0155, 0141, 0164, 0145, 0055, 0163, 0171, 0163, 
+  0164, 0145, 0155, 0055, 0155, 0157, 0156, 0151, 0164, 0157, 0162, 0057, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0157, 0162, 0147, 0057, 0005, 0000, 0000, 0000, 0057, 0000, 0000, 0000, 
+  0001, 0000, 0000, 0000, 0151, 0156, 0164, 0145, 0162, 0146, 0141, 0143, 0145, 0056, 0165, 0151, 
+  0242, 0073, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0133, 0133, 0163, 0352, 0066, 
+  0020, 0176, 0317, 0257, 0160, 0375, 0332, 0161, 0010, 0227, 0320, 0164, 0006, 0070, 0323, 0166, 
+  0232, 0364, 0241, 0347, 0114, 0046, 0344, 0114, 0037, 0031, 0331, 0136, 0260, 0212, 0054, 0271, 
+  0222, 0314, 0345, 0337, 0237, 0065, 0066, 0004, 0002, 0370, 0102, 0210, 0061, 0224, 0067, 0154, 
+  0257, 0054, 0355, 0267, 0253, 0335, 0317, 0253, 0245, 0363, 0145, 0346, 0063, 0143, 0002, 0122, 
+  0121, 0301, 0273, 0146, 0375, 0366, 0316, 0064, 0200, 0073, 0302, 0245, 0174, 0324, 0065, 0277, 
+  0277, 0076, 0132, 0017, 0346, 0227, 0336, 0115, 0347, 0047, 0313, 0062, 0236, 0200, 0203, 0044, 
+  0032, 0134, 0143, 0112, 0265, 0147, 0214, 0030, 0161, 0301, 0150, 0336, 0066, 0037, 0156, 0033, 
+  0206, 0145, 0241, 0020, 0345, 0032, 0344, 0220, 0070, 0320, 0353, 0110, 0370, 0057, 0244, 0022, 
+  0224, 0301, 0250, 0335, 0065, 0107, 0172, 0374, 0263, 0371, 0066, 0113, 0363, 0266, 0321, 0062, 
+  0153, 0275, 0216, 0260, 0377, 0005, 0107, 0033, 0016, 0043, 0112, 0165, 0315, 0047, 0075, 0376, 
+  0207, 0162, 0127, 0114, 0115, 0203, 0272, 0135, 0323, 0047, 0224, 0017, 0246, 0361, 0215, 0136, 
+  0047, 0220, 0042, 0000, 0251, 0347, 0006, 0047, 0076, 0164, 0115, 0207, 0160, 0153, 0050, 0234, 
+  0120, 0231, 0275, 0107, 0302, 0024, 0164, 0152, 0113, 0201, 0055, 0121, 0115, 0065, 0003, 0323, 
+  0320, 0222, 0160, 0305, 0210, 0046, 0066, 0303, 0233, 0163, 0300, 0221, 0375, 0271, 0322, 0340, 
+  0033, 0137, 0005, 0247, 0132, 0310, 0224, 0127, 0270, 0060, 0044, 0041, 0323, 0326, 0224, 0272, 
+  0332, 0063, 0173, 0255, 0326, 0135, 0016, 0141, 0017, 0350, 0310, 0323, 0050, 0375, 0353, 0375, 
+  0272, 0264, 0343, 0121, 0346, 0356, 0120, 0375, 0167, 0061, 0133, 0323, 0333, 0306, 0253, 0255, 
+  0067, 0117, 0250, 0242, 0270, 0172, 0263, 0367, 0052, 0303, 0064, 0215, 0013, 0200, 0043, 0044, 
+  0005, 0256, 0211, 0106, 0263, 0230, 0075, 0264, 0217, 0246, 0016, 0141, 0073, 0226, 0033, 0060, 
+  0264, 0252, 0047, 0230, 0013, 0022, 0355, 0126, 0113, 0356, 0356, 0323, 0345, 0233, 0320, 0140, 
+  0013, 0061, 0216, 0025, 0342, 0313, 0253, 0143, 0050, 0224, 0041, 0351, 0023, 0071, 0242, 0334, 
+  0122, 0232, 0110, 0204, 0276, 0336, 0310, 0026, 0005, 0356, 0346, 0023, 0324, 0042, 0170, 0057, 
+  0230, 0151, 0113, 0065, 0127, 0224, 0017, 0105, 0151, 0346, 0364, 0140, 0026, 0220, 0110, 0241, 
+  0214, 0127, 0116, 0162, 0312, 0331, 0102, 0242, 0305, 0227, 0176, 0237, 0212, 0222, 0012, 0210, 
+  0203, 0061, 0143, 0017, 0104, 0251, 0376, 0263, 0373, 0141, 0055, 0206, 0365, 0235, 0264, 0241, 
+  0347, 0101, 0264, 0251, 0211, 0155, 0356, 0000, 0376, 0157, 0142, 0003, 0333, 0204, 0236, 0055, 
+  0156, 0225, 0001, 0176, 0074, 0323, 0376, 0100, 0263, 0076, 0164, 0245, 0034, 0242, 0066, 0106, 
+  0330, 0266, 0243, 0026, 0261, 0255, 0041, 0145, 0154, 0307, 0264, 0265, 0325, 0230, 0254, 0175, 
+  0270, 0362, 0103, 0034, 0354, 0374, 0037, 0234, 0060, 0063, 0234, 0355, 0165, 0332, 0207, 0074, 
+  0373, 0172, 0315, 0275, 0230, 0040, 0356, 0200, 0114, 0106, 0045, 0372, 0227, 0107, 0030, 0035, 
+  0241, 0136, 0213, 0340, 0126, 0310, 0231, 0226, 0100, 0147, 0315, 0020, 0073, 0134, 0306, 0212, 
+  0003, 0241, 0150, 0014, 0360, 0335, 0141, 0136, 0331, 0167, 0244, 0140, 0014, 0334, 0365, 0144, 
+  0037, 0071, 0050, 0050, 0005, 0152, 0240, 0222, 0247, 0145, 0144, 0213, 0143, 0173, 0252, 0362, 
+  0010, 0152, 0144, 0105, 0041, 0312, 0354, 0121, 0236, 0073, 0016, 0236, 0312, 0200, 0365, 0003, 
+  0303, 0112, 0250, 0065, 0016, 0137, 0030, 0016, 0323, 0147, 0142, 0073, 0073, 0276, 0133, 0040, 
+  0054, 0376, 0311, 0135, 0143, 0360, 0034, 0217, 0116, 0131, 0157, 0250, 0300, 0042, 0116, 0264, 
+  0142, 0213, 0004, 0001, 0020, 0174, 0221, 0003, 0331, 0130, 0034, 0337, 0135, 0044, 0070, 0100, 
+  0047, 0240, 0254, 0204, 0342, 0145, 0373, 0127, 0262, 0143, 0021, 0244, 0014, 0375, 0102, 0216, 
+  0036, 0301, 0050, 0337, 0261, 0334, 0123, 0071, 0107, 0043, 0335, 0071, 0062, 0227, 0125, 0314, 
+  0315, 0162, 0347, 0365, 0105, 0052, 0253, 0102, 0122, 0177, 0136, 0206, 0254, 0102, 0306, 0332, 
+  0203, 0312, 0247, 0146, 0177, 0374, 0014, 0273, 0046, 0377, 0242, 0214, 0165, 0077, 0234, 0116, 
+  0020, 0126, 0347, 0373, 0154, 0257, 0116, 0167, 0005, 0011, 0115, 0244, 0125, 0025, 0266, 0325, 
+  0037, 0317, 0337, 0215, 0277, 0250, 0302, 0017, 0362, 0171, 0312, 0370, 0131, 0022, 0131, 0067, 
+  0264, 0044, 0132, 0113, 0212, 0151, 0010, 0324, 0332, 0357, 0144, 0300, 0064, 0376, 0032, 0067, 
+  0046, 0204, 0205, 0013, 0267, 0142, 0156, 0124, 0201, 0250, 0255, 0217, 0071, 0063, 0036, 0265, 
+  0341, 0220, 0043, 0111, 0002, 0357, 0154, 0167, 0371, 0301, 0156, 0336, 0376, 0160, 0255, 0342, 
+  0221, 0211, 0351, 0006, 0222, 0103, 0274, 0121, 0032, 0220, 0223, 0175, 0234, 0076, 0265, 0256, 
+  0161, 0377, 0113, 0332, 0354, 0202, 0205, 0076, 0212, 0056, 0041, 0112, 0013, 0231, 0022, 0331, 
+  0152, 0056, 0101, 0037, 0047, 0137, 0040, 0050, 0201, 0133, 0370, 0300, 0212, 0271, 0112, 0063, 
+  0165, 0311, 0263, 0135, 0103, 0322, 0213, 0010, 0300, 0040, 0146, 0172, 0276, 0160, 0121, 0230, 
+  0013, 0176, 0112, 0056, 0204, 0223, 0044, 0144, 0076, 0235, 0301, 0345, 0246, 0072, 0025, 0045, 
+  0372, 0347, 0032, 0370, 0174, 0360, 0057, 0060, 0023, 0107, 0132, 0125, 0041, 0023, 0177, 0005, 
+  0037, 0223, 0260, 0201, 0206, 0067, 0372, 0123, 0022, 0134, 0263, 0162, 0161, 0347, 0274, 0146, 
+  0345, 0174, 0131, 0071, 0072, 0135, 0302, 0004, 0263, 0310, 0134, 0252, 0333, 0302, 0337, 0230, 
+  0231, 0124, 0167, 0161, 0254, 0264, 0015, 0361, 0223, 0244, 0356, 0033, 0306, 0013, 0227, 0055, 
+  0005, 0337, 0002, 0111, 0070, 0257, 0051, 0066, 0022, 0160, 0273, 0100, 0126, 0157, 0147, 0274, 
+  0324, 0023, 0276, 0030, 0001, 0007, 0261, 0253, 0256, 0221, 0043, 0010, 0051, 0334, 0361, 0145, 
+  0326, 0066, 0163, 0342, 0225, 0122, 0143, 0307, 0005, 0027, 0015, 0115, 0231, 0241, 0205, 0301, 
+  0120, 0133, 0030, 0214, 0210, 0343, 0245, 0223, 0035, 0055, 0202, 0225, 0334, 0201, 0201, 0143, 
+  0063, 0003, 0140, 0240, 0075, 0053, 0370, 0343, 0144, 0361, 0271, 0006, 0250, 0037, 0325, 0000, 
+  0007, 0034, 0111, 0235, 0342, 0341, 0225, 0362, 0136, 0024, 0345, 0255, 0177, 0220, 0125, 0160, 
+  0320, 0027, 0110, 0171, 0043, 0255, 0252, 0100, 0171, 0277, 0201, 0236, 0012, 0071, 0276, 0122, 
+  0335, 0342, 0116, 0171, 0245, 0272, 0173, 0330, 0154, 0073, 0067, 0233, 0215, 0140, 0074, 0031, 
+  0233, 0155, 0345, 0154, 0225, 0151, 0076, 0134, 0062, 0355, 0215, 0217, 0370, 0160, 0252, 0263, 
+  0042, 0137, 0057, 0313, 0125, 0237, 0023, 0377, 0112, 0063, 0203, 0026, 0232, 0260, 0101, 0162, 
+  0336, 0352, 0236, 0225, 0055, 0136, 0243, 0245, 0033, 0057, 0311, 0322, 0253, 0141, 0220, 0372, 
+  0207, 0015, 0242, 0160, 0357, 0237, 0333, 0256, 0350, 0143, 0104, 0377, 0134, 0374, 0357, 0113, 
+  0336, 0020, 0150, 0005, 0175, 0206, 0233, 0241, 0072, 0206, 0070, 0302, 0106, 0300, 0101, 0040, 
+  0267, 0341, 0137, 0034, 0120, 0133, 0121, 0327, 0063, 0050, 0235, 0221, 0045, 0077, 0215, 0322, 
+  0366, 0156, 0112, 0256, 0156, 0154, 0071, 0114, 0334, 0362, 0334, 0070, 0014, 0346, 0337, 0042, 
+  0077, 0360, 0321, 0131, 0336, 0347, 0342, 0200, 0072, 0143, 0220, 0003, 0262, 0172, 0136, 0006, 
+  0244, 0233, 0235, 0007, 0355, 0343, 0065, 0163, 0155, 0300, 0176, 0127, 0071, 0330, 0227, 0241, 
+  0376, 0202, 0101, 0157, 0225, 0016, 0372, 0045, 0026, 0176, 0076, 0122, 0146, 0313, 0255, 0134, 
+  0306, 0262, 0057, 0243, 0050, 0164, 0274, 0126, 0273, 0306, 0061, 0133, 0355, 0242, 0276, 0261, 
+  0052, 0124, 0145, 0136, 0100, 0211, 0120, 0072, 0007, 0167, 0332, 0065, 0112, 0353, 0264, 0033, 
+  0226, 0327, 0150, 0127, 0106, 0143, 0134, 0073, 0317, 0327, 0363, 0256, 0166, 0156, 0227, 0252, 
+  0361, 0265, 0225, 0273, 0102, 0045, 0274, 0002, 0273, 0245, 0171, 0314, 0020, 0062, 0254, 0106, 
+  0004, 0171, 0244, 0014, 0214, 0370, 0137, 0070, 0207, 0006, 0221, 0346, 0261, 0202, 0310, 0231, 
+  0235, 0074, 0364, 0061, 0160, 0204, 0312, 0046, 0062, 0141, 0207, 0253, 0313, 0112, 0237, 0100, 
+  0064, 0076, 0261, 0153, 0054, 0113, 0252, 0170, 0136, 0337, 0276, 0361, 0366, 0117, 0332, 0233, 
+  0037, 0325, 0360, 0311, 0023, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0160, 0162, 0145, 0146, 
+  0145, 0162, 0145, 0156, 0143, 0145, 0163, 0056, 0165, 0151, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0065, 0123, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0134, 0335, 0162, 0342, 0066, 
+  0024, 0276, 0357, 0123, 0250, 0276, 0355, 0050, 0004, 0262, 0155, 0167, 0072, 0301, 0073, 0335, 
+  0335, 0046, 0335, 0231, 0266, 0263, 0323, 0354, 0266, 0227, 0036, 0331, 0076, 0140, 0155, 0204, 
+  0344, 0112, 0002, 0102, 0257, 0372, 0054, 0175, 0264, 0076, 0111, 0217, 0177, 0010, 0140, 0300, 
+  0066, 0004, 0210, 0041, 0334, 0331, 0346, 0110, 0072, 0072, 0377, 0237, 0216, 0206, 0353, 0067, 
+  0017, 0003, 0101, 0106, 0240, 0015, 0127, 0262, 0353, 0264, 0057, 0056, 0035, 0002, 0062, 0120, 
+  0041, 0227, 0375, 0256, 0363, 0371, 0323, 0015, 0175, 0355, 0274, 0161, 0277, 0272, 0376, 0232, 
+  0122, 0162, 0013, 0022, 0064, 0263, 0020, 0222, 0061, 0267, 0021, 0351, 0013, 0026, 0002, 0271, 
+  0272, 0270, 0172, 0175, 0321, 0041, 0224, 0042, 0021, 0227, 0026, 0164, 0217, 0005, 0340, 0136, 
+  0153, 0370, 0153, 0310, 0065, 0030, 0042, 0270, 0337, 0165, 0372, 0366, 0376, 0033, 0147, 0266, 
+  0312, 0325, 0105, 0347, 0225, 0323, 0162, 0257, 0225, 0377, 0005, 0002, 0113, 0002, 0301, 0214, 
+  0351, 0072, 0267, 0366, 0376, 0303, 0200, 0365, 0301, 0041, 0074, 0354, 0072, 0074, 0171, 0154, 
+  0073, 0356, 0165, 0254, 0125, 0014, 0332, 0116, 0210, 0144, 0003, 0350, 0072, 0043, 0156, 0270, 
+  0057, 0300, 0161, 0077, 0351, 0041, 0134, 0267, 0246, 0277, 0056, 0321, 0005, 0114, 0322, 0236, 
+  0012, 0206, 0306, 0161, 0157, 0230, 0060, 0145, 0244, 0074, 0120, 0222, 0046, 0217, 0216, 0073, 
+  0346, 0062, 0124, 0143, 0032, 0010, 0265, 0070, 0242, 0225, 0261, 0132, 0203, 0345, 0316, 0241, 
+  0131, 0216, 0100, 0304, 0324, 0327, 0152, 0154, 0100, 0327, 0143, 0371, 0075, 0147, 0102, 0365, 
+  0063, 0236, 0143, 0015, 0075, 0320, 0250, 0161, 0060, 0136, 0230, 0175, 0177, 0012, 0137, 0276, 
+  0322, 0041, 0150, 0072, 0346, 0241, 0215, 0034, 0367, 0333, 0022, 0112, 0313, 0055, 0212, 0204, 
+  0130, 0315, 0244, 0021, 0314, 0062, 0024, 0120, 0327, 0231, 0000, 0256, 0161, 0067, 0061, 0026, 
+  0006, 0344, 0127, 0045, 0271, 0125, 0232, 0174, 0234, 0161, 0130, 0062, 0135, 0010, 0075, 0066, 
+  0024, 0166, 0272, 0362, 0253, 0313, 0313, 0032, 0304, 0021, 0360, 0176, 0144, 0221, 0272, 0123, 
+  0116, 0155, 0254, 0126, 0023, 0232, 0030, 0075, 0215, 0031, 0262, 0142, 0053, 0125, 0151, 0047, 
+  0061, 0320, 0210, 0047, 0224, 0231, 0124, 0347, 0151, 0203, 0210, 0213, 0220, 0244, 0316, 0042, 
+  0231, 0240, 0351, 0053, 0132, 0211, 0257, 0036, 0234, 0025, 0332, 0172, 0213, 0237, 0123, 0125, 
+  0145, 0023, 0171, 0202, 0115, 0324, 0320, 0076, 0111, 0113, 0003, 0246, 0373, 0134, 0122, 0253, 
+  0342, 0162, 0035, 0345, 0164, 0276, 0262, 0126, 0015, 0312, 0111, 0225, 0346, 0050, 0027, 0146, 
+  0321, 0277, 0035, 0027, 0035, 0335, 0362, 0200, 0211, 0022, 0172, 0023, 0263, 0000, 0103, 0214, 
+  0343, 0166, 0252, 0045, 0303, 0202, 0144, 0132, 0017, 0045, 0317, 0126, 0012, 0150, 0210, 0354, 
+  0311, 0242, 0230, 0026, 0007, 0155, 0040, 0253, 0164, 0321, 0265, 0313, 0144, 0153, 0044, 0076, 
+  0347, 0371, 0331, 0207, 0245, 0311, 0005, 0363, 0101, 0070, 0356, 0317, 0110, 0123, 0042, 0200, 
+  0241, 0001, 0232, 0361, 0110, 0131, 0034, 0003, 0103, 0077, 0010, 0240, 0132, 0165, 0133, 0304, 
+  0222, 0012, 0112, 0015, 0001, 0360, 0021, 0030, 0232, 0173, 0105, 0345, 0200, 0064, 0314, 0071, 
+  0156, 0026, 0355, 0126, 0106, 0034, 0324, 0355, 0075, 0052, 0167, 0151, 0044, 0074, 0304, 0114, 
+  0206, 0325, 0233, 0354, 0161, 0041, 0052, 0331, 0210, 0225, 0341, 0231, 0271, 0055, 0070, 0157, 
+  0353, 0161, 0361, 0126, 0256, 0311, 0072, 0012, 0115, 0003, 0176, 0225, 0106, 0337, 0025, 0263, 
+  0302, 0111, 0252, 0264, 0335, 0004, 0225, 0266, 0313, 0125, 0172, 0140, 0266, 0160, 0021, 0232, 
+  0104, 0164, 0307, 0005, 0031, 0356, 0320, 0044, 0223, 0242, 0112, 0322, 0100, 0211, 0341, 0100, 
+  0232, 0156, 0033, 0237, 0223, 0064, 0216, 0017, 0130, 0115, 0055, 0333, 0353, 0255, 0346, 0141, 
+  0156, 0255, 0012, 0043, 0244, 0264, 0136, 0077, 0371, 0162, 0210, 0162, 0143, 0323, 0350, 0236, 
+  0155, 0211, 0226, 0004, 0371, 0025, 0373, 0373, 0115, 0131, 0360, 0225, 0272, 0317, 0366, 0050, 
+  0247, 0157, 0007, 0360, 0227, 0150, 0152, 0056, 0025, 0164, 0243, 0232, 0164, 0045, 0125, 0120, 
+  0271, 0346, 0073, 0125, 0232, 0307, 0211, 0260, 0016, 0062, 0130, 0254, 0141, 0305, 0344, 0345, 
+  0166, 0160, 0020, 0023, 0330, 0257, 0214, 0332, 0235, 0035, 0132, 0037, 0212, 0162, 0146, 0172, 
+  0355, 0327, 0173, 0021, 0277, 0017, 0021, 0033, 0161, 0245, 0017, 0042, 0373, 0205, 0015, 0175, 
+  0127, 0307, 0227, 0176, 0111, 0063, 0326, 0032, 0236, 0275, 0074, 0237, 0035, 0302, 0152, 0230, 
+  0340, 0175, 0324, 0232, 0261, 0114, 0333, 0022, 0272, 0214, 0243, 0125, 0150, 0340, 0155, 0316, 
+  0164, 0131, 0055, 0211, 0162, 0021, 0100, 0005, 0227, 0100, 0007, 0052, 0134, 0261, 0001, 0146, 
+  0255, 0346, 0230, 0335, 0301, 0314, 0075, 0347, 0243, 0307, 0031, 0010, 0040, 0043, 0046, 0206, 
+  0251, 0135, 0212, 0060, 0301, 0246, 0255, 0371, 0061, 0225, 0371, 0106, 0100, 0317, 0122, 0034, 
+  0301, 0202, 0250, 0020, 0374, 0213, 0300, 0100, 0305, 0253, 0351, 0066, 0115, 0022, 0257, 0066, 
+  0267, 0125, 0317, 0100, 0220, 0071, 0321, 0001, 0064, 0237, 0143, 0207, 0124, 0361, 0025, 0376, 
+  0135, 0151, 0336, 0213, 0042, 0350, 0324, 0316, 0223, 0303, 0070, 0144, 0026, 0274, 0024, 0117, 
+  0240, 0172, 0017, 0227, 0057, 0353, 0006, 0313, 0142, 0236, 0154, 0167, 0266, 0166, 0356, 0307, 
+  0115, 0036, 0316, 0271, 0327, 0073, 0255, 0367, 0071, 0225, 0074, 0231, 0062, 0205, 0017, 0004, 
+  0215, 0117, 0311, 0320, 0374, 0120, 0121, 0100, 0017, 0045, 0246, 0205, 0304, 0225, 0053, 0071, 
+  0035, 0110, 0030, 0050, 0311, 0203, 0044, 0207, 0364, 0001, 0215, 0154, 0205, 0060, 0114, 0314, 
+  0245, 0134, 0163, 0056, 0362, 0014, 0276, 0274, 0244, 0312, 0073, 0344, 0157, 0036, 0207, 0254, 
+  0337, 0302, 0041, 0352, 0040, 0056, 0363, 0071, 0021, 0171, 0063, 0134, 0361, 0277, 0177, 0376, 
+  0055, 0233, 0127, 0360, 0201, 0117, 0223, 0003, 0301, 0102, 0275, 0136, 0074, 0077, 0341, 0175, 
+  0156, 0115, 0241, 0010, 0334, 0114, 0013, 0355, 0335, 0150, 0241, 0121, 0252, 0177, 0027, 0101, 
+  0260, 0200, 0101, 0315, 0100, 0051, 0033, 0125, 0200, 0320, 0125, 0336, 0366, 0223, 0114, 0136, 
+  0210, 0227, 0115, 0100, 0064, 0364, 0064, 0230, 0350, 0070, 0201, 0152, 0025, 0017, 0233, 0205, 
+  0210, 0120, 0263, 0061, 0345, 0062, 0304, 0202, 0321, 0046, 0265, 0132, 0221, 0174, 0077, 0006, 
+  0321, 0336, 0221, 0101, 0004, 0311, 0207, 0055, 0354, 0341, 0107, 0201, 0144, 0304, 0207, 0236, 
+  0322, 0100, 0020, 0261, 0342, 0352, 0104, 0151, 0342, 0335, 0043, 0330, 0115, 0236, 0037, 0203, 
+  0314, 0331, 0104, 0236, 0313, 0104, 0072, 0273, 0212, 0031, 0112, 0060, 0315, 0315, 0026, 0106, 
+  0342, 0275, 0347, 0043, 0036, 0002, 0171, 0367, 0361, 0063, 0031, 0032, 0326, 0007, 0342, 0117, 
+  0322, 0227, 0100, 0015, 0245, 0075, 0133, 0306, 0163, 0131, 0306, 0325, 0163, 0244, 0260, 0166, 
+  0163, 0363, 0346, 0323, 0241, 0172, 0217, 0203, 0010, 0315, 0121, 0036, 0222, 0354, 0010, 0370, 
+  0147, 0022, 0150, 0004, 0062, 0370, 0040, 0061, 0053, 0015, 0322, 0263, 0034, 0162, 0223, 0262, 
+  0125, 0062, 0315, 0227, 0241, 0261, 0274, 0067, 0161, 0334, 0344, 0230, 0266, 0204, 0016, 0060, 
+  0257, 0305, 0206, 0377, 0135, 0171, 0100, 0133, 0175, 0122, 0120, 0030, 0360, 0220, 0237, 0137, 
+  0134, 0236, 0370, 0151, 0302, 0306, 0356, 0324, 0074, 0054, 0135, 0327, 0247, 0052, 0117, 0023, 
+  0267, 0161, 0255, 0324, 0304, 0033, 0341, 0140, 0037, 0063, 0326, 0010, 0367, 0346, 0074, 0315, 
+  0104, 0152, 0054, 0023, 0020, 0056, 0270, 0261, 0173, 0106, 0340, 0126, 0003, 0170, 0271, 0201, 
+  0155, 0352, 0131, 0315, 0302, 0346, 0201, 0126, 0102, 0100, 0370, 0147, 0172, 0047, 0244, 0250, 
+  0170, 0223, 0377, 0172, 0214, 0375, 0011, 0023, 0261, 0344, 0226, 0113, 0326, 0322, 0342, 0262, 
+  0216, 0361, 0177, 0102, 0255, 0376, 0301, 0141, 0116, 0014, 0363, 0172, 0076, 0214, 0020, 0030, 
+  0332, 0245, 0241, 0217, 0063, 0127, 0371, 0010, 0244, 0260, 0230, 0032, 0054, 0121, 0023, 0053, 
+  0130, 0335, 0350, 0137, 0272, 0154, 0140, 0100, 0074, 0236, 0222, 0256, 0224, 0302, 0335, 0043, 
+  0301, 0242, 0105, 0114, 0203, 0052, 0235, 0315, 0320, 0132, 0121, 0102, 0235, 0140, 0041, 0327, 
+  0350, 0105, 0027, 0274, 0234, 0044, 0046, 0217, 0363, 0060, 0337, 0251, 0033, 0340, 0223, 0076, 
+  0133, 0203, 0342, 0372, 0042, 0150, 0257, 0024, 0055, 0316, 0100, 0263, 0036, 0367, 0322, 0312, 
+  0073, 0357, 0112, 0153, 0060, 0152, 0250, 0203, 0163, 0157, 0362, 0171, 0172, 0223, 0063, 0361, 
+  0367, 0065, 0213, 0243, 0146, 0001, 0236, 0047, 0001, 0231, 0342, 0316, 0016, 0331, 0277, 0254, 
+  0271, 0277, 0365, 0176, 0173, 0233, 0262, 0174, 0006, 0071, 0307, 0000, 0162, 0226, 0014, 0255, 
+  0241, 0015, 0323, 0203, 0037, 0063, 0154, 0333, 0200, 0235, 0011, 0264, 0320, 0212, 0075, 0255, 
+  0056, 0354, 0154, 0233, 0347, 0056, 0254, 0273, 0102, 0030, 0307, 0326, 0205, 0135, 0277, 0205, 
+  0163, 0027, 0366, 0324, 0273, 0260, 0076, 0112, 0151, 0233, 0166, 0312, 0135, 0244, 0306, 0104, 
+  0202, 0035, 0053, 0175, 0117, 0114, 0014, 0220, 0100, 0113, 0222, 0314, 0166, 0232, 0275, 0224, 
+  0272, 0301, 0365, 0004, 0032, 0266, 0057, 0247, 0347, 0122, 0271, 0150, 0355, 0033, 0332, 0233, 
+  0301, 0355, 0105, 0350, 0330, 0204, 0334, 0371, 0373, 0224, 0243, 0215, 0254, 0157, 0215, 0170, 
+  0366, 0007, 0312, 0053, 0113, 0332, 0020, 0106, 0374, 0014, 0311, 0237, 0011, 0222, 0117, 0205, 
+  0177, 0074, 0227, 0205, 0213, 0034, 0037, 0025, 0324, 0256, 0161, 0125, 0370, 0014, 0266, 0033, 
+  0003, 0266, 0227, 0114, 0355, 0310, 0301, 0366, 0336, 0100, 0364, 0124, 0120, 0047, 0174, 0215, 
+  0171, 0151, 0213, 0057, 0027, 0076, 0057, 0211, 0342, 0330, 0300, 0363, 0272, 0015, 0234, 0241, 
+  0363, 0251, 0103, 0147, 0046, 0204, 0067, 0325, 0176, 0172, 0167, 0165, 0023, 0000, 0235, 0342, 
+  0147, 0017, 0247, 0040, 0230, 0232, 0201, 0230, 0364, 0117, 0000, 0316, 0330, 0371, 0214, 0235, 
+  0137, 0310, 0175, 0305, 0251, 0343, 0274, 0324, 0333, 0212, 0213, 0373, 0077, 0052, 0334, 0161, 
+  0276, 0323, 0170, 0012, 0056, 0167, 0302, 0067, 0032, 0367, 0350, 0247, 0315, 0271, 0370, 0170, 
+  0063, 0053, 0033, 0236, 0347, 0362, 0143, 0310, 0315, 0175, 0162, 0051, 0116, 0302, 0370, 0144, 
+  0357, 0077, 0116, 0265, 0377, 0242, 0157, 0077, 0256, 0120, 0364, 0013, 0276, 0000, 0231, 0233, 
+  0004, 0115, 0044, 0062, 0102, 0031, 0235, 0357, 0077, 0036, 0305, 0242, 0263, 0126, 0105, 0147, 
+  0227, 0235, 0234, 0004, 0274, 0171, 0071, 0170, 0153, 0114, 0063, 0047, 0115, 0015, 0167, 0313, 
+  0210, 0162, 0133, 0041, 0075, 0245, 0237, 0323, 0314, 0276, 0136, 0315, 0320, 0271, 0247, 0177, 
+  0161, 0232, 0176, 0310, 0341, 0174, 0226, 0120, 0115, 0341, 0235, 0150, 0060, 0261, 0222, 0006, 
+  0127, 0240, 0355, 0166, 0366, 0277, 0207, 0171, 0243, 0036, 0113, 0321, 0171, 0312, 0222, 0201, 
+  0337, 0073, 0356, 0374, 0137, 0175, 0055, 0015, 0154, 0025, 0131, 0230, 0361, 0070, 0373, 0163, 
+  0313, 0257, 0376, 0007, 0112, 0344, 0157, 0105, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0155, 
+  0141, 0164, 0145, 0057, 0000, 0000, 0000, 0000
+} };
+
+static GStaticResource static_resource = { msm_resource_data.data, sizeof (msm_resource_data.data) - 1 /* nul terminator */, NULL, NULL, NULL };
+
+G_MODULE_EXPORT
+GResource *msm_get_resource (void);
+GResource *msm_get_resource (void)
+{
+  return g_static_resource_get_resource (&static_resource);
+}
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GLib Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __G_CONSTRUCTOR_H__
+#define __G_CONSTRUCTOR_H__
+
+/*
+  If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and
+  destructors, in a usable way, including e.g. on library unload. If not you're on
+  your own.
+
+  Some compilers need #pragma to handle this, which does not work with macros,
+  so the way you need to use this is (for constructors):
+
+  #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+  #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(my_constructor)
+  #endif
+  G_DEFINE_CONSTRUCTOR(my_constructor)
+  static void my_constructor(void) {
+   ...
+  }
+
+*/
+
+#ifndef __GTK_DOC_IGNORE__
+
+#if  __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func (void);
+#define G_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func (void);
+
+#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
+/* Visual studio 2008 and later has _Pragma */
+
+/*
+ * Only try to include gslist.h if not already included via glib.h,
+ * so that items using gconstructor.h outside of GLib (such as
+ * GResources) continue to build properly.
+ */
+#ifndef __G_LIB_H__
+#include "gslist.h"
+#endif
+
+#include <stdlib.h>
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* We do some weird things to avoid the constructors being optimized
+ * away on VS2015 if WholeProgramOptimization is enabled. First we
+ * make a reference to the array from the wrapper to make sure its
+ * references. Then we use a pragma to make sure the wrapper function
+ * symbol is always included at the link stage. Also, the symbols
+ * need to be extern (but not dllexport), even though they are not
+ * really used from another object file.
+ */
+
+/* We need to account for differences between the mangling of symbols
+ * for x86 and x64/ARM/ARM64 programs, as symbols on x86 are prefixed
+ * with an underscore but symbols on x64/ARM/ARM64 are not.
+ */
+#ifdef _M_IX86
+#define G_MSVC_SYMBOL_PREFIX "_"
+#else
+#define G_MSVC_SYMBOL_PREFIX ""
+#endif
+
+#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
+#define G_DEFINE_DESTRUCTOR(_func) G_MSVC_DTOR (_func, G_MSVC_SYMBOL_PREFIX)
+
+#define G_MSVC_CTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _wrapper(void);              \
+  int _func ## _wrapper(void) { _func(); g_slist_find (NULL,  _array ## _func); return 0; } \
+  __pragma(comment(linker,"/include:" _sym_prefix # _func "_wrapper")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _wrapper;
+
+#define G_MSVC_DTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _constructor(void);              \
+  int _func ## _constructor(void) { atexit (_func); g_slist_find (NULL,  _array ## _func); return 0; } \
+   __pragma(comment(linker,"/include:" _sym_prefix # _func "_constructor")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined (_MSC_VER)
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* Pre Visual studio 2008 must use #pragma section */
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _wrapper(void) { _func(); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func ## _wrapper;
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _constructor(void) { atexit (_func); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined(__SUNPRO_C)
+
+/* This is not tested, but i believe it should work, based on:
+ * http://opensource.apple.com/source/OpenSSL098/OpenSSL098-35/src/fips/fips_premain.c
+ */
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  init(_func)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void);
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  fini(_func)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void);
+
+#else
+
+/* constructors not supported for this compiler */
+
+#endif
+
+#endif /* __GTK_DOC_IGNORE__ */
+#endif /* __G_CONSTRUCTOR_H__ */
+
+#ifdef G_HAS_CONSTRUCTORS
+
+#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(msmresource_constructor)
+#endif
+G_DEFINE_CONSTRUCTOR(msmresource_constructor)
+#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(msmresource_destructor)
+#endif
+G_DEFINE_DESTRUCTOR(msmresource_destructor)
+
+#else
+#warning "Constructor not supported on this compiler, linking in resources will not work"
+#endif
+
+static void msmresource_constructor (void)
+{
+  g_static_resource_init (&static_resource);
+}
+
+static void msmresource_destructor (void)
+{
+  g_static_resource_fini (&static_resource);
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/28.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/28.html new file mode 100644 index 00000000..d6f26215 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/28.html @@ -0,0 +1,1039 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procopenfiles.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <netdb.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/socket.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <netinet/in.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <arpa/inet.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "openfiles.h"
+#include "proctable.h"
+#include "util.h"
+#include "settings-keys.h"
+
+#ifndef NI_IDN
+#define NI_IDN 0
+#endif
+
+enum
+{
+    COL_FD,
+    COL_TYPE,
+    COL_OBJECT,
+    COL_OPENFILE_STRUCT,
+    NUM_OPENFILES_COL
+};
+
+
+static const char*
+get_type_name(enum glibtop_file_type t)
+{
+    switch(t)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        return _("file");
+    case GLIBTOP_FILE_TYPE_PIPE:
+        return _("pipe");
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+        return _("IPv6 network connection");
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        return _("IPv4 network connection");
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        return _("local socket");
+    default:
+        return _("unknown type");
+    }
+}
+
+
+
+static char *
+friendlier_hostname(const char *addr_str, int port)
+{
+    struct addrinfo hints = { };
+    struct addrinfo *res = NULL;
+    char hostname[NI_MAXHOST];
+    char service[NI_MAXSERV];
+    char port_str[6];
+
+    if (!addr_str[0]) return g_strdup("");
+
+    snprintf(port_str, sizeof port_str, "%d", port);
+
+    hints.ai_family = AF_UNSPEC;
+    hints.ai_socktype = SOCK_STREAM;
+
+    if (getaddrinfo(addr_str, port_str, &hints, &res))
+        goto failsafe;
+
+    if (getnameinfo(res->ai_addr, res->ai_addrlen, hostname,<--- Null pointer dereference
+            sizeof hostname, service, sizeof service, NI_IDN))
+        goto failsafe;
+
+    if (res) freeaddrinfo(res);<--- Assuming that condition 'res' is not redundant
+        return g_strdup_printf("%s, TCP port %d (%s)", hostname, port, service);
+
+  failsafe:
+    if (res) freeaddrinfo(res);
+    return g_strdup_printf("%s, TCP port %d", addr_str, port);
+}
+
+
+
+static void
+add_new_files (gpointer key, gpointer value, gpointer data)
+{
+    glibtop_open_files_entry *openfiles = static_cast<glibtop_open_files_entry*>(value);
+
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreeIter row;
+
+    char *object;
+
+    switch(openfiles->type)
+    {
+    case GLIBTOP_FILE_TYPE_FILE:
+        object = g_strdup(openfiles->info.file.name);
+        break;
+
+    case GLIBTOP_FILE_TYPE_INET6SOCKET:
+    case GLIBTOP_FILE_TYPE_INETSOCKET:
+        object = friendlier_hostname(openfiles->info.sock.dest_host,
+                         openfiles->info.sock.dest_port);
+        break;
+
+    case GLIBTOP_FILE_TYPE_LOCALSOCKET:
+        object = g_strdup(openfiles->info.localsock.name);
+        break;
+
+    default:
+        object = g_strdup("");
+    }
+
+    gtk_list_store_insert (GTK_LIST_STORE (model), &row, 0);
+    gtk_list_store_set (GTK_LIST_STORE (model), &row,
+                        COL_FD, openfiles->fd,
+                        COL_TYPE, get_type_name(static_cast<glibtop_file_type>(openfiles->type)),
+                        COL_OBJECT, object,
+#if GLIB_CHECK_VERSION (2, 68, 0)
+                        COL_OPENFILE_STRUCT, g_memdup2(openfiles, sizeof(*openfiles)),
+#else
+                        COL_OPENFILE_STRUCT, g_memdup(openfiles, sizeof(*openfiles)),
+#endif
+                        -1);
+
+    g_free(object);
+}
+
+static GList *old_maps = NULL;
+
+static gboolean
+classify_openfiles (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+    GHashTable *new_maps = static_cast<GHashTable*>(data);
+    GtkTreeIter *old_iter;
+    glibtop_open_files_entry *openfiles;<--- Variable 'openfiles' can be declared as pointer to const
+    gchar *old_name;
+
+    gtk_tree_model_get (model, iter, 1, &old_name, -1);
+
+    openfiles = static_cast<glibtop_open_files_entry*>(g_hash_table_lookup (new_maps, old_name));
+    if (openfiles) {
+        g_hash_table_remove (new_maps, old_name);
+        g_free (old_name);
+        return FALSE;
+
+    }
+
+    old_iter = gtk_tree_iter_copy (iter);
+    old_maps = g_list_append (old_maps, old_iter);
+    g_free (old_name);
+    return FALSE;
+
+}
+
+
+static gboolean
+compare_open_files(gconstpointer a, gconstpointer b)
+{
+    const glibtop_open_files_entry *o1 = static_cast<const glibtop_open_files_entry *>(a);
+    const glibtop_open_files_entry *o2 = static_cast<const glibtop_open_files_entry *>(b);
+
+    /* Falta manejar los diferentes tipos! */
+    return (o1->fd == o2->fd) && (o1->type == o2->type); /* XXX! */
+}
+
+
+static void
+update_openfiles_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+    GtkTreeModel *model;
+    glibtop_open_files_entry *openfiles;<--- Shadowed declaration
+    glibtop_proc_open_files procmap;
+    GHashTable *new_maps;
+    guint i;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    if (!info)
+        return;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    openfiles = glibtop_get_proc_open_files (&procmap, info->pid);
+
+    if (!openfiles)
+        return;
+
+    new_maps = static_cast<GHashTable *>(g_hash_table_new_full (g_str_hash, compare_open_files,
+                                                                NULL, NULL));
+    for (i=0; i < procmap.number; i++)
+        g_hash_table_insert (new_maps, openfiles + i, openfiles + i);
+
+    gtk_tree_model_foreach (model, classify_openfiles, new_maps);
+
+    g_hash_table_foreach (new_maps, add_new_files, model);
+
+    while (old_maps) {
+        GtkTreeIter *iter = static_cast<GtkTreeIter*>(old_maps->data);
+        glibtop_open_files_entry *openfiles = NULL;<--- Shadow variable
+
+        gtk_tree_model_get (model, iter,
+                            COL_OPENFILE_STRUCT, &openfiles,
+                            -1);
+
+        gtk_list_store_remove (GTK_LIST_STORE (model), iter);
+        gtk_tree_iter_free (iter);
+        g_free (openfiles);
+
+        old_maps = g_list_next (old_maps);
+
+    }
+
+    g_hash_table_destroy (new_maps);
+    g_free (openfiles);
+}
+
+static void
+close_openfiles_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GSettings *settings;
+    guint timer;
+
+    settings = static_cast<GSettings*>(g_object_get_data (G_OBJECT (tree), "settings"));
+    procman_save_tree_state (settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    return ;
+}
+
+
+static GtkWidget *
+create_openfiles_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    const gchar * const titles[] = {
+        /* Translators: "FD" here means "File Descriptor". Please use
+           a very short translation if possible, and at most
+           2-3 characters for it to be able to fit in the UI. */
+        N_("FD"),
+        N_("Type"),
+        N_("Object")
+    };
+
+    model = gtk_list_store_new (NUM_OPENFILES_COL,
+                                G_TYPE_INT,        /* FD */
+                                G_TYPE_STRING,    /* Type */
+                                G_TYPE_STRING,    /* Object */
+                                G_TYPE_POINTER    /* open_files_entry */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_OPENFILES_COL-1; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        switch (i) {
+        case COL_FD:
+            g_object_set(cell, "xalign", 1.0f, NULL);
+            break;
+        }
+
+        column = gtk_tree_view_column_new_with_attributes (_(titles[i]),
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_sort_column_id (column, i);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    procman_get_tree_state (procdata->settings, tree, procman::settings::open_files_tree_prefix.c_str());
+
+    return tree;
+}
+
+
+static gboolean
+openfiles_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_openfiles_dialog (tree);
+
+    return TRUE;
+}
+
+
+static void
+create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *openfilesdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    openfilesdialog = gtk_dialog_new_with_buttons (_("Open Files"), NULL,
+                                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                   "gtk-close", GTK_RESPONSE_CLOSE,
+                                                   NULL);
+    gtk_window_set_resizable (GTK_WINDOW (openfilesdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (openfilesdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (openfilesdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (openfilesdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("_Files opened by process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                    GTK_POLICY_AUTOMATIC,
+                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_openfiles_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+    g_object_set_data (G_OBJECT (tree), "settings", procdata->settings);
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (openfilesdialog), "response",
+                      G_CALLBACK (close_openfiles_dialog), tree);
+
+    gtk_widget_show_all (openfilesdialog);
+
+    timer = g_timeout_add_seconds (5, openfiles_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_openfiles_dialog (tree);
+
+}
+
+
+void
+create_openfiles_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_openfiles_dialog,
+                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/29.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/29.html new file mode 100644 index 00000000..cf2ba1fb --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/29.html @@ -0,0 +1,271 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
#ifndef H_PROCMAN_SETTINGS_KEYS_1177430397
+#define H_PROCMAN_SETTINGS_KEYS_1177430397
+
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+namespace procman
+{
+    namespace settings
+    {
+        extern const std::string root;
+        extern const std::string solaris_mode;
+        extern const std::string open_files_tree_prefix;
+        extern const std::string network_in_bits;
+    }
+}
+
+#endif //  H_PROCMAN_SETTINGS_KEYS_1177430397
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/3.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/3.html new file mode 100644 index 00000000..e4482baf --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/3.html @@ -0,0 +1,395 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
/* Procman - callbacks
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef _PROCMAN_CALLBACKS_H_
+#define _PROCMAN_CALLBACKS_H_
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+#include "gsm_color_button.h"
+
+void            cb_show_memory_maps (GtkAction *action, gpointer data);
+void            cb_show_open_files (GtkAction *action, gpointer data);
+void            cb_show_process_properties (GtkAction *action, gpointer data);
+void            cb_show_lsof(GtkAction *action, gpointer data);
+void            cb_renice (GtkAction *action, GtkRadioAction *current, gpointer data);
+void            cb_end_process (GtkAction *action, gpointer data);
+void            cb_kill_process (GtkAction *action, gpointer data);
+void            cb_edit_preferences (GtkAction *action, gpointer data);
+
+void            cb_help_contents (GtkAction *action, gpointer data);
+void            cb_about (GtkAction *action, gpointer data);
+
+void            cb_app_exit (GtkAction *action, gpointer data);
+gboolean        cb_app_delete (GtkWidget *window, GdkEventAny *event, gpointer data);
+
+void            cb_end_process_button_pressed (GtkButton *button, gpointer data);
+void            cb_logout (GtkButton *button, gpointer data);
+
+void            cb_info_button_pressed (GtkButton *button, gpointer user_data);
+
+void            cb_cpu_color_changed (GSMColorButton *widget, gpointer user_data);
+void            cb_mem_color_changed (GSMColorButton *widget, gpointer user_data);
+void            cb_swap_color_changed (GSMColorButton *widget, gpointer user_data);
+void            cb_net_in_color_changed (GSMColorButton *widget, gpointer user_data);
+void            cb_net_out_color_changed (GSMColorButton *widget, gpointer user_data);
+
+void            cb_row_selected (GtkTreeSelection *selection, gpointer data);
+
+gboolean        cb_tree_popup_menu (GtkWidget *widget, gpointer data);
+gboolean        cb_tree_button_pressed (GtkWidget *widget, GdkEventButton *event,
+                                        gpointer data);
+
+void            cb_change_current_page (GtkNotebook *nb,
+                                        gint num, gpointer data);
+void            cb_switch_page (GtkNotebook *nb, GtkWidget *page,
+                                gint num, gpointer data);
+
+gint            cb_update_disks (gpointer data);
+gint            cb_user_refresh (GtkAction* action, gpointer data);
+gint            cb_timeout (gpointer data);
+
+void            cb_radio_processes(GtkAction *action,
+                                   GtkRadioAction *current,
+                                   gpointer data);
+
+void            cb_kill_sigstop(GtkAction *action,
+                                gpointer data);
+
+void            cb_kill_sigcont(GtkAction *action,
+                                gpointer data);
+
+#endif /* _PROCMAN_CALLBACKS_H_ */
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/30.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/30.html new file mode 100644 index 00000000..b8468668 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/30.html @@ -0,0 +1,899 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef HAVE_WNCK
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <dirent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk-pixbuf/gdk-pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procstate.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/error.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/file.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/miscutils.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <iostream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <vector><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "prettytable.h"
+#include "defaulttable.h"
+#include "proctable.h"
+#include "util.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+namespace
+{
+  const unsigned APP_ICON_SIZE = 16;
+}
+
+
+PrettyTable::PrettyTable()
+{
+#ifdef HAVE_WNCK
+#ifdef GDK_WINDOWING_X11
+  if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+      WnckScreen* screen = wnck_screen_get_default();
+      g_signal_connect(G_OBJECT(screen), "application_opened",
+		       G_CALLBACK(PrettyTable::on_application_opened), this);
+      g_signal_connect(G_OBJECT(screen), "application_closed",
+	               G_CALLBACK(PrettyTable::on_application_closed), this);
+  }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    // init GIO apps cache
+    std::vector<std::string> dirs = Glib::get_system_data_dirs();
+    for (std::vector<std::string>::iterator it = dirs.begin(); it != dirs.end(); ++it) {
+        std::string path = (*it).append("/applications");
+        Glib::RefPtr<Gio::File> file = Gio::File::create_for_path(path);
+        Glib::RefPtr<Gio::FileMonitor> monitor = file->monitor_directory();
+        monitor->set_rate_limit(1000); // 1 second
+
+        monitor->signal_changed().connect(sigc::mem_fun(this, &PrettyTable::file_monitor_event));
+        monitors[path] = monitor;
+    }
+
+    this->init_gio_app_cache();
+}
+
+
+PrettyTable::~PrettyTable()
+{
+}
+
+#ifdef HAVE_WNCK
+void
+PrettyTable::on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data)
+{
+    PrettyTable * const that = static_cast<PrettyTable*>(data);
+    FILE *f;
+
+    pid_t pid = wnck_application_get_pid(app);
+
+    if (pid == 0)
+        return;
+
+    const char* icon_name = wnck_application_get_icon_name(app);
+
+
+    Glib::RefPtr<Gdk::Pixbuf> icon;
+
+    // Make sure that icon_name is a valid symlink before loading.
+    f = fopen (icon_name, "r");
+    if (f != NULL) {
+        fclose (f);
+        icon = that->theme->load_icon(icon_name, APP_ICON_SIZE);
+    }
+
+    if (not icon) {
+        icon = Glib::wrap(wnck_application_get_icon(app), /* take_copy */ true);
+        icon = icon->scale_simple(APP_ICON_SIZE, APP_ICON_SIZE, Gdk::INTERP_HYPER);
+    }
+
+    if (not icon)
+        return;
+
+    that->register_application(pid, icon);
+}
+
+void
+PrettyTable::register_application(pid_t pid, Glib::RefPtr<Gdk::Pixbuf> icon)
+{
+  /* If process already exists then set the icon. Otherwise put into hash
+  ** table to be added later */
+  if (ProcInfo* info = ProcInfo::find(pid))
+    {
+      info->set_icon(icon);
+      // move the ref to the map
+      this->apps[pid] = icon;
+      procman_debug("MATEWNCK OK for %u", unsigned(pid));
+    }
+}
+
+void
+PrettyTable::on_application_closed(WnckScreen* screen, WnckApplication* app, gpointer data)
+{
+    pid_t pid = wnck_application_get_pid(app);
+
+    if (pid == 0)
+        return;
+
+    static_cast<PrettyTable*>(data)->unregister_application(pid);
+}
+
+void
+PrettyTable::unregister_application(pid_t pid)
+{
+    IconsForPID::iterator it(this->apps.find(pid));
+
+    if (it != this->apps.end())
+        this->apps.erase(it);
+}
+#endif // HAVE_WNCK
+
+void PrettyTable::init_gio_app_cache ()
+{
+    this->gio_apps.clear();
+
+    Glib::ListHandle<Glib::RefPtr<Gio::AppInfo>> registered_apps = Gio::AppInfo::get_all();
+    for (Glib::ListHandle<Glib::RefPtr<Gio::AppInfo>>::const_iterator it = registered_apps.begin(); it != registered_apps.end(); ++it) {
+        Glib::RefPtr<Gio::AppInfo> app = *it;
+        std::string executable = app->get_executable();
+        if (executable != "sh" && executable != "env")
+            this->gio_apps[executable] = app;
+    }
+}
+
+void PrettyTable::file_monitor_event(Glib::RefPtr<Gio::File>,
+                                     Glib::RefPtr<Gio::File>,
+                                     Gio::FileMonitorEvent)
+{
+  this->init_gio_app_cache();
+}
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_theme(const ProcInfo &info)
+{
+    return this->theme->load_icon(info.name, APP_ICON_SIZE);
+}
+
+
+bool PrettyTable::get_default_icon_name(const string &cmd, string &name)
+{
+    for (size_t i = 0; i != G_N_ELEMENTS(default_table); ++i) {
+        if (default_table[i].command->match(cmd)) {
+            name = default_table[i].icon;
+            return true;
+        }
+    }
+
+    return false;
+}
+
+/*
+  Try to get an icon from the default_table
+  If it's not in defaults, try to load it.
+  If there is no default for a command, store NULL in defaults
+  so we don't have to lookup again.
+*/
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_default(const ProcInfo &info)
+{
+    Glib::RefPtr<Gdk::Pixbuf> pix;
+    string name;
+
+    if (this->get_default_icon_name(info.name, name)) {
+        IconCache::iterator it(this->defaults.find(name));
+
+        if (it == this->defaults.end()) {
+            pix = this->theme->load_icon(name, APP_ICON_SIZE);
+            if (pix)
+                this->defaults[name] = pix;
+            } else
+                pix = it->second;
+    }
+
+    return pix;
+}
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_gio(const ProcInfo &info)
+{
+    gchar **cmdline = g_strsplit(info.name, " ", 2);
+    const gchar *executable = cmdline[0];
+    Glib::RefPtr<Gdk::Pixbuf> icon;
+
+    if (executable) {
+        Glib::RefPtr<Gio::AppInfo> app = this->gio_apps[executable];
+        Glib::RefPtr<Gio::Icon> gicon;
+
+        if (app)
+          gicon = app->get_icon();
+
+        if (gicon)
+          icon = this->theme->load_gicon(gicon, APP_ICON_SIZE, Gtk::ICON_LOOKUP_USE_BUILTIN | Gtk::ICON_LOOKUP_FORCE_SIZE);
+    }
+
+    g_strfreev(cmdline);
+    return icon;
+}
+
+#ifdef HAVE_WNCK
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_wnck(const ProcInfo &info)
+{
+    Glib::RefPtr<Gdk::Pixbuf> icon;
+
+    IconsForPID::iterator it(this->apps.find(info.pid));
+
+    if (it != this->apps.end())
+        icon = it->second;
+
+    return icon;
+}
+#endif
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_from_name(const ProcInfo &info)
+{
+    return this->theme->load_icon(info.name, APP_ICON_SIZE);
+}
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_dummy(const ProcInfo &)
+{
+    return this->theme->load_icon("application-x-executable", APP_ICON_SIZE);
+}
+
+
+namespace
+{
+    bool has_kthreadd()
+    {
+        glibtop_proc_state buf;
+        glibtop_get_proc_state(&buf, 2);
+
+        return buf.cmd == string("kthreadd");
+    }
+
+    // @pre: has_kthreadd
+    bool is_kthread(const ProcInfo &info)
+    {
+        return info.pid == 2 or info.ppid == 2;
+    }
+}
+
+
+Glib::RefPtr<Gdk::Pixbuf>
+PrettyTable::get_icon_for_kernel(const ProcInfo &info)
+{
+    if (is_kthread(info))
+        return this->theme->load_icon("applications-system", APP_ICON_SIZE);
+
+    return Glib::RefPtr<Gdk::Pixbuf>();
+}
+
+
+
+void
+PrettyTable::set_icon(ProcInfo &info)
+{
+    typedef Glib::RefPtr<Gdk::Pixbuf>
+        (PrettyTable::*Getter)(const ProcInfo &);
+
+    static std::vector<Getter> getters;
+
+    if (getters.empty())
+    {
+        getters.push_back(&PrettyTable::get_icon_from_gio);
+#ifdef HAVE_WNCK
+        getters.push_back(&PrettyTable::get_icon_from_wnck);
+#endif
+        getters.push_back(&PrettyTable::get_icon_from_theme);
+        getters.push_back(&PrettyTable::get_icon_from_default);
+        getters.push_back(&PrettyTable::get_icon_from_name);
+        if (has_kthreadd())
+        {
+            procman_debug("kthreadd is running with PID 2");
+            getters.push_back(&PrettyTable::get_icon_for_kernel);
+        }
+        getters.push_back(&PrettyTable::get_icon_dummy);
+    }
+
+    Glib::RefPtr<Gdk::Pixbuf> icon;
+
+    for (size_t i = 0; not icon and i < getters.size(); ++i) {
+        try {
+            icon = (this->*getters[i])(info);
+        }
+        catch (std::exception& e) {
+            g_warning("Failed to load icon for %s(%u) : %s", info.name, info.pid, e.what());
+            continue;
+        }
+        catch (Glib::Exception& e) {
+            g_warning("Failed to load icon for %s(%u) : %s", info.name, info.pid, e.what().c_str());
+            continue;
+        }
+    }
+
+    info.set_icon(icon);
+}
+
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/31.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/31.html new file mode 100644 index 00000000..06386dd4 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/31.html @@ -0,0 +1,331 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
#ifndef _PROCMAN_DEFAULTTABLE_H_
+#define _PROCMAN_DEFAULTTABLE_H_
+
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/refptr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/regex.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+/* This file contains prettynames and icons for well-known applications, that by default has no .desktop entry */
+
+struct PrettyTableItem
+{
+    Glib::RefPtr<Glib::Regex> command;
+    std::string icon;
+
+PrettyTableItem(const std::string& a_command, const std::string& a_icon)
+: command(Glib::Regex::create("^(" + a_command + ")$")),
+        icon(a_icon)
+    { }
+};
+
+#define ITEM PrettyTableItem
+
+static const PrettyTableItem default_table[] = {
+    ITEM("(ba|z|tc|c|k)?sh", "utilities-terminal"),
+    ITEM("(k|sys|u)logd|logger", "internet-news-reader"),
+    ITEM("X(org)?", "display"),
+    ITEM("apache2?|httpd|lighttpd", "internet-web-browser"),
+    ITEM("atd|cron|CRON|ntpd", "date"),
+    ITEM("cupsd|lpd?", "printer"),
+    ITEM("cvsd|mtn|git|svn", "file-manager"),
+    ITEM("evolution.*", "internet-mail"),
+    ITEM("famd|gam_server", "file-manager"),
+    ITEM("getty", "input-keyboard"),
+    ITEM("gdb|((gcc|g\\+\\+)(-.*)?)|ar|ld|make", "applications-development"),
+    ITEM("marco|metacity", "gnome-window-manager"),
+    ITEM("sendmail|exim\\d?", "internet-mail"),
+    ITEM("squid", "proxy"),
+    ITEM("ssh(d|-agent)", "ssh-askpass-gnome"),
+    ITEM("top|vmstat", "system-monitor"),
+    ITEM("vim?", "vim"),
+    ITEM("x?inetd", "internet-web-browser"),
+    ITEM("vino.*", "gnome-remote-desktop")
+};
+
+#undef ITEM
+
+#endif /* _PROCMAN_DEFAULTTABLE_H_ */
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/32.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/32.html new file mode 100644 index 00000000..a0a12dda --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/32.html @@ -0,0 +1,621 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
/* Procman process actions
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/resource.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procactions.h"
+#include "procman.h"
+#include "proctable.h"
+#include "procdialogs.h"
+#include "callbacks.h"
+
+
+static void
+renice_single_process (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+    const struct ReniceArgs * const args = static_cast<ReniceArgs*>(data);
+
+    ProcInfo *info = NULL;
+    gint error;
+    int saved_errno;
+    gchar *error_msg;
+    GtkWidget *dialog;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+    if (info->nice == args->nice_value)
+        return;
+    error = setpriority (PRIO_PROCESS, info->pid, args->nice_value);
+
+    /* success */
+    if(error != -1) return;
+
+    saved_errno = errno;
+
+    /* need to be root */
+    if(errno == EPERM || errno == EACCES) {
+        gboolean success;
+
+        success = procdialog_create_root_password_dialog (
+            PROCMAN_ACTION_RENICE, args->procdata, info->pid,
+            args->nice_value);
+
+        if(success) return;
+
+        if(errno) {
+            saved_errno = errno;
+        }
+    }
+
+    /* failed */
+    error_msg = g_strdup_printf (
+        _("Cannot change the priority of process with PID %d to %d.\n"
+          "%s"),
+        info->pid, args->nice_value, g_strerror(saved_errno));
+
+    dialog = gtk_message_dialog_new (
+        NULL,
+        GTK_DIALOG_DESTROY_WITH_PARENT,
+        GTK_MESSAGE_ERROR,
+        GTK_BUTTONS_OK,
+        "%s", error_msg);
+
+    gtk_dialog_run (GTK_DIALOG (dialog));
+    gtk_widget_destroy (dialog);
+    g_free (error_msg);
+}
+
+
+void
+renice (ProcData *procdata, int nice)
+{
+    struct ReniceArgs args = { procdata, nice };
+
+    /* EEEK - ugly hack - make sure the table is not updated as a crash
+    ** occurs if you first kill a process and the tree node is removed while
+    ** still in the foreach function
+    */
+    g_source_remove(procdata->timeout);
+
+    gtk_tree_selection_selected_foreach(procdata->selection, renice_single_process,
+                                        &args);
+
+    procdata->timeout = g_timeout_add(procdata->config.update_interval,
+                                      cb_timeout,
+                                      procdata);
+
+    proctable_update (procdata);
+}
+
+
+
+
+static void
+kill_single_process (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
+{
+    const struct KillArgs * const args = static_cast<KillArgs*>(data);
+    char *error_msg;
+    ProcInfo *info;
+    int error;
+    int saved_errno;
+    GtkWidget *dialog;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    error = kill (info->pid, args->signal);
+
+    /* success */
+    if(error != -1) return;
+
+    saved_errno = errno;
+
+    /* need to be root */
+    if(errno == EPERM) {
+        gboolean success;
+
+        success = procdialog_create_root_password_dialog (
+            PROCMAN_ACTION_KILL, args->procdata, info->pid,
+            args->signal);
+
+        if(success) return;
+
+        if(errno) {
+            saved_errno = errno;
+        }
+    }
+
+    /* failed */
+    error_msg = g_strdup_printf (
+        _("Cannot kill process with PID %d with signal %d.\n"
+          "%s"),
+        info->pid, args->signal, g_strerror(saved_errno));
+
+    dialog = gtk_message_dialog_new (
+        NULL,
+        GTK_DIALOG_DESTROY_WITH_PARENT,
+        GTK_MESSAGE_ERROR,
+        GTK_BUTTONS_OK,
+        "%s", error_msg);
+
+    gtk_dialog_run (GTK_DIALOG (dialog));
+    gtk_widget_destroy (dialog);
+    g_free (error_msg);
+}
+
+
+void
+kill_process (ProcData *procdata, int sig)
+{
+    struct KillArgs args = { procdata, sig };
+
+    /* EEEK - ugly hack - make sure the table is not updated as a crash
+    ** occurs if you first kill a process and the tree node is removed while
+    ** still in the foreach function
+    */
+    g_source_remove (procdata->timeout);
+
+    gtk_tree_selection_selected_foreach (procdata->selection, kill_single_process,
+                                         &args);
+
+    procdata->timeout = g_timeout_add (procdata->config.update_interval,
+                                       cb_timeout,
+                                       procdata);
+    proctable_update (procdata);
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/33.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/33.html new file mode 100644 index 00000000..d99de9c7 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/33.html @@ -0,0 +1,1417 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
/* Procman - dialogs
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procdialogs.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "procactions.h"
+#include "util.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "procman_gksu.h"
+#include "procman_pkexec.h"
+#include "cgroups.h"
+
+#define GET_WIDGET(x) GTK_WIDGET(gtk_builder_get_object(builder, x))
+
+static GtkWidget *renice_dialog = NULL;
+static GtkWidget *prefs_dialog = NULL;
+static gint new_nice_value = 0;
+
+
+static void
+kill_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    struct KillArgs *kargs = static_cast<KillArgs*>(data);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+
+    if (id == GTK_RESPONSE_OK)
+        kill_process (kargs->procdata, kargs->signal);
+
+    g_free (kargs);
+}
+
+void
+procdialog_create_kill_dialog (ProcData *procdata, int signal)
+{
+    GtkWidget *kill_alert_dialog;
+    gchar *primary, *secondary, *button_text;
+    struct KillArgs *kargs;
+
+    kargs = g_new(KillArgs, 1);
+    kargs->procdata = procdata;
+    kargs->signal = signal;
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if ( selected_count == 1 ) {
+        ProcInfo *selected_process = NULL;
+        // get the last selected row
+        gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &selected_process);
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing single process*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        } else {
+            /*xgettext: primary alert message for ending single process*/
+            primary = g_strdup_printf (_("Are you sure you want to end the selected process “%s†(PID: %u)?"),
+                                       selected_process->name,
+                                       selected_process->pid);
+        }
+    } else {
+        if (signal == SIGKILL) {
+            /*xgettext: primary alert message for killing multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to kill the %d selected processes?"),
+                                       selected_count);
+        } else {
+            /*xgettext: primary alert message for ending multiple processes*/
+            primary = g_strdup_printf (_("Are you sure you want to end the %d selected processes?"),
+                                       selected_count);
+
+        }
+    }
+
+    if ( signal == SIGKILL ) {
+        /*xgettext: secondary alert message*/
+        secondary = _("Killing a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be killed.");
+        button_text = ngettext("_Kill Process", "_Kill Processes", selected_count);
+    } else {
+        /*xgettext: secondary alert message*/
+        secondary = _("Ending a process may destroy data, break the "
+                    "session or introduce a security risk. "
+                    "Only unresponsive processes should be ended.");
+        button_text = ngettext("_End Process", "_End Processes", selected_count);
+    }
+
+    kill_alert_dialog = gtk_message_dialog_new (GTK_WINDOW (procdata->app),
+                                                static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
+                                                GTK_MESSAGE_WARNING,
+                                                GTK_BUTTONS_NONE,
+                                                "%s",
+                                                primary);
+    g_free (primary);
+
+    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (kill_alert_dialog),
+                                              "%s",
+                                              secondary);
+
+    gtk_dialog_add_buttons (GTK_DIALOG (kill_alert_dialog),
+                            "gtk-cancel", GTK_RESPONSE_CANCEL,
+                            button_text, GTK_RESPONSE_OK,
+                            NULL);
+
+    gtk_dialog_set_default_response (GTK_DIALOG (kill_alert_dialog),
+                                     GTK_RESPONSE_CANCEL);
+
+    g_signal_connect (G_OBJECT (kill_alert_dialog), "response",
+                      G_CALLBACK (kill_dialog_button_pressed), kargs);
+
+    gtk_widget_show_all (kill_alert_dialog);
+}
+
+static void
+renice_scale_changed (GtkAdjustment *adj, gpointer data)
+{
+    GtkWidget *label = GTK_WIDGET (data);
+
+    new_nice_value = int(gtk_adjustment_get_value (adj));
+    gchar* text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (new_nice_value));
+    gtk_label_set_text (GTK_LABEL (label), text);
+    g_free(text);
+
+}
+
+static void
+renice_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (id == 100) {
+        if (new_nice_value == -100)
+            return;
+        renice(procdata, new_nice_value);
+    }
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+    renice_dialog = NULL;
+}
+
+void
+procdialog_create_renice_dialog (ProcData *procdata)
+{
+    ProcInfo  *info;
+    GtkWidget *dialog = NULL;
+    GtkWidget *dialog_vbox;
+    GtkWidget *vbox;
+    GtkWidget *label;
+    GtkWidget *priority_label;
+    GtkWidget *grid;
+    GtkAdjustment *renice_adj;
+    GtkWidget *hscale;
+    GtkWidget *button;
+    GtkWidget *icon;
+    gchar     *text;
+    gchar     *dialog_title;
+
+    if (renice_dialog)
+        return;
+
+    gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected,
+                                         &info);
+    gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection);
+
+    if (!info)
+        return;
+
+    if ( selected_count == 1 ) {
+        dialog_title = g_strdup_printf (_("Change Priority of Process “%s†(PID: %u)"),
+                                        info->name, info->pid);
+    } else {
+        dialog_title = g_strdup_printf (_("Change Priority of %d Selected Processes"),
+                                        selected_count);
+    }
+
+    dialog = gtk_dialog_new_with_buttons (dialog_title, NULL,
+                                          GTK_DIALOG_DESTROY_WITH_PARENT,
+                                          "gtk-cancel", GTK_RESPONSE_CANCEL,
+                                          NULL);
+    g_free (dialog_title);
+
+    renice_dialog = dialog;
+    gtk_window_set_resizable (GTK_WINDOW (renice_dialog), FALSE);
+    gtk_container_set_border_width (GTK_CONTAINER (renice_dialog), 5);
+
+    button = gtk_button_new_with_mnemonic (_("Change _Priority"));
+    gtk_widget_set_can_default (button, TRUE);
+
+    icon = gtk_image_new_from_icon_name ("gtk-apply", GTK_ICON_SIZE_BUTTON);
+    gtk_button_set_image (GTK_BUTTON (button), icon);
+
+    gtk_dialog_add_action_widget (GTK_DIALOG (renice_dialog), button, 100);
+    gtk_dialog_set_default_response (GTK_DIALOG (renice_dialog), 100);
+    new_nice_value = -100;
+
+    dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+    gtk_box_set_spacing (GTK_BOX (dialog_vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+
+    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), vbox, TRUE, TRUE, 0);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+
+    grid = gtk_grid_new ();
+    gtk_grid_set_column_spacing (GTK_GRID(grid), 12);
+    gtk_grid_set_row_spacing (GTK_GRID(grid), 6);
+    gtk_box_pack_start (GTK_BOX (vbox), grid, TRUE, TRUE, 0);
+
+    label = gtk_label_new_with_mnemonic (_("_Nice value:"));
+    gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 2);
+
+    renice_adj = gtk_adjustment_new (info->nice, RENICE_VAL_MIN, RENICE_VAL_MAX, 1, 1, 0);
+    new_nice_value = 0;
+    hscale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, renice_adj);
+    gtk_label_set_mnemonic_widget (GTK_LABEL (label), hscale);
+    gtk_scale_set_digits (GTK_SCALE (hscale), 0);
+    gtk_widget_set_hexpand (hscale, TRUE);
+    gtk_grid_attach (GTK_GRID (grid), hscale, 1, 0, 1, 1);
+    text = g_strdup_printf(_("(%s Priority)"), procman::get_nice_level (info->nice));
+    priority_label = gtk_label_new (text);
+    gtk_grid_attach (GTK_GRID (grid), priority_label, 1, 1, 1, 1);
+    g_free(text);
+
+    text = g_strconcat("<small><i><b>", _("Note:"), "</b> ",
+        _("The priority of a process is given by its nice value. A lower nice value corresponds to a higher priority."),
+        "</i></small>", NULL);
+    label = gtk_label_new (_(text));
+    gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+    g_free (text);
+
+    g_signal_connect (G_OBJECT (dialog), "response",
+                      G_CALLBACK (renice_dialog_button_pressed), procdata);
+    g_signal_connect (G_OBJECT (renice_adj), "value_changed",
+                      G_CALLBACK (renice_scale_changed), priority_label);
+
+    gtk_widget_show_all (dialog);
+
+
+}
+
+static void
+prefs_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data)
+{
+    if (id == GTK_RESPONSE_HELP)
+    {
+        GError* error = 0;
+        if (!g_app_info_launch_default_for_uri("help:mate-system-monitor/mate-system-monitor-prefs", NULL, &error))
+        {
+            g_warning("Could not display preferences help : %s", error->message);
+            g_error_free(error);
+        }
+    }
+    else
+    {
+        gtk_widget_destroy (GTK_WIDGET (dialog));
+        prefs_dialog = NULL;
+    }
+}
+
+
+class SpinButtonUpdater
+{
+public:
+    SpinButtonUpdater(const string& key)
+        : key(key)
+    { }
+
+    static gboolean callback(GtkWidget *widget, GdkEventFocus *event, gpointer data)
+    {
+        SpinButtonUpdater* updater = static_cast<SpinButtonUpdater*>(data);
+        gtk_spin_button_update(GTK_SPIN_BUTTON(widget));
+        updater->update(GTK_SPIN_BUTTON(widget));
+        return FALSE;
+    }
+
+private:
+
+    void update(GtkSpinButton* spin)
+    {
+        int new_value = int(1000 * gtk_spin_button_get_value(spin));
+        g_settings_set_int(ProcData::get_instance()->settings,
+                           this->key.c_str(), new_value);
+
+        procman_debug("set %s to %d", this->key.c_str(), new_value);
+    }
+
+    const string key;
+};
+
+
+static void
+field_toggled (const gchar *child_schema, GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    GtkTreeModel *model = static_cast<GtkTreeModel*>(data);
+    GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+    GtkTreeIter iter;
+    GtkTreeViewColumn *column;
+    gboolean toggled;
+    GSettings *settings = g_settings_get_child (ProcData::get_instance()->settings, child_schema);
+    gchar *key;
+    int id;
+
+    if (!path)
+        return;
+
+    gtk_tree_model_get_iter (model, &iter, path);
+
+    gtk_tree_model_get (model, &iter, 2, &column, -1);
+    toggled = gtk_cell_renderer_toggle_get_active (cell);
+
+    gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, !toggled, -1);
+    gtk_tree_view_column_set_visible (column, !toggled);
+
+    id = gtk_tree_view_column_get_sort_column_id (column);
+
+    key = g_strdup_printf ("col-%d-visible", id);
+    g_settings_set_boolean (settings, key, !toggled);
+    g_free (key);
+
+    gtk_tree_path_free (path);
+}
+
+static void
+proc_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("proctree", cell, path_str, data);
+}
+
+static void
+disk_field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
+{
+    field_toggled ("disktreenew", cell, path_str, data);
+}
+
+static void
+create_field_page(GtkBuilder* builder, GtkWidget *tree, const gchar *widgetname)
+{
+    GtkTreeView *treeview;
+    GList *it, *columns;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;<--- Shadowed declaration
+    GtkCellRenderer *cell;
+    gchar *full_widgetname;
+
+    full_widgetname = g_strdup_printf ("%s_columns", widgetname);
+    treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, full_widgetname));
+    g_free (full_widgetname);
+
+    model = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER);
+
+    gtk_tree_view_set_model (GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(model));
+    g_object_unref (G_OBJECT (model));
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_toggle_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "active", 0,
+                                         NULL);
+
+    if (g_strcmp0 (widgetname, "proctree") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (proc_field_toggled), model);
+    else if (g_strcmp0 (widgetname, "disktreenew") == 0)
+        g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (disk_field_toggled), model);
+
+    gtk_tree_view_column_set_clickable (column, TRUE);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    column = gtk_tree_view_column_new ();
+
+    cell = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell,
+                                         "text", 1,
+                                         NULL);
+
+    gtk_tree_view_column_set_title (column, "Not Shown");
+    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    for(it = columns; it; it = it->next)
+    {
+        GtkTreeViewColumn *column = static_cast<GtkTreeViewColumn*>(it->data);<--- Shadow variable
+        GtkTreeIter iter;
+        const gchar *title;
+        gboolean visible;
+        gint column_id;
+
+        title = gtk_tree_view_column_get_title (column);
+        if (!title)
+            title = _("Icon");
+
+        column_id = gtk_tree_view_column_get_sort_column_id(column);
+        if ((column_id == COL_CGROUP) && (!cgroups_enabled()))
+            continue;
+
+        if ((column_id == COL_UNIT ||
+             column_id == COL_SESSION ||
+             column_id == COL_SEAT ||
+             column_id == COL_OWNER)
+#ifdef HAVE_SYSTEMD
+            && !LOGIND_RUNNING()
+#endif
+                )
+            continue;
+
+        visible = gtk_tree_view_column_get_visible (column);
+
+        gtk_list_store_append (model, &iter);
+        gtk_list_store_set (model, &iter, 0, visible, 1, title, 2, column,-1);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procdialog_create_preferences_dialog (ProcData *procdata)
+{
+    typedef SpinButtonUpdater SBU;
+
+    static SBU interval_updater("update-interval");
+    static SBU graph_interval_updater("graph-update-interval");
+    static SBU disks_interval_updater("disks-interval");
+
+    GtkWidget *notebook;
+    GtkAdjustment *adjustment;
+    GtkWidget *spin_button;
+    GtkWidget *check_button;
+    GtkWidget *smooth_button;
+    GtkBuilder *builder;
+    gfloat update;
+
+    if (prefs_dialog)
+        return;
+
+    builder = gtk_builder_new_from_resource("/org/mate/mate-system-monitor/preferences.ui");
+
+    prefs_dialog = GET_WIDGET("preferences_dialog");
+    notebook = GET_WIDGET("notebook");
+    spin_button = GET_WIDGET("processes_interval_spinner");
+
+    update = (gfloat) procdata->config.update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0,
+                                   MIN_UPDATE_INTERVAL / 1000,
+                                   MAX_UPDATE_INTERVAL / 1000,
+                                   0.25,
+                                   1.0,
+                                   0);
+
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK (SBU::callback), &interval_updater);
+
+    smooth_button = GET_WIDGET("smooth_button");
+    g_settings_bind(procdata->settings, SmoothRefresh::KEY.c_str(), smooth_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    check_button = GET_WIDGET("check_button");
+    g_settings_bind(procdata->settings, "kill-dialog", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    GtkWidget *solaris_button = GET_WIDGET("solaris_button");
+    g_settings_bind(procdata->settings, procman::settings::solaris_mode.c_str(), solaris_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->tree, "proctree");
+
+    update = (gfloat) procdata->config.graph_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0, 0.25,
+                                                      100.0, 0.25, 1.0, 0);
+
+    spin_button = GET_WIDGET("resources_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &graph_interval_updater);
+
+    GtkWidget *bits_button = GET_WIDGET("bits_button");
+    g_settings_bind(procdata->settings, procman::settings::network_in_bits.c_str(), bits_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+
+    update = (gfloat) procdata->config.disks_update_interval;
+    adjustment = (GtkAdjustment *) gtk_adjustment_new (update / 1000.0, 1.0,
+                                                       100.0, 1.0, 1.0, 0);
+
+    spin_button = GET_WIDGET("devices_interval_spinner");
+    gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(spin_button), adjustment);
+    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
+                      G_CALLBACK(SBU::callback),
+                      &disks_interval_updater);
+
+    check_button = GET_WIDGET("all_devices_check");
+    g_settings_bind(procdata->settings, "show-all-fs", check_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+    create_field_page (builder, procdata->disk_list, "disktreenew");
+
+    gtk_widget_show_all (prefs_dialog);
+    g_signal_connect (G_OBJECT (prefs_dialog), "response",
+                       G_CALLBACK (prefs_dialog_button_pressed), procdata);
+
+    switch (procdata->config.current_tab) {
+    case PROCMAN_TAB_SYSINFO:
+    case PROCMAN_TAB_PROCESSES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
+        break;
+    case PROCMAN_TAB_RESOURCES:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 1);
+        break;
+    case PROCMAN_TAB_DISKS:
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 2);
+        break;
+    }
+
+    gtk_builder_connect_signals (builder, NULL);
+    g_object_unref (G_OBJECT (builder));
+}
+
+
+static char *
+procman_action_to_command(ProcmanActionType type,
+                          gint pid,
+                          gint extra_value)
+{
+    switch (type) {
+    case PROCMAN_ACTION_KILL:
+           return g_strdup_printf("kill -s %d %d", extra_value, pid);
+    case PROCMAN_ACTION_RENICE:
+        return g_strdup_printf("renice %d %d", extra_value, pid);
+    default:
+        g_assert_not_reached();
+    }
+}
+
+
+/*
+ * type determines whether if dialog is for killing process or renice.
+ * type == PROCMAN_ACTION_KILL,   extra_value -> signal to send
+ * type == PROCMAN_ACTION_RENICE, extra_value -> new priority.
+ */
+gboolean
+procdialog_create_root_password_dialog(ProcmanActionType type,
+                                       ProcData *procdata,
+                                       gint pid,
+                                       gint extra_value)
+{
+    char * command;
+    gboolean ret = FALSE;
+
+    command = procman_action_to_command(type, pid, extra_value);
+
+    procman_debug("Trying to run '%s' as root", command);
+
+    if (procman_has_pkexec())
+        ret = procman_pkexec_create_root_password_dialog(command);
+    else if (procman_has_gksu())
+        ret = procman_gksu_create_root_password_dialog(command);
+
+    g_free(command);
+    return ret;
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/34.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/34.html new file mode 100644 index 00000000..e345fe82 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/34.html @@ -0,0 +1,261 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
#ifndef H_MATE_SYSTEM_MONITOR_GKSU_H_1132171928
+#define H_MATE_SYSTEM_MONITOR_GKSU_H_1132171928
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+gboolean
+procman_gksu_create_root_password_dialog(const char * command);
+
+gboolean
+procman_has_gksu(void) G_GNUC_CONST;
+
+#endif /* H_MATE_SYSTEM_MONITOR_GKSU_H_1132171928 */
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/35.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/35.html new file mode 100644 index 00000000..bf9d9643 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/35.html @@ -0,0 +1,261 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
#ifndef _PROCMAN_PKEXEC_H_
+#define _PROCMAN_PKEXEC_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+gboolean
+procman_pkexec_create_root_password_dialog(const char *command);
+
+gboolean
+procman_has_pkexec(void) G_GNUC_CONST;
+
+#endif /* _PROCMAN_PKEXEC_H_ */
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/36.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/36.html new file mode 100644 index 00000000..05aae1d2 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/36.html @@ -0,0 +1,1109 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/close.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/sysinfo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman-app.h"
+#include "procman.h"
+#include "interface.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "load-graph.h"
+#include "settings-keys.h"
+#include "argv.h"
+#include "util.h"
+
+static void
+mount_changed(const Glib::RefPtr<Gio::Mount>&)
+{
+    cb_update_disks(ProcData::get_instance());
+}
+
+
+static void
+init_volume_monitor(ProcData *procdata)
+{
+    using namespace Gio;
+    using namespace Glib;
+
+    RefPtr<VolumeMonitor> monitor = VolumeMonitor::get();
+
+    monitor->signal_mount_added().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_changed().connect(sigc::ptr_fun(&mount_changed));
+    monitor->signal_mount_removed().connect(sigc::ptr_fun(&mount_changed));
+}
+
+static gboolean
+has_key (gchar **keys, const gchar *key)
+{
+    gchar **loop = keys;
+
+    while (*loop) {
+        if (!strcmp (*loop++, key))
+            return TRUE;
+    }
+
+    return FALSE;
+}
+
+static void
+tree_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_tree = g_settings_get_boolean(settings, key);
+
+    g_object_set(G_OBJECT(procdata->tree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+solaris_mode_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.solaris_mode = g_settings_get_boolean(settings, key);
+    proctable_update (procdata);
+}
+
+
+static void
+network_in_bits_changed_cb(GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.network_in_bits = g_settings_get_boolean(settings, key);
+    // force scale to be redrawn
+    procdata->net_graph->clear_background();
+}
+
+static void
+view_as_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    procdata->config.whose_process = g_settings_get_int (settings, key);
+    procdata->config.whose_process = CLAMP (procdata->config.whose_process, 0, 2);
+    proctable_clear_tree (procdata);
+    proctable_update (procdata);
+}
+
+static void
+warning_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "kill-dialog")) {
+        procdata->config.show_kill_warning = g_settings_get_boolean (settings, key);
+    }
+}
+
+static void
+timeouts_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+
+    if (g_str_equal (key, "update-interval")) {
+        procdata->config.update_interval = g_settings_get_int (settings, key);
+        procdata->config.update_interval =
+            MAX (procdata->config.update_interval, 1000);
+
+        procdata->smooth_refresh->reset();
+
+        if(procdata->timeout) {
+            g_source_remove (procdata->timeout);
+            procdata->timeout = g_timeout_add (procdata->config.update_interval,
+                                               cb_timeout,
+                                               procdata);
+        }
+    }
+    else if (g_str_equal (key, "graph-update-interval")){
+        procdata->config.graph_update_interval = g_settings_get_int (settings, key);
+        procdata->config.graph_update_interval =
+            MAX (procdata->config.graph_update_interval,
+                 250);
+        load_graph_change_speed(procdata->cpu_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->mem_graph,
+                                procdata->config.graph_update_interval);
+        load_graph_change_speed(procdata->net_graph,
+                                procdata->config.graph_update_interval);
+    }
+    else if (g_str_equal(key, "disks-interval")) {
+        procdata->config.disks_update_interval = g_settings_get_int (settings, key);
+        procdata->config.disks_update_interval =
+            MAX (procdata->config.disks_update_interval, 1000);
+
+        if(procdata->disk_timeout) {
+            g_source_remove (procdata->disk_timeout);
+            procdata->disk_timeout = \
+                g_timeout_add (procdata->config.disks_update_interval,
+                               cb_update_disks,
+                               procdata);
+        }
+    }
+    else {
+        g_assert_not_reached();
+    }
+}
+
+static void
+color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+    gchar *color = g_settings_get_string (settings, key);
+
+    if (g_str_has_prefix (key, "cpu-color")) {
+        for (int i = 0; i < procdata->config.num_cpus; i++) {
+            string cpu_key = make_string(g_strdup_printf("cpu-color%d", i));
+            if (cpu_key == key) {
+                gdk_rgba_parse (&procdata->config.cpu_color[i], color);
+                procdata->cpu_graph->colors.at(i) = procdata->config.cpu_color[i];
+                break;
+            }
+        }
+    }
+    else if (g_str_equal (key, "mem-color")) {
+        gdk_rgba_parse (&procdata->config.mem_color, color);
+        procdata->mem_graph->colors.at(0) = procdata->config.mem_color;
+    }
+    else if (g_str_equal (key, "swap-color")) {
+        gdk_rgba_parse (&procdata->config.swap_color, color);
+        procdata->mem_graph->colors.at(1) = procdata->config.swap_color;
+    }
+    else if (g_str_equal (key, "net-in-color")) {
+        gdk_rgba_parse (&procdata->config.net_in_color, color);
+        procdata->net_graph->colors.at(0) = procdata->config.net_in_color;
+    }
+    else if (g_str_equal (key, "net-out-color")) {
+        gdk_rgba_parse (&procdata->config.net_out_color, color);
+        procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
+    }
+    else {
+        g_assert_not_reached();
+    }
+    g_free(color);
+}
+
+static void
+show_all_fs_changed_cb (GSettings *settings, const gchar *key, gpointer data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(data);
+
+    procdata->config.show_all_fs = g_settings_get_boolean (settings, key);
+
+    cb_update_disks (data);
+}
+
+static ProcData *
+procman_data_new (GSettings *settings)
+{
+    GSettingsSchema *schema;
+    ProcData *pd;
+    gchar *color;
+    gchar **keys;
+    glibtop_cpu cpu;
+
+    pd = ProcData::get_instance();
+
+    g_settings_get (settings, "window-state", "(iiii)",
+                    &pd->config.width, &pd->config.height,
+                    &pd->config.xpos, &pd->config.ypos);
+
+    pd->config.maximized = g_settings_get_boolean(settings, "maximized");
+
+    pd->config.show_tree = g_settings_get_boolean (settings, "show-tree");
+    g_signal_connect (G_OBJECT(settings), "changed::show-tree", G_CALLBACK(tree_changed_cb), pd);
+
+    pd->config.solaris_mode = g_settings_get_boolean(settings, procman::settings::solaris_mode.c_str());
+    std::string detail_string("changed::" + procman::settings::solaris_mode);
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(solaris_mode_changed_cb), pd);
+
+    pd->config.network_in_bits = g_settings_get_boolean(settings, procman::settings::network_in_bits.c_str());
+    detail_string = "changed::" + procman::settings::network_in_bits;
+    g_signal_connect(G_OBJECT(settings), detail_string.c_str(), G_CALLBACK(network_in_bits_changed_cb), pd);
+
+    pd->config.show_kill_warning = g_settings_get_boolean (settings, "kill-dialog");
+    g_signal_connect (G_OBJECT(settings), "changed::kill-dialog", G_CALLBACK(warning_changed_cb), pd);
+    pd->config.update_interval = g_settings_get_int (settings, "update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::update-interval", G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.graph_update_interval = g_settings_get_int (settings,
+                                                           "graph-update-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::graph-update-interval",
+                      G_CALLBACK(timeouts_changed_cb), pd);
+    pd->config.disks_update_interval = g_settings_get_int (settings, "disks-interval");
+    g_signal_connect (G_OBJECT(settings), "changed::disks-interval", G_CALLBACK(timeouts_changed_cb), pd);
+
+
+    /* show_all_fs */
+    pd->config.show_all_fs = g_settings_get_boolean (settings, "show-all-fs");
+    g_signal_connect (settings, "changed::show-all-fs", G_CALLBACK(show_all_fs_changed_cb), pd);
+
+
+    pd->config.whose_process = g_settings_get_int (settings, "view-as");
+    g_signal_connect (G_OBJECT(settings), "changed::view-as", G_CALLBACK(view_as_changed_cb),pd);
+    pd->config.current_tab = g_settings_get_int (settings, "current-tab");
+
+    glibtop_get_cpu (&cpu);
+    pd->frequency = cpu.frequency;
+    pd->config.num_cpus = glibtop_get_sysinfo()->ncpu; // or server->ncpu + 1
+
+    g_object_get (settings, "settings-schema", &schema, NULL);
+    keys = g_settings_schema_list_keys (schema);
+    g_settings_schema_unref (schema);
+
+    for (int i = 0; i < pd->config.num_cpus; i++) {
+        gchar *key;
+        key = g_strdup_printf ("cpu-color%d", i);
+
+        if (has_key (keys, key))
+            color = g_settings_get_string (settings, key);
+        else
+            color = g_strdup ("#f25915e815e8");
+        detail_string = std::string("changed::") + std::string(key);
+        g_signal_connect (G_OBJECT(settings), detail_string.c_str(),
+                          G_CALLBACK(color_changed_cb), pd);
+        gdk_rgba_parse (&pd->config.cpu_color[i], color);
+        g_free (color);
+        g_free (key);
+    }
+    g_strfreev (keys);
+
+    color = g_settings_get_string (settings, "mem-color");
+    if (!color)
+        color = g_strdup ("#000000ff0082");
+    g_signal_connect (G_OBJECT(settings), "changed::mem-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.mem_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "swap-color");
+    if (!color)
+        color = g_strdup ("#00b6000000ff");
+    g_signal_connect (G_OBJECT(settings), "changed::swap-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.swap_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-in-color");
+    if (!color)
+        color = g_strdup ("#000000f200f2");
+    g_signal_connect (G_OBJECT(settings), "changed::net-in-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_in_color, color);
+    g_free (color);
+
+    color = g_settings_get_string (settings, "net-out-color");
+    if (!color)
+        color = g_strdup ("#00f2000000c1");
+    g_signal_connect (G_OBJECT(settings), "changed::net-out-color",
+                      G_CALLBACK(color_changed_cb), pd);
+    gdk_rgba_parse(&pd->config.net_out_color, color);
+    g_free (color);
+
+    /* Sanity checks */
+    GdkDisplay *display;
+    GdkMonitor *monitor;
+    GdkRectangle monitor_geometry;
+
+    display = gdk_display_get_default ();
+    monitor = gdk_display_get_monitor_at_point (display, pd->config.xpos, pd->config.ypos);
+    if (monitor == NULL) {
+        monitor = gdk_display_get_monitor (display, 0);
+    }
+    gdk_monitor_get_geometry (monitor, &monitor_geometry);
+
+    pd->config.width = CLAMP (pd->config.width, 50, monitor_geometry.width);
+    pd->config.height = CLAMP (pd->config.height, 50, monitor_geometry.height);
+    pd->config.update_interval = MAX (pd->config.update_interval, 1000);
+    pd->config.graph_update_interval = MAX (pd->config.graph_update_interval, 250);
+    pd->config.disks_update_interval = MAX (pd->config.disks_update_interval, 1000);
+    pd->config.whose_process = CLAMP (pd->config.whose_process, 0, 2);
+    pd->config.current_tab = CLAMP(pd->config.current_tab,
+                                   PROCMAN_TAB_SYSINFO,
+                                   PROCMAN_TAB_DISKS);
+
+    // delayed initialization as SmoothRefresh() needs ProcData
+    // i.e. we can't call ProcData::get_instance
+    pd->smooth_refresh = new SmoothRefresh(settings);
+
+    pd->terminating = FALSE;
+
+    return pd;
+}
+
+static void
+procman_free_data (ProcData *procdata)
+{
+
+    proctable_free_table (procdata);
+    delete procdata->smooth_refresh;
+}
+
+ProcmanApp::ProcmanApp() : Gtk::Application("org.mate.SystemMonitor", Gio::APPLICATION_HANDLES_COMMAND_LINE)
+{
+    Glib::set_application_name(_("System Monitor"));
+}
+
+Glib::RefPtr<ProcmanApp> ProcmanApp::create ()
+{
+    return Glib::RefPtr<ProcmanApp>(new ProcmanApp());
+}
+
+void ProcmanApp::on_activate()
+{
+    gtk_window_present (GTK_WINDOW (procdata->app));
+}
+
+static void
+set_tab(GtkNotebook* notebook, gint tab, ProcData* procdata)
+{
+    gtk_notebook_set_current_page(notebook, tab);
+    cb_change_current_page(notebook, tab, procdata);
+}
+
+int ProcmanApp::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line)
+{
+    int argc = 0;
+    char** argv = command_line->get_arguments(argc);
+
+    Glib::OptionContext context;
+    context.set_summary(_("A simple process and system monitor."));
+    context.set_ignore_unknown_options(true);
+    procman::OptionGroup option_group;
+    context.set_main_group(option_group);
+
+    try {
+        context.parse(argc, argv);
+    } catch (const Glib::Error& ex) {
+        g_error("Arguments parse error : %s", ex.what().c_str());
+    }
+
+    if (option_group.show_system_tab) {
+        procman_debug("Starting with PROCMAN_TAB_SYSINFO by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_SYSINFO, procdata);
+    } else if (option_group.show_processes_tab) {
+        procman_debug("Starting with PROCMAN_TAB_PROCESSES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_PROCESSES, procdata);
+    } else if (option_group.show_resources_tab) {
+        procman_debug("Starting with PROCMAN_TAB_RESOURCES by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_RESOURCES, procdata);
+    } else if (option_group.show_file_systems_tab) {
+        procman_debug("Starting with PROCMAN_TAB_DISKS by commandline request");
+        set_tab(GTK_NOTEBOOK(procdata->notebook), PROCMAN_TAB_DISKS, procdata);
+    }
+
+    on_activate ();
+
+    return 0;
+}
+
+void ProcmanApp::on_startup()
+{
+    Gtk::Application::on_startup();
+
+    GSettings *settings;
+
+    Gtk::Window::set_default_icon_name ("utilities-system-monitor");
+
+    settings = g_settings_new (GSM_GSETTINGS_SCHEMA);
+
+    glibtop_init ();
+
+    procdata = procman_data_new (settings);
+    procdata->settings = g_settings_new(GSM_GSETTINGS_SCHEMA);
+
+    create_main_window (procdata);
+    init_volume_monitor (procdata);
+
+    Gtk::Window *window = Glib::wrap(GTK_WINDOW(procdata->app));
+    window->show();
+    window->set_name ("mate-system-monitor");
+
+    add_window (*window);
+}
+
+void ProcmanApp::on_shutdown()
+{
+    procman_free_data(procdata);
+    glibtop_close();
+}
+
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/37.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/37.html new file mode 100644 index 00000000..b1ec2de1 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/37.html @@ -0,0 +1,283 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
#ifndef _PROCMAN_PROCMAN_APP_H_
+#define _PROCMAN_PROCMAN_APP_H_
+
+#include <gtkmm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+class ProcmanApp : public Gtk::Application
+{
+    ProcData *procdata;
+protected:
+    ProcmanApp();
+public:
+    static Glib::RefPtr<ProcmanApp> create ();
+protected:
+    virtual void on_activate();
+    virtual int on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>& command_line);
+    virtual void on_startup();
+    virtual void on_shutdown();
+};
+
+#endif  /* _PROCMAN_PROCMAN_APP_H_ */
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/38.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/38.html new file mode 100644 index 00000000..a481b3e6 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/38.html @@ -0,0 +1,671 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtkmm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman-app.h"
+#include "procman.h"
+#include "proctable.h"
+
+ProcData::ProcData()
+    : tree(NULL),
+      cpu_graph(NULL),
+      mem_graph(NULL),
+      net_graph(NULL),
+      selected_process(NULL),
+      timeout(0),
+      disk_timeout(0),
+      cpu_total_time(1),
+      cpu_total_time_last(1)
+{ }
+
+ProcData* ProcData::get_instance()
+{
+    static ProcData instance;
+    return &instance;
+}
+
+gboolean
+procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns, *it;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+
+    sort_col = g_settings_get_int (pt_settings, "sort-col");
+
+    order = static_cast<GtkSortType>(g_settings_get_int (pt_settings, "sort-order"));
+
+    if (sort_col != -1)
+        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
+                                              sort_col,
+                                              order);
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        for (it = columns; it; it = it->next)
+        {
+            GtkTreeViewColumn *column;
+            gint width;
+            gboolean visible;
+            int id;
+            gchar *key;
+
+            column = static_cast<GtkTreeViewColumn*>(it->data);
+            id = gtk_tree_view_column_get_sort_column_id (column);
+
+            key = g_strdup_printf ("col-%d-width", id);
+            g_settings_get (pt_settings, key, "i", &width);
+            g_free (key);
+
+            key = g_strdup_printf ("col-%d-visible", id);
+            visible = g_settings_get_boolean (pt_settings, key);
+            g_free (key);
+
+            gtk_tree_view_column_set_visible (column, visible);
+            if (visible) {
+                /* ensure column is really visible */
+                width = MAX(width, 20);
+                gtk_tree_view_column_set_fixed_width(column, width);
+            }
+        }
+
+        GVariant     *value;
+        GVariantIter iter;
+        int          sortIndex;
+
+        GSList *order = NULL;<--- Shadow variable
+
+        value = g_settings_get_value(pt_settings, "columns-order");
+        g_variant_iter_init(&iter, value);
+
+        while (g_variant_iter_loop (&iter, "i", &sortIndex))
+            order = g_slist_append(order, GINT_TO_POINTER(sortIndex));
+
+        proctable_set_columns_order(GTK_TREE_VIEW(tree), order);
+
+        g_variant_unref(value);
+        g_slist_free(order);
+    }
+
+    g_object_unref(pt_settings);
+    pt_settings = NULL;
+
+    g_list_free(columns);
+
+    return TRUE;
+}
+
+void
+procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
+{
+    GtkTreeModel *model;
+    GList *columns;
+    gint sort_col;
+    GtkSortType order;<--- Shadowed declaration
+
+    if (ProcData::get_instance()->terminating)
+        return;
+
+    g_assert(tree);
+    g_assert(child_schema);
+
+    GSettings *pt_settings = g_settings_get_child (settings, child_schema);
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    if (gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (model), &sort_col,
+                                              &order)) {
+        g_settings_set_int (pt_settings, "sort-col", sort_col);
+        g_settings_set_int (pt_settings, "sort-order", order);
+    }
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
+
+    if (g_strcmp0(child_schema, "proctree") == 0 ||
+        g_strcmp0(child_schema, "disktreenew") == 0)
+    {
+        GSList *order;<--- Shadow variable
+        GSList *order_node;
+        GVariantBuilder *builder;
+        GVariant *order_variant;
+
+        order = proctable_get_columns_order(GTK_TREE_VIEW(tree));
+
+        builder = g_variant_builder_new (G_VARIANT_TYPE ("ai"));
+
+        for (order_node = order; order_node; order_node = order_node->next)
+            g_variant_builder_add(builder, "i", GPOINTER_TO_INT(order_node->data));
+
+        order_variant = g_variant_new("ai", builder);
+        g_settings_set_value(pt_settings, "columns-order", order_variant);
+
+        g_slist_free(order);
+    }
+
+    g_list_free(columns);
+}
+
+void
+procman_save_config (ProcData *data)
+{
+    GSettings *settings = data->settings;
+
+    g_assert(data);
+
+    data->config.maximized = gdk_window_get_state(gtk_widget_get_window (data->app)) & GDK_WINDOW_STATE_MAXIMIZED;
+    if (!data->config.maximized) {
+        // we only want to store/overwrite size and position info with non-maximized state info
+        data->config.width  = gdk_window_get_width (gtk_widget_get_window (data->app));
+        data->config.height = gdk_window_get_height(gtk_widget_get_window (data->app));
+
+        gtk_window_get_position(GTK_WINDOW(data->app), &data->config.xpos, &data->config.ypos);
+
+        g_settings_set (settings, "window-state", "(iiii)",
+                        data->config.width, data->config.height,
+                        data->config.xpos, data->config.ypos);
+    }
+    g_settings_set_boolean (settings, "maximized", data->config.maximized);
+
+    g_settings_set_int (settings, "current-tab", data->config.current_tab);
+}
+
+int
+main (int argc, char *argv[])
+{
+    bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+    textdomain (GETTEXT_PACKAGE);
+    setlocale (LC_ALL, "");
+
+    Glib::RefPtr<ProcmanApp> application = ProcmanApp::create();
+    return application->run (argc, argv);
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/39.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/39.html new file mode 100644 index 00000000..3facd5ab --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/39.html @@ -0,0 +1,303 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "procman_gksu.h"
+
+gboolean
+procman_gksu_create_root_password_dialog (const char *command)
+{
+    gchar *command_line;
+    gboolean success;
+    GError *error = NULL;
+
+    command_line = g_strdup_printf ("gksu '%s'", command);
+    success = g_spawn_command_line_sync (command_line, NULL, NULL, NULL, &error);
+    g_free (command_line);
+
+    if (!success) {
+        g_critical ("Could not run gksu '%s' : %s\n",
+                    command, error->message);
+        g_error_free (error);
+        return FALSE;
+    }
+
+    g_debug ("gksu did fine\n");
+    return TRUE;
+}
+
+gboolean
+procman_has_gksu (void)
+{
+    return g_file_test ("/usr/bin/gksu", G_FILE_TEST_EXISTS);
+}
+
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/4.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/4.html new file mode 100644 index 00000000..5ce1a9d0 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/4.html @@ -0,0 +1,763 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
/* Procman
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef _PROCMAN_PROCMAN_H_
+#define _PROCMAN_PROCMAN_H_
+
+#include <glibmm/refptr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <cairo-gobject.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk-pixbuf/gdk-pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <map><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+struct ProcInfo;
+struct ProcData;
+struct LoadGraph;
+
+#include "smooth_refresh.h"
+#include "prettytable.h"
+
+#define GSM_GSETTINGS_SCHEMA "org.mate.system-monitor"
+
+enum
+{
+    ALL_PROCESSES,
+    MY_PROCESSES,
+    ACTIVE_PROCESSES
+};
+
+enum
+{
+    VERY_HIGH_PRIORITY,
+    HIGH_PRIORITY,
+    NORMAL_PRIORITY,
+    LOW_PRIORITY,
+    VERY_LOW_PRIORITY,
+    CUSTOM_PRIORITY
+};
+
+static const unsigned MIN_UPDATE_INTERVAL =   1 * 1000;
+static const unsigned MAX_UPDATE_INTERVAL = 100 * 1000;
+
+enum ProcmanTab
+{
+    PROCMAN_TAB_SYSINFO,
+    PROCMAN_TAB_PROCESSES,
+    PROCMAN_TAB_RESOURCES,
+    PROCMAN_TAB_DISKS
+};
+
+struct ProcConfig
+{
+    gint        width;
+    gint        height;
+    gint        xpos;
+    gint        ypos;
+    gboolean    maximized;
+    gboolean    show_kill_warning;
+    gboolean    show_tree;
+    gboolean    show_all_fs;
+    int         update_interval;
+    int         graph_update_interval;
+    int         disks_update_interval;
+    gint        whose_process;
+    gint        current_tab;
+    GdkRGBA     cpu_color[GLIBTOP_NCPU];
+    GdkRGBA     mem_color;
+    GdkRGBA     swap_color;
+    GdkRGBA     net_in_color;
+    GdkRGBA     net_out_color;
+    GdkRGBA     bg_color;
+    GdkRGBA     frame_color;
+    gint        num_cpus;
+    bool solaris_mode;
+    bool network_in_bits;
+};
+
+struct MutableProcInfo
+{
+MutableProcInfo()
+  : disk_write_bytes_current(0ULL),
+    disk_read_bytes_current(0ULL),
+    disk_write_bytes_total(0ULL),
+    disk_read_bytes_total(0ULL),
+    status(0U)
+    { }
+
+    std::string user;
+
+    gchar wchan[40];
+
+    // all these members are filled with libgtop which uses
+    // guint64 (to have fixed size data) but we don't need more
+    // than an unsigned long (even for 32bit apps on a 64bit
+    // kernel) as these data are amounts, not offsets.
+    gulong vmsize;
+    gulong memres;
+    gulong memshared;
+    gulong memwritable;
+    gulong mem;
+
+#ifdef HAVE_WNCK
+    // wnck gives an unsigned long
+    gulong memxserver;
+#endif
+
+    gulong start_time;
+    guint64 cpu_time;
+    guint64 disk_write_bytes_current;
+    guint64 disk_read_bytes_current;
+    guint64 disk_write_bytes_total;
+    guint64 disk_read_bytes_total;
+    guint status;
+    guint pcpu;
+    gint nice;
+    gchar *cgroup_name;
+
+    gchar *unit;
+    gchar *session;
+    gchar *seat;
+
+    std::string owner;
+};
+
+class ProcInfo
+: public MutableProcInfo
+{
+    /* undefined */ ProcInfo& operator=(const ProcInfo&);
+    /* undefined */ ProcInfo(const ProcInfo&);
+
+    typedef std::map<guint, std::string> UserMap;
+    /* cached username */
+    static UserMap users;
+
+  public:
+
+    // TODO: use a set instead
+    // sorted by pid. The map has a nice property : it is sorted
+    // by pid so this helps a lot when looking for the parent node
+    // as ppid is nearly always < pid.
+    typedef std::map<pid_t, ProcInfo*> List;
+    typedef List::iterator Iterator;
+
+    static List all;
+
+    static ProcInfo* find(pid_t pid);
+    static Iterator begin() { return ProcInfo::all.begin(); }
+    static Iterator end() { return ProcInfo::all.end(); }
+
+    ProcInfo(pid_t pid);
+    ~ProcInfo();
+    // adds one more ref to icon
+    void set_icon(Glib::RefPtr<Gdk::Pixbuf> icon);
+    void set_user(guint uid);
+    std::string lookup_user(guint uid);
+
+    GtkTreeIter      node;
+    cairo_surface_t *surface;
+    gchar           *tooltip;
+    gchar           *name;
+    gchar           *arguments;
+    gchar           *security_context;
+
+    const pid_t      pid;
+    pid_t            ppid;
+    guint            uid;
+
+// private:
+    // tracks cpu time per process keeps growing because if a
+    // ProcInfo is deleted this does not mean that the process is
+    // not going to be recreated on the next update.  For example,
+    // if dependencies + (My or Active), the proclist is cleared
+    // on each update.  This is a workaround
+    static std::map<pid_t, guint64> cpu_times;
+};
+
+struct ProcData
+{
+    // lazy initialization
+    static ProcData* get_instance();
+
+    GtkUIManager    *uimanager;
+    GtkActionGroup    *action_group;
+    GtkWidget    *statusbar;
+    gint        tip_message_cid;
+    GtkWidget    *tree;
+    GtkWidget    *loadavg;
+    GtkWidget    *endprocessbutton;
+    GtkWidget    *popup_menu;
+    GtkWidget    *disk_list;
+    GtkWidget    *notebook;
+    ProcConfig    config;
+    LoadGraph    *cpu_graph;
+    LoadGraph    *mem_graph;
+    LoadGraph    *net_graph;
+    gint        cpu_label_fixed_width;
+    gint        net_label_fixed_width;
+    ProcInfo    *selected_process;
+    GtkTreeSelection *selection;
+    guint        timeout;
+    guint        disk_timeout;
+
+    PrettyTable    pretty_table;
+
+    GSettings       *settings;
+    GtkWidget        *app;
+    GtkUIManager    *menu;
+
+    unsigned    frequency;
+
+    SmoothRefresh  *smooth_refresh;
+
+    guint64 cpu_total_time;
+    guint64 cpu_total_time_last;
+
+    gboolean terminating;
+
+private:
+    ProcData();
+    /* undefined */ ProcData(const ProcData &);
+    /* undefined */ ProcData& operator=(const ProcData &);
+};
+
+void        procman_save_config (ProcData *data);
+void        procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+gboolean    procman_get_tree_state (GSettings *settings, GtkWidget *tree, const gchar *prefix);
+
+struct ReniceArgs
+{
+    ProcData *procdata;
+    int nice_value;
+};
+
+struct KillArgs
+{
+    ProcData *procdata;
+    int signal;
+};
+
+#endif /* _PROCMAN_PROCMAN_H_ */
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/40.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/40.html new file mode 100644 index 00000000..49b5a9f4 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/40.html @@ -0,0 +1,303 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman_pkexec.h"
+
+gboolean
+procman_pkexec_create_root_password_dialog (const char *command)
+{
+    gchar *command_line;
+    gboolean success;
+    GError *error = NULL;
+
+    command_line = g_strdup_printf ("pkexec --disable-internal-agent %s/msm-%s",
+                                    PKGLIBEXECDIR, command);
+    success = g_spawn_command_line_sync (command_line, NULL, NULL, NULL, &error);
+    g_free (command_line);
+
+    if (!success) {
+        g_critical ("Could not run pkexec (\"%s\") : %s\n",
+                    command, error->message);
+        g_error_free (error);
+        return FALSE;
+    }
+
+    g_debug ("pkexec did fine\n");
+    return TRUE;
+}
+
+gboolean
+procman_has_pkexec (void)
+{
+    return g_file_test("/usr/bin/pkexec", G_FILE_TEST_EXISTS);
+}
+
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/41.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/41.html new file mode 100644 index 00000000..c4214d73 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/41.html @@ -0,0 +1,913 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
/* Process properties dialog
+ * Copyright (C) 2010 Krishnan Parthasarathi <krishnan.parthasarathi@gmail.com>
+ *                    Robert Ancell <robert.ancell@canonical.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procmem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procmap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procstate.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+#include "procproperties.h"
+#include "proctable.h"
+#include "util.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+enum
+{
+    COL_PROP = 0,
+    COL_VAL,
+    NUM_COLS,
+};
+
+typedef struct _proc_arg {
+    const gchar *prop;
+    gchar *val;
+} proc_arg;
+
+static void
+get_process_memory_writable (ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info (ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+static gchar*
+format_memsize(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
+}
+
+static gchar*
+format_size(guint64 size)
+{
+    if (size == 0)
+        return g_strdup(_("N/A"));
+    else
+        return g_format_size(size);
+}
+
+static void
+fill_proc_properties (GtkWidget *tree, ProcInfo *info)
+{
+    guint i;
+    GtkListStore *store;
+
+    if (!info)
+        return;
+
+    get_process_memory_info(info);
+
+    proc_arg proc_props[] = {
+        { N_("Process Name"), g_strdup_printf("%s", info->name)},
+        { N_("User"), g_strdup_printf("%s (%d)", info->user.c_str(), info->uid)},
+        { N_("Status"), g_strdup(format_process_state(info->status))},
+        { N_("Memory"), format_memsize(info->mem)},
+        { N_("Virtual Memory"), format_memsize(info->vmsize)},
+        { N_("Resident Memory"), format_memsize(info->memres)},
+        { N_("Writable Memory"), format_memsize(info->memwritable)},
+        { N_("Shared Memory"), format_memsize(info->memshared)},
+#ifdef HAVE_WNCK
+        { N_("X Server Memory"), format_memsize(info->memxserver)},
+#endif
+        { N_("Disk Read Total"), format_size(info->disk_read_bytes_total)},
+        { N_("Disk Write Total"), format_size(info->disk_write_bytes_total)},
+        { N_("CPU"), g_strdup_printf("%d%%", info->pcpu)},
+        { N_("CPU Time"), procman::format_duration_for_display(100 * info->cpu_time / ProcData::get_instance()->frequency) },
+        { N_("Started"), procman_format_date_for_display(info->start_time) },
+        { N_("Nice"), g_strdup_printf("%d", info->nice)},
+        { N_("Priority"), g_strdup_printf("%s", procman::get_nice_level(info->nice)) },
+        { N_("ID"), g_strdup_printf("%d", info->pid)},
+        { N_("Security Context"), info->security_context ? g_strdup_printf("%s", info->security_context) : g_strdup(_("N/A"))},
+        { N_("Command Line"), g_strdup_printf("%s", info->arguments)},
+        { N_("Waiting Channel"), g_strdup_printf("%s", info->wchan)},
+        { N_("Control Group"), info->cgroup_name ? g_strdup_printf("%s", info->cgroup_name) : g_strdup(_("N/A"))},
+        { NULL, NULL}
+    };
+
+    store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
+    for (i = 0; proc_props[i].prop; i++) {
+        GtkTreeIter iter;
+
+        if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL(store), &iter, NULL, i)) {
+            gtk_list_store_append(store, &iter);
+            gtk_list_store_set(store, &iter, COL_PROP, _(proc_props[i].prop), -1);
+        }
+
+        gtk_list_store_set(store, &iter, COL_VAL, g_strstrip(proc_props[i].val), -1);
+        g_free(proc_props[i].val);
+    }
+}
+
+static void
+update_procproperties_dialog (GtkWidget *tree)
+{
+    ProcInfo *info;
+
+    pid_t pid = GPOINTER_TO_UINT(static_cast<pid_t*>(g_object_get_data (G_OBJECT (tree), "selected_info")));
+    info = ProcInfo::find(pid);
+
+    fill_proc_properties(tree, info);
+}
+
+static void
+close_procprop_dialog (GtkDialog *dialog, gint id, gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    guint timer;
+
+    timer = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (tree), "timer"));
+    g_source_remove (timer);
+
+    gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static GtkWidget *
+create_procproperties_tree (ProcData *procdata)
+{
+    GtkWidget *tree;
+    GtkListStore *model;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell;
+    gint i;
+
+    model = gtk_list_store_new (NUM_COLS,
+                                G_TYPE_STRING,	/* Property */
+                                G_TYPE_STRING	/* Value */
+        );
+
+    tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    g_object_unref (G_OBJECT (model));
+
+    for (i = 0; i < NUM_COLS; i++) {
+        cell = gtk_cell_renderer_text_new ();
+
+        column = gtk_tree_view_column_new_with_attributes (NULL,
+                                                           cell,
+                                                           "text", i,
+                                                           NULL);
+        gtk_tree_view_column_set_resizable (column, TRUE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+    }
+
+    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(tree), FALSE);
+    fill_proc_properties(tree, procdata->selected_process);
+
+    return tree;
+}
+
+static gboolean
+procprop_timer (gpointer data)
+{
+    GtkWidget *tree = static_cast<GtkWidget*>(data);
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
+    g_assert(model);
+
+    update_procproperties_dialog (tree);
+
+    return TRUE;
+}
+
+static void
+create_single_procproperties_dialog (GtkTreeModel *model, GtkTreePath *path,
+                                     GtkTreeIter *iter, gpointer data)
+{
+    ProcData *procdata = static_cast<ProcData*>(data);
+    GtkWidget *procpropdialog;
+    GtkWidget *dialog_vbox, *vbox;
+    GtkWidget *cmd_hbox;
+    GtkWidget *label;
+    GtkWidget *scrolled;
+    GtkWidget *tree;
+    ProcInfo *info;
+    guint timer;
+
+    gtk_tree_model_get (model, iter, COL_POINTER, &info, -1);
+
+    if (!info)
+        return;
+
+    procpropdialog = gtk_dialog_new_with_buttons (_("Process Properties"), NULL,
+                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                  "gtk-close", GTK_RESPONSE_CLOSE,
+                                                  NULL);
+    gtk_window_set_resizable (GTK_WINDOW (procpropdialog), TRUE);
+    gtk_window_set_default_size (GTK_WINDOW (procpropdialog), 575, 400);
+    gtk_container_set_border_width (GTK_CONTAINER (procpropdialog), 5);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (procpropdialog));
+    gtk_box_set_spacing (GTK_BOX (vbox), 2);
+    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+    dialog_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
+    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+
+    cmd_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+
+    label = procman_make_label_for_mmaps_or_ofiles (
+        _("Properties of process \"%s\" (PID %u):"),
+        info->name,
+        info->pid);
+
+    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+
+    scrolled = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+                                    GTK_POLICY_AUTOMATIC,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+                                         GTK_SHADOW_IN);
+
+    tree = create_procproperties_tree (procdata);
+    gtk_container_add (GTK_CONTAINER (scrolled), tree);
+    g_object_set_data (G_OBJECT (tree), "selected_info", GUINT_TO_POINTER (info->pid));
+
+    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
+    gtk_widget_show_all (scrolled);
+
+    g_signal_connect (G_OBJECT (procpropdialog), "response",
+                      G_CALLBACK (close_procprop_dialog), tree);
+
+    gtk_widget_show_all (procpropdialog);
+
+    timer = g_timeout_add_seconds (5, procprop_timer, tree);
+    g_object_set_data (G_OBJECT (tree), "timer", GUINT_TO_POINTER (timer));
+
+    update_procproperties_dialog (tree);
+}
+
+void
+create_procproperties_dialog (ProcData *procdata)
+{
+    gtk_tree_selection_selected_foreach (procdata->selection, create_single_procproperties_dialog,
+                                         procdata);
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/42.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/42.html new file mode 100644 index 00000000..27c5022d --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/42.html @@ -0,0 +1,2635 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
/* Procman tree view and process updating
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <cairo-gobject.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gprintf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/loadavg.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/proclist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procstate.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procmem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procmap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/proctime.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procuid.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procargs.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/prockernel.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/swap.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <pwd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <set><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <list><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef HAVE_SYSTEMD
+#include <systemd/sd-login.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include "procman.h"
+#include "selection.h"
+#include "proctable.h"
+#include "callbacks.h"
+#include "prettytable.h"
+#include "util.h"
+#include "interface.h"
+#include "selinux.h"
+#include "cgroups.h"
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+ProcInfo::UserMap ProcInfo::users;
+ProcInfo::List ProcInfo::all;
+std::map<pid_t, guint64> ProcInfo::cpu_times;
+
+
+ProcInfo* ProcInfo::find(pid_t pid)
+{
+    Iterator it(ProcInfo::all.find(pid));
+    return (it == ProcInfo::all.end() ? NULL : it->second);
+}
+
+void
+get_last_selected (GtkTreeModel *model, GtkTreePath *path,
+           GtkTreeIter *iter, gpointer data)
+{
+    ProcInfo **info = static_cast<ProcInfo**>(data);
+
+    gtk_tree_model_get (model, iter, COL_POINTER, info, -1);
+}
+
+static void
+cb_columns_changed(GtkTreeView *treeview, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state(procdata->settings,
+                            GTK_WIDGET(treeview),
+                            "proctree");
+}
+
+static void
+cb_sort_changed (GtkTreeSortable *model, gpointer user_data)
+{
+    ProcData * const procdata = static_cast<ProcData*>(user_data);
+
+    procman_save_tree_state (procdata->settings,
+                             GTK_WIDGET (procdata->tree),
+                             "proctree");
+}
+
+
+static GtkTreeViewColumn*
+my_gtk_tree_view_get_column_with_sort_column_id(GtkTreeView *treeview, int id)
+{
+    GList *columns, *it;
+    GtkTreeViewColumn *col = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(it = columns; it; it = it->next)
+    {
+        if(gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(it->data)) == id)
+        {
+            col = static_cast<GtkTreeViewColumn*>(it->data);
+            break;
+        }
+    }
+
+    g_list_free(columns);
+
+    return col;
+}
+
+
+void
+proctable_set_columns_order(GtkTreeView *treeview, GSList *order)
+{
+    GtkTreeViewColumn* last = NULL;
+    GSList *it;
+
+    for(it = order; it; it = it->next)
+    {
+        int id;
+        GtkTreeViewColumn *cur;
+
+        id = GPOINTER_TO_INT(it->data);
+
+        cur = my_gtk_tree_view_get_column_with_sort_column_id(treeview, id);
+
+        if(cur && cur != last)
+        {
+            gtk_tree_view_move_column_after(treeview, cur, last);
+            last = cur;
+        }
+    }
+}
+
+
+GSList*
+proctable_get_columns_order(GtkTreeView *treeview)
+{
+    GList *columns, *col;
+    GSList *order = NULL;
+
+    columns = gtk_tree_view_get_columns(treeview);
+
+    for(col = columns; col; col = col->next)
+    {
+        int id;
+
+        id = gtk_tree_view_column_get_sort_column_id(static_cast<GtkTreeViewColumn*>(col->data));
+        order = g_slist_prepend(order, GINT_TO_POINTER(id));
+    }
+
+    g_list_free(columns);
+
+    order = g_slist_reverse(order);
+
+    return order;
+}
+
+static guint timeout_id = 0;
+static GtkTreeViewColumn *current_column;
+
+static gboolean
+save_column_width (gpointer data)
+{
+    gint width;
+    gchar *key;
+    int id;
+    GSettings *settings;
+
+    settings = g_settings_get_child (G_SETTINGS (data), "proctree");
+    id = gtk_tree_view_column_get_sort_column_id (current_column);
+    width = gtk_tree_view_column_get_width (current_column);
+
+    key = g_strdup_printf ("col-%d-width", id);
+    g_settings_set_int(settings, key, width);
+    g_free (key);
+
+    if (timeout_id) {
+        g_source_remove (timeout_id);
+        timeout_id = 0;
+    }
+
+    return FALSE;
+}
+
+static void
+cb_proctable_column_resized(GtkWidget *widget, GParamSpec *pspec, gpointer data)
+{
+    current_column = GTK_TREE_VIEW_COLUMN(widget);
+
+    if (timeout_id)
+        g_source_remove (timeout_id);
+
+    timeout_id = g_timeout_add (250, save_column_width, data);
+}
+
+static gboolean
+search_equal_func(GtkTreeModel *model,
+                  gint column,
+                  const gchar *key,
+                  GtkTreeIter *iter,
+                  gpointer search_data)
+{
+    char* name;
+    char* user;
+    gboolean found;
+
+    gtk_tree_model_get(model, iter,
+                       COL_NAME, &name,
+                       COL_USER, &user,
+                       -1);
+
+    found = !((name && strcasestr(name, key))
+              || (user && strcasestr(user, key)));
+
+    g_free(name);
+    g_free(user);
+
+    return found;
+}
+
+
+
+GtkWidget *
+proctable_new (ProcData * const procdata)
+{
+    GtkWidget *proctree;
+    GtkTreeStore *model;
+    GtkTreeSelection *selection;
+    GtkTreeViewColumn *column;
+    GtkCellRenderer *cell_renderer;
+
+    const gchar *titles[] = {
+        N_("Process Name"),
+        N_("User"),
+        N_("Status"),
+        N_("Virtual Memory"),
+        N_("Resident Memory"),
+        N_("Writable Memory"),
+        N_("Shared Memory"),
+        N_("X Server Memory"),
+        /* xgettext:no-c-format */ N_("% CPU"),
+        N_("CPU Time"),
+        N_("Started"),
+        N_("Nice"),
+        N_("ID"),
+        N_("Security Context"),
+        N_("Command Line"),
+        N_("Memory"),
+        /* xgettext: combined noun, the function the process is waiting in, see wchan ps(1) */
+        N_("Waiting Channel"),
+        N_("Control Group"),
+        N_("Unit"),
+        N_("Session"),
+        /* TRANSLATORS: Seat = i.e. the physical seat the session of the process belongs to, only
+	for multi-seat environments. See http://en.wikipedia.org/wiki/Multiseat_configuration */
+        N_("Seat"),
+        N_("Owner"),
+        N_("Disk Read Total"),
+        N_("Disk Write Total"),
+        N_("Disk Read"),
+        N_("Disk Write"),
+        N_("Priority"),
+        NULL,
+        "POINTER"
+    };
+
+    gint i;
+
+    model = gtk_tree_store_new (NUM_COLUMNS,
+                                G_TYPE_STRING,              /* Process Name */
+                                G_TYPE_STRING,              /* User         */
+                                G_TYPE_UINT,                /* Status       */
+                                G_TYPE_ULONG,               /* VM Size      */
+                                G_TYPE_ULONG,               /* Resident Memory */
+                                G_TYPE_ULONG,               /* Writable Memory */
+                                G_TYPE_ULONG,               /* Shared Memory */
+                                G_TYPE_ULONG,               /* X Server Memory */
+                                G_TYPE_UINT,                /* % CPU        */
+                                G_TYPE_UINT64,              /* CPU time     */
+                                G_TYPE_ULONG,               /* Started      */
+                                G_TYPE_INT,                 /* Nice         */
+                                G_TYPE_UINT,                /* ID           */
+                                G_TYPE_STRING,              /* Security Context */
+                                G_TYPE_STRING,              /* Arguments    */
+                                G_TYPE_ULONG,               /* Memory       */
+                                G_TYPE_STRING,              /* wchan        */
+                                G_TYPE_STRING,              /* Cgroup       */
+                                G_TYPE_STRING,              /* Unit         */
+                                G_TYPE_STRING,              /* Session      */
+                                G_TYPE_STRING,              /* Seat         */
+                                G_TYPE_STRING,              /* Owner        */
+                                G_TYPE_UINT64,              /* Disk read total */
+                                G_TYPE_UINT64,              /* Disk write total*/
+                                G_TYPE_UINT64,              /* Disk read    */
+                                G_TYPE_UINT64,              /* Disk write   */
+                                G_TYPE_STRING,              /* Priority     */
+                                CAIRO_GOBJECT_TYPE_SURFACE, /* Icon         */
+                                G_TYPE_POINTER,             /* ProcInfo     */
+                                G_TYPE_STRING               /* Sexy tooltip */
+        );
+
+    proctree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+    gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (proctree), COL_TOOLTIP);
+    g_object_set(G_OBJECT(proctree),
+                 "show-expanders", procdata->config.show_tree,
+                 NULL);
+    gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (proctree),
+                                         search_equal_func,
+                                         NULL,
+                                         NULL);
+    g_object_unref (G_OBJECT (model));
+
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree));
+    gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+
+    column = gtk_tree_view_column_new ();
+
+    cell_renderer = gtk_cell_renderer_pixbuf_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "surface", COL_SURFACE,
+                                         NULL);
+
+    cell_renderer = gtk_cell_renderer_text_new ();
+    gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+    gtk_tree_view_column_set_attributes (column, cell_renderer,
+                                         "text", COL_NAME,
+                                         NULL);
+    gtk_tree_view_column_set_title (column, _(titles[0]));
+    gtk_tree_view_column_set_sort_column_id (column, COL_NAME);
+    gtk_tree_view_column_set_resizable (column, TRUE);
+    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+    gtk_tree_view_column_set_min_width (column, 20);
+    gtk_tree_view_column_set_reorderable (column, TRUE);
+    g_signal_connect(G_OBJECT(column), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (proctree), column);
+    gtk_tree_view_set_expander_column (GTK_TREE_VIEW (proctree), column);
+
+
+    for (i = COL_USER; i <= COL_PRIORITY; i++) {
+
+        GtkCellRenderer *cell;
+        GtkTreeViewColumn *col;
+
+#ifndef HAVE_WNCK
+        if (i == COL_MEMXSERVER) {
+          continue;
+        }
+#endif
+
+        cell = gtk_cell_renderer_text_new();
+        col = gtk_tree_view_column_new();
+        gtk_tree_view_column_pack_start(col, cell, TRUE);
+        gtk_tree_view_column_set_title(col, _(titles[i]));
+        gtk_tree_view_column_set_sort_column_id(col, i);
+        gtk_tree_view_column_set_resizable(col, TRUE);
+        gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_FIXED);
+        g_signal_connect(G_OBJECT(col), "notify::fixed-width", G_CALLBACK(cb_proctable_column_resized), procdata->settings);
+        gtk_tree_view_column_set_reorderable(col, TRUE);
+        gtk_tree_view_append_column(GTK_TREE_VIEW(proctree), col);
+
+        // type
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::memory_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_CPU_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::duration_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_START_TIME:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::time_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_STATUS:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::status_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::storage_size_na_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::io_rate_cell_data_func,
+                                                        GUINT_TO_POINTER(i),
+                                                        NULL);
+                break;
+
+            case COL_PRIORITY:
+                gtk_tree_view_column_set_cell_data_func(col, cell,
+                                                        &procman::priority_cell_data_func,
+                                                        GUINT_TO_POINTER(COL_NICE),
+                                                        NULL);
+                break;
+
+            default:
+                gtk_tree_view_column_set_attributes(col, cell, "text", i, NULL);
+        }
+
+        // sorting
+        switch (i) {
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMSHARED:
+            case COL_MEM:
+            case COL_MEMWRITABLE:
+            case COL_CPU:
+            case COL_CPU_TIME:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_START_TIME:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::number_compare_func, GUINT_TO_POINTER(i),
+                                                NULL);
+                break;
+            case COL_PRIORITY:
+                gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), i,
+                                                procman::priority_compare_func,
+                                                GUINT_TO_POINTER(COL_NICE), NULL);
+                break;
+            default:
+                break;
+        }
+
+        // xalign
+        switch(i)
+        {
+            case COL_VMSIZE:
+            case COL_MEMRES:
+            case COL_MEMWRITABLE:
+            case COL_MEMSHARED:
+#ifdef HAVE_WNCK
+            case COL_MEMXSERVER:
+#endif
+            case COL_CPU:
+            case COL_NICE:
+            case COL_PID:
+            case COL_DISK_READ_TOTAL:
+            case COL_DISK_WRITE_TOTAL:
+            case COL_DISK_READ_CURRENT:
+            case COL_DISK_WRITE_CURRENT:
+            case COL_CPU_TIME:
+            case COL_MEM:
+                g_object_set(G_OBJECT(cell), "xalign", 1.0f, NULL);
+                break;
+        }
+
+        // sizing
+        switch (i) {
+            case COL_ARGS:
+                gtk_tree_view_column_set_min_width(col, 150);
+                break;
+            default:
+                gtk_tree_view_column_set_min_width(col, 20);
+                break;
+        }
+    }
+
+    procdata->tree = proctree;
+
+    procman_get_tree_state (procdata->settings, proctree, "proctree");
+
+    /* Override column settings by hiding this column if it's meaningless: */
+    if (!can_show_security_context_column ()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id (GTK_TREE_VIEW (proctree), COL_SECURITYCONTEXT);
+        gtk_tree_view_column_set_visible (column, FALSE);
+    }
+
+    if (!cgroups_enabled()) {
+        column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), COL_CGROUP);
+        gtk_tree_view_column_set_visible(column, FALSE);
+    }
+
+#ifdef HAVE_SYSTEMD
+    if (!LOGIND_RUNNING())
+#endif
+    {
+        for (i = COL_UNIT; i <= COL_OWNER; i++) {
+            column = my_gtk_tree_view_get_column_with_sort_column_id(GTK_TREE_VIEW(proctree), i);
+            gtk_tree_view_column_set_visible(column, FALSE);
+        }
+    }
+
+    g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (proctree))),
+                      "changed",
+                      G_CALLBACK (cb_row_selected), procdata);
+    g_signal_connect (G_OBJECT (proctree), "popup_menu",
+                      G_CALLBACK (cb_tree_popup_menu), procdata);
+    g_signal_connect (G_OBJECT (proctree), "button_press_event",
+                      G_CALLBACK (cb_tree_button_pressed), procdata);
+
+    g_signal_connect (G_OBJECT(proctree), "columns-changed",
+                      G_CALLBACK(cb_columns_changed), procdata);
+
+    g_signal_connect (G_OBJECT (model), "sort-column-changed",
+                      G_CALLBACK (cb_sort_changed), procdata);
+
+    return proctree;
+}
+
+
+ProcInfo::~ProcInfo()
+{
+    g_free(this->name);
+    g_free(this->tooltip);
+    g_free(this->arguments);
+    g_free(this->security_context);
+    g_free(this->cgroup_name);
+    g_free(this->unit);
+    g_free(this->session);
+    g_free(this->seat);
+    cairo_surface_destroy(this->surface);
+}
+
+
+static void
+get_process_name (ProcInfo *info,
+                  const gchar *cmd, const GStrv args)
+{
+    if (args) {
+        // look for /usr/bin/very_long_name
+        // and also /usr/bin/interpreter /usr/.../very_long_name
+        // which may have use prctl to alter 'cmd' name
+        for (int i = 0; i != 2 && args[i]; ++i) {
+            char* basename;
+            basename = g_path_get_basename(args[i]);
+
+            if (g_str_has_prefix(basename, cmd)) {
+                info->name = basename;
+                return;
+            }
+
+            g_free(basename);
+        }
+    }
+
+    info->name = g_strdup (cmd);
+}
+
+std::string
+ProcInfo::lookup_user(guint uid)
+{
+    typedef std::pair<ProcInfo::UserMap::iterator, bool> Pair;
+    ProcInfo::UserMap::value_type hint(uid, "");
+    Pair p(ProcInfo::users.insert(hint));
+
+    // procman_debug("User lookup for uid %u: %s", uid, (p.second ? "MISS" : "HIT"));
+
+    if (p.second) {
+        struct passwd* pwd;<--- Variable 'pwd' can be declared as pointer to const
+        pwd = getpwuid(uid);
+
+        if (pwd && pwd->pw_name)
+            p.first->second = pwd->pw_name;
+        else {
+            char username[16];
+            g_sprintf(username, "%u", uid);
+            p.first->second = username;
+        }
+    }
+
+    return p.first->second;
+}
+
+void
+ProcInfo::set_user(guint uid)
+{
+    if (G_LIKELY(this->uid == uid))
+        return;
+
+    this->uid = uid;
+    this->user = lookup_user(uid);
+}
+
+static void get_process_memory_writable(ProcInfo *info)
+{
+    glibtop_proc_map buf;
+    glibtop_map_entry *maps;
+
+    maps = glibtop_get_proc_map(&buf, info->pid);
+
+    gulong memwritable = 0;
+    const unsigned number = buf.number;
+
+    for (unsigned i = 0; i < number; ++i) {
+#ifdef __linux__
+        memwritable += maps[i].private_dirty;
+#else
+        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+            memwritable += maps[i].size;
+#endif
+    }
+
+    info->memwritable = memwritable;
+
+    g_free(maps);
+}
+
+static void
+get_process_memory_info(ProcInfo *info)
+{
+    glibtop_proc_mem procmem;
+
+#ifdef HAVE_WNCK
+    info->memxserver = 0;
+#ifdef GDK_WINDOWING_X11
+    if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
+        WnckResourceUsage xresources;
+
+        wnck_pid_read_resource_usage (gdk_screen_get_display (gdk_screen_get_default ()),
+                                      info->pid,
+                                      &xresources);
+
+        info->memxserver = xresources.total_bytes_estimate;
+    }
+#endif // GDK_WINDOWING_X11
+#endif // HAVE_WNCK
+
+    glibtop_get_proc_mem(&procmem, info->pid);
+
+    info->vmsize    = procmem.vsize;
+    info->memres    = procmem.resident;
+    info->memshared = procmem.share;
+
+    get_process_memory_writable(info);
+
+    // fake the smart memory column if writable is not available
+    info->mem = info->memwritable ? info->memwritable : info->memres;
+#ifdef HAVE_WNCK
+    info->mem += info->memxserver;
+#endif
+}
+
+
+static void
+update_info_mutable_cols(ProcInfo *info)
+{
+    ProcData * const procdata = ProcData::get_instance();
+    GtkTreeModel *model;
+    model = gtk_tree_view_get_model(GTK_TREE_VIEW(procdata->tree));
+
+    using procman::tree_store_update;
+
+    tree_store_update(model, &info->node, COL_STATUS, info->status);
+    tree_store_update(model, &info->node, COL_USER, info->user.c_str());
+    tree_store_update(model, &info->node, COL_VMSIZE, info->vmsize);
+    tree_store_update(model, &info->node, COL_MEMRES, info->memres);
+    tree_store_update(model, &info->node, COL_MEMWRITABLE, info->memwritable);
+    tree_store_update(model, &info->node, COL_MEMSHARED, info->memshared);
+#ifdef HAVE_WNCK
+    tree_store_update(model, &info->node, COL_MEMXSERVER, info->memxserver);
+#endif
+    tree_store_update(model, &info->node, COL_CPU, info->pcpu);
+    tree_store_update(model, &info->node, COL_CPU_TIME, info->cpu_time);
+    tree_store_update(model, &info->node, COL_DISK_READ_TOTAL, info->disk_read_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_TOTAL, info->disk_write_bytes_total);
+    tree_store_update(model, &info->node, COL_DISK_READ_CURRENT, info->disk_read_bytes_current);
+    tree_store_update(model, &info->node, COL_DISK_WRITE_CURRENT, info->disk_write_bytes_current);
+    tree_store_update(model, &info->node, COL_START_TIME, info->start_time);
+    tree_store_update(model, &info->node, COL_NICE, info->nice);
+    tree_store_update(model, &info->node, COL_MEM, info->mem);
+    tree_store_update(model, &info->node, COL_WCHAN, info->wchan);
+    tree_store_update(model, &info->node, COL_CGROUP, info->cgroup_name);
+    tree_store_update(model, &info->node, COL_UNIT, info->unit);
+    tree_store_update(model, &info->node, COL_SESSION, info->session);
+    tree_store_update(model, &info->node, COL_SEAT, info->seat);
+    tree_store_update(model, &info->node, COL_OWNER, info->owner.c_str());
+}
+
+
+
+static void
+insert_info_to_tree (ProcInfo *info, ProcData *procdata, bool forced = false)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    if (procdata->config.show_tree) {
+
+        ProcInfo *parent = 0;
+
+        if (not forced)
+            parent = ProcInfo::find(info->ppid);
+
+        if (parent) {
+            GtkTreePath *parent_node = gtk_tree_model_get_path(model, &parent->node);
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, &parent->node, 0);
+
+            if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(procdata->tree), parent_node)
+#ifdef __linux__
+                // on linuxes we don't want to expand kthreadd by default (always has pid 2)
+                && (parent->pid != 2)
+#endif
+            )
+                gtk_tree_view_expand_row(GTK_TREE_VIEW(procdata->tree), parent_node, FALSE);
+            gtk_tree_path_free(parent_node);
+        } else
+            gtk_tree_store_insert(GTK_TREE_STORE(model), &info->node, NULL, 0);
+    }
+    else
+        gtk_tree_store_insert (GTK_TREE_STORE (model), &info->node, NULL, 0);
+
+    gtk_tree_store_set (GTK_TREE_STORE (model), &info->node,
+                        COL_POINTER, info,
+                        COL_NAME, info->name,
+                        COL_ARGS, info->arguments,
+                        COL_TOOLTIP, info->tooltip,
+                        COL_PID, info->pid,
+                        COL_SECURITYCONTEXT, info->security_context,
+                        -1);
+
+    procdata->pretty_table.set_icon(*info);
+
+    procman_debug("inserted %d%s", info->pid, (forced ? " (forced)" : ""));
+}
+
+
+/* Removing a node with children - make sure the children are queued
+** to be readded.
+*/
+template<typename List>
+static void
+remove_info_from_tree (ProcData *procdata, GtkTreeModel *model,
+                       ProcInfo *current, List &orphans, unsigned lvl = 0)
+{
+    GtkTreeIter child_node;
+
+    if (std::find(orphans.begin(), orphans.end(), current) != orphans.end()) {
+        procman_debug("[%u] %d already removed from tree", lvl, int(current->pid));
+        return;
+    }
+
+    procman_debug("[%u] pid %d, %d children", lvl, int(current->pid),
+                  gtk_tree_model_iter_n_children(model, &current->node));
+
+    // it is not possible to iterate&erase over a treeview so instead we
+    // just pop one child after another and recursively remove it and
+    // its children
+
+    while (gtk_tree_model_iter_children(model, &child_node, &current->node)) {
+        ProcInfo *child = 0;
+        gtk_tree_model_get(model, &child_node, COL_POINTER, &child, -1);
+        remove_info_from_tree(procdata, model, child, orphans, lvl + 1);
+    }
+
+    g_assert(not gtk_tree_model_iter_has_child(model, &current->node));
+
+    if (procdata->selected_process == current)
+        procdata->selected_process = NULL;
+
+    orphans.push_back(current);
+    gtk_tree_store_remove(GTK_TREE_STORE(model), &current->node);
+    procman::poison(current->node, 0x69);
+}
+
+static void
+get_process_systemd_info(ProcInfo *info)
+{
+#ifdef HAVE_SYSTEMD
+    uid_t uid;
+
+    if (!LOGIND_RUNNING())
+        return;
+
+    free(info->unit);
+    info->unit = NULL;
+    sd_pid_get_unit(info->pid, &info->unit);
+
+    free(info->session);
+    info->session = NULL;
+    sd_pid_get_session(info->pid, &info->session);
+
+    free(info->seat);
+    info->seat = NULL;
+
+    if (info->session != NULL)
+        sd_session_get_seat(info->session, &info->seat);
+
+    if (sd_pid_get_owner_uid(info->pid, &uid) >= 0)
+        info->owner = info->lookup_user(uid);
+    else
+        info->owner = "";
+#endif
+}
+
+static void
+update_info (ProcData *procdata, ProcInfo *info)
+{
+    glibtop_proc_state procstate;
+    glibtop_proc_uid procuid;
+    glibtop_proc_time proctime;
+    glibtop_proc_kernel prockernel;
+    glibtop_proc_io procio;
+
+    glibtop_get_proc_kernel(&prockernel, info->pid);
+    g_strlcpy(info->wchan, prockernel.wchan, sizeof info->wchan);
+
+    glibtop_get_proc_state (&procstate, info->pid);
+    info->status = procstate.state;
+
+    glibtop_get_proc_uid (&procuid, info->pid);
+    glibtop_get_proc_time (&proctime, info->pid);
+    glibtop_get_proc_io (&procio, info->pid);
+
+    get_process_memory_info(info);
+
+    info->set_user(procstate.uid);
+
+    // if the cpu time has increased reset the status to running
+    // regardless of kernel state (https://bugzilla.gnome.org/606579)
+    guint64 difference = proctime.rtime - info->cpu_time;
+    if (difference > 0)
+        info->status = GLIBTOP_PROCESS_RUNNING;
+    info->pcpu = difference * 100 / procdata->cpu_total_time;
+    info->pcpu = MIN(info->pcpu, 100);
+
+    if (not procdata->config.solaris_mode)
+      info->pcpu *= procdata->config.num_cpus;
+
+    ProcInfo::cpu_times[info->pid] = info->cpu_time = proctime.rtime;
+    info->nice = procuid.nice;
+
+    gdouble update_interval_seconds = procdata->config.update_interval / 1000.0;
+    difference = procio.disk_wbytes - info->disk_write_bytes_total;
+    info->disk_write_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+    difference = procio.disk_rbytes - info->disk_read_bytes_total;
+    info->disk_read_bytes_current = difference > update_interval_seconds ? difference/update_interval_seconds : 0ULL;
+
+    info->disk_write_bytes_total = procio.disk_wbytes;
+    info->disk_read_bytes_total = procio.disk_rbytes;
+
+    // set the ppid only if one can exist
+    // i.e. pid=0 can never have a parent
+    if (info->pid > 0) {
+        info->ppid = procuid.ppid;
+    }
+
+    g_assert(info->pid != info->ppid);
+    g_assert(info->ppid != -1 || info->pid == 0);
+
+    /* get cgroup data */
+    get_process_cgroup_info(info);
+
+    get_process_systemd_info(info);
+}
+
+
+ProcInfo::ProcInfo(pid_t pid)
+    : node(),
+      surface(),
+      tooltip(NULL),
+      name(NULL),
+      arguments(NULL),
+      security_context(NULL),
+      pid(pid),
+      ppid(-1),
+      uid(-1)
+{
+    ProcInfo * const info = this;
+    glibtop_proc_state procstate;
+    glibtop_proc_time proctime;
+    glibtop_proc_args procargs;
+    gchar** arguments;<--- Shadow variable
+
+    glibtop_get_proc_state (&procstate, pid);
+    glibtop_get_proc_time (&proctime, pid);
+    arguments = glibtop_get_proc_argv (&procargs, pid, 0);
+
+    /* FIXME : wrong. name and arguments may change with exec* */
+    get_process_name (info, procstate.cmd, static_cast<const GStrv>(arguments));
+
+    std::string tooltip = make_string(g_strjoinv(" ", arguments));<--- Shadow variable
+    if (tooltip.empty())
+        tooltip = procstate.cmd;
+
+    info->tooltip = g_markup_escape_text(tooltip.c_str(), -1);
+
+    info->arguments = g_strescape(tooltip.c_str(), "\\\"");
+    g_strfreev(arguments);
+
+    guint64 cpu_time = proctime.rtime;
+    std::map<pid_t, guint64>::iterator it(ProcInfo::cpu_times.find(pid));
+    if (it != ProcInfo::cpu_times.end())
+    {
+        if (proctime.rtime >= it->second)
+          cpu_time = it->second;
+    }
+    info->cpu_time = cpu_time;
+    info->start_time = proctime.start_time;
+
+    get_process_selinux_context (info);
+    info->cgroup_name = NULL;
+    get_process_cgroup_info(info);
+
+    info->unit = info->session = info->seat = NULL;
+    get_process_systemd_info(info);
+}
+
+static void
+refresh_list (ProcData *procdata, const pid_t* pid_list, const guint n)
+{
+    typedef std::list<ProcInfo*> ProcList;
+    ProcList addition;
+
+    GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+    guint i;
+
+    // Add or update processes in the process list
+    for(i = 0; i < n; ++i) {
+        ProcInfo *info = ProcInfo::find(pid_list[i]);
+
+        if (!info) {
+            info = new ProcInfo(pid_list[i]);
+            ProcInfo::all[info->pid] = info;
+            addition.push_back(info);
+        }
+
+        update_info (procdata, info);
+    }
+
+
+    // Remove dead processes from the process list and from the
+    // tree. children are queued to be readded at the right place
+    // in the tree.
+
+    const std::set<pid_t> pids(pid_list, pid_list + n);
+
+    ProcInfo::Iterator it(ProcInfo::begin());<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration<--- Shadowed declaration
+
+    while (it != ProcInfo::end()) {
+        ProcInfo * const info = it->second;
+        ProcInfo::Iterator next(it);
+        ++next;
+
+        if (pids.find(info->pid) == pids.end()) {
+            procman_debug("ripping %d", info->pid);
+            remove_info_from_tree(procdata, model, info, addition);
+            addition.remove(info);
+            ProcInfo::all.erase(it);
+            delete info;
+        }
+
+        it = next;
+    }
+
+    // INVARIANT
+    // pid_list == ProcInfo::all + addition
+
+
+    if (procdata->config.show_tree) {
+
+        // insert process in the tree. walk through the addition list
+        // (new process + process that have a new parent). This loop
+        // handles the dependencies because we cannot insert a process
+        // until its parent is in the tree.
+
+        std::set<pid_t> in_tree(pids);
+
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            in_tree.erase((*it)->pid);
+
+
+        while (not addition.empty()) {
+            procman_debug("looking for %d parents", int(addition.size()));
+            ProcList::iterator it(addition.begin());<--- Shadow variable
+
+            while (it != addition.end()) {
+                procman_debug("looking for %d's parent with ppid %d",
+                              int((*it)->pid), int((*it)->ppid));
+
+
+                // inserts the process in the treeview if :
+                // - it has no parent (ppid = -1),
+                //   ie it is for example the [kernel] on FreeBSD
+                // - it is init
+                // - its parent is already in tree
+                // - its parent is unreachable
+                //
+                // rounds == 2 means that addition contains processes with
+                // unreachable parents
+                //
+                // FIXME: this is broken if the unreachable parent becomes active
+                // i.e. it gets active or changes ower
+                // so we just clear the tree on __each__ update
+                // see proctable_update_list (ProcData * const procdata)
+
+
+                if ((*it)->ppid <= 0 or in_tree.find((*it)->ppid) != in_tree.end()) {
+                    insert_info_to_tree(*it, procdata);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ProcInfo *parent = ProcInfo::find((*it)->ppid);<--- Variable 'parent' can be declared as pointer to const
+                // if the parent is unreachable
+                if (not parent) {
+                    // or std::find(addition.begin(), addition.end(), parent) == addition.end()) {
+                    insert_info_to_tree(*it, procdata, true);
+                    in_tree.insert((*it)->pid);
+                    it = addition.erase(it);
+                    continue;
+                }
+
+                ++it;
+            }
+        }
+    }
+    else {
+        // don't care of the tree
+        for (ProcList::iterator it(addition.begin()); it != addition.end(); ++it)<--- Shadow variable
+            insert_info_to_tree(*it, procdata);
+    }
+
+
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)<--- Shadow variable
+        update_info_mutable_cols(it->second);
+}
+
+
+static void
+proctable_update_list (ProcData * const procdata)
+{
+    pid_t* pid_list;
+    glibtop_proclist proclist;
+    glibtop_cpu cpu;
+    gint which, arg;
+    procman::SelectionMemento selection;
+
+    switch (procdata->config.whose_process) {
+        case ALL_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL;
+            arg = 0;
+            break;
+
+        case ACTIVE_PROCESSES:
+            which = GLIBTOP_KERN_PROC_ALL | GLIBTOP_EXCLUDE_IDLE;
+            arg = 0;
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+
+        default:
+            which = GLIBTOP_KERN_PROC_UID;
+            arg = getuid ();
+            if (procdata->config.show_tree)
+            {
+                selection.save(procdata->tree);
+            }
+            break;
+    }
+
+    pid_list = glibtop_get_proclist (&proclist, which, arg);
+
+    /* FIXME: total cpu time elapsed should be calculated on an individual basis here
+    ** should probably have a total_time_last gint in the ProcInfo structure */
+    glibtop_get_cpu (&cpu);
+    procdata->cpu_total_time = MAX(cpu.total - procdata->cpu_total_time_last, 1);
+    procdata->cpu_total_time_last = cpu.total;
+
+    // FIXME: not sure if glibtop always returns a sorted list of pid
+    // but it is important otherwise refresh_list won't find the parent
+    std::sort(pid_list, pid_list + proclist.number);
+
+    refresh_list (procdata, pid_list, proclist.number);
+
+    selection.restore(procdata->tree);
+
+    g_free (pid_list);
+
+    /* proclist.number == g_list_length(procdata->info) == g_hash_table_size(procdata->pids) */
+}
+
+
+void
+proctable_update (ProcData * const procdata)
+{
+    char* string;
+
+    string = make_loadavg_string();
+    gtk_label_set_text (GTK_LABEL(procdata->loadavg), string);
+    g_free (string);
+
+    proctable_update_list (procdata);
+}
+
+
+void
+proctable_free_table (ProcData * const procdata)
+{
+    for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it)
+        delete it->second;
+
+    ProcInfo::all.clear();
+}
+
+
+void
+proctable_clear_tree (ProcData * const procdata)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model (GTK_TREE_VIEW (procdata->tree));
+
+    gtk_tree_store_clear (GTK_TREE_STORE (model));
+
+    proctable_free_table (procdata);
+
+    update_sensitivity(procdata);
+}
+
+
+char*
+make_loadavg_string(void)
+{
+    glibtop_loadavg buf;
+
+    glibtop_get_loadavg(&buf);
+
+    return g_strdup_printf(
+        _("Load averages for the last 1, 5, 15 minutes: "
+          "%0.2f, %0.2f, %0.2f"),
+        buf.loadavg[0],
+        buf.loadavg[1],
+        buf.loadavg[2]);
+}
+
+
+
+void
+ProcInfo::set_icon(Glib::RefPtr<Gdk::Pixbuf> icon)
+{
+  this->surface = gdk_cairo_surface_create_from_pixbuf (icon->gobj(), 0, NULL);
+
+  GtkTreeModel *model;
+  model = gtk_tree_view_get_model(GTK_TREE_VIEW(ProcData::get_instance()->tree));
+  gtk_tree_store_set(GTK_TREE_STORE(model), &this->node,
+                     COL_SURFACE, this->surface,
+                    -1);
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/43.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/43.html new file mode 100644 index 00000000..6671f8cd --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/43.html @@ -0,0 +1,279 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
#ifndef H_MATE_SYSTEM_MONITOR_SELECTION_H_1183113337
+#define H_MATE_SYSTEM_MONITOR_SELECTION_H_1183113337
+
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <vector><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+namespace procman
+{
+    class SelectionMemento
+    {
+        std::vector<pid_t> pids;
+        static void add_to_selected(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer data);
+
+    public:
+        void save(GtkWidget* tree);
+        void restore(GtkWidget* tree);
+    };
+}
+
+#endif /* H_MATE_SYSTEM_MONITOR_SELECTION_H_1183113337 */
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/44.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/44.html new file mode 100644 index 00000000..1093d32a --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/44.html @@ -0,0 +1,265 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
#ifndef PROCMAN_SELINUX_H_20050525
+#define PROCMAN_SELINUX_H_20050525
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "procman.h"
+
+void
+get_process_selinux_context (ProcInfo *info);
+
+gboolean
+can_show_security_context_column (void) G_GNUC_CONST;
+
+#endif /* PROCMAN_SELINUX_H_20050525 */
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/45.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/45.html new file mode 100644 index 00000000..dfb6b9b7 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/45.html @@ -0,0 +1,323 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "selection.h"
+#include "proctable.h"
+#include "util.h"
+
+namespace procman
+{
+    void SelectionMemento::add_to_selected(GtkTreeModel* model, GtkTreePath*, GtkTreeIter* iter, gpointer data)
+    {
+        guint pid = 0;
+        gtk_tree_model_get(model, iter, COL_PID, &pid, -1);
+        if (pid)
+            static_cast<SelectionMemento*>(data)->pids.push_back(pid);
+    }
+
+
+    void SelectionMemento::save(GtkWidget* tree)
+    {
+        GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
+        gtk_tree_selection_selected_foreach(selection, &SelectionMemento::add_to_selected, this);
+    }
+
+
+    void SelectionMemento::restore(GtkWidget* tree)
+    {
+        if (not this->pids.empty())
+        {
+            GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
+            typedef std::vector<pid_t>::iterator iterator;
+            for (iterator it(this->pids.begin()); it != this->pids.end(); ++it)
+            {
+                if (ProcInfo* proc = ProcInfo::find(*it))
+                {
+                    gtk_tree_selection_select_iter(selection, &proc->node);
+                    procman_debug("Re-selected process %u", unsigned(*it));
+                }
+                else
+                    procman_debug("Could not find process %u, cannot re-select it", unsigned(*it));
+            }
+        }
+    }
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/46.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/46.html new file mode 100644 index 00000000..1b7bdee1 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/46.html @@ -0,0 +1,405 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "selinux.h"
+#include "procman.h"
+#include "util.h"
+
+
+static int (*getpidcon)(pid_t, char**);
+static void (*freecon)(char*);
+static int (*is_selinux_enabled)(void);
+
+static gboolean has_selinux;
+
+static gboolean load_selinux(void)
+{
+    return load_symbols("libselinux.so.1",
+                        "getpidcon", &getpidcon,
+                        "freecon", &freecon,
+                        "is_selinux_enabled", &is_selinux_enabled,
+                        NULL);
+}
+
+
+
+void
+get_process_selinux_context (ProcInfo *info)
+{
+    char *con;
+
+    if (has_selinux && !getpidcon (info->pid, &con)) {
+        info->security_context = g_strdup (con);
+        freecon (con);
+    }
+}
+
+
+
+gboolean
+can_show_security_context_column (void)
+{
+    if (!(has_selinux = load_selinux()))
+        return FALSE;
+
+    switch (is_selinux_enabled()) {
+        case 1:
+            /* We're running on an SELinux kernel */
+            return TRUE;
+
+        case -1:
+            /* Error; hide the security context column */
+
+        case 0:
+            /* We're not running on an SELinux kernel:
+               hide the security context column */
+
+        default:
+            g_warning("SELinux was found but is not enabled.\n");
+            return FALSE;
+    }
+}
+
+
+
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/47.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/47.html new file mode 100644 index 00000000..2237890f --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/47.html @@ -0,0 +1,553 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/proctime.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/cpu.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <algorithm><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "smooth_refresh.h"
+#include "procman.h"
+#include "util.h"
+
+
+const string SmoothRefresh::KEY("smooth-refresh");
+
+
+unsigned SmoothRefresh::get_own_cpu_usage()
+{
+    glibtop_cpu cpu;
+    glibtop_proc_time proctime;
+    guint64 elapsed;
+    unsigned usage = PCPU_LO;
+
+    glibtop_get_cpu (&cpu);
+    elapsed = cpu.total - this->last_total_time;
+
+    if (elapsed) { // avoid division by 0
+        glibtop_get_proc_time(&proctime, getpid());
+        usage = (proctime.rtime - this->last_cpu_time) * 100 / elapsed;
+        this->last_cpu_time = proctime.rtime;
+    }
+
+    usage = MIN (usage, 100);
+
+    this->last_total_time = cpu.total;
+
+    return usage;
+}
+
+
+
+void SmoothRefresh::status_changed(GSettings *settings,
+                                   const gchar *key,
+                                   gpointer user_data)
+{
+    static_cast<SmoothRefresh*>(user_data)->load_settings_value(key);
+}
+
+void SmoothRefresh::load_settings_value(const gchar *key)
+{
+    this->active = g_settings_get_boolean(settings, key);
+
+    if (this->active)
+        procman_debug("smooth_refresh is enabled");
+}
+
+SmoothRefresh::SmoothRefresh(GSettings *a_settings)
+    :
+    settings(a_settings)
+{
+    this->connection = g_signal_connect(G_OBJECT(settings),
+                                        "changed::smooth-refresh",
+                                        G_CALLBACK(status_changed),
+                                        this);
+
+  this->reset();
+  this->load_settings_value(KEY.c_str());
+}
+
+
+
+void SmoothRefresh::reset()
+{
+    glibtop_cpu cpu;
+    glibtop_proc_time proctime;
+
+    glibtop_get_cpu(&cpu);
+    glibtop_get_proc_time(&proctime, getpid());
+
+    this->interval = ProcData::get_instance()->config.update_interval;
+    this->last_pcpu = PCPU_LO;
+    this->last_total_time = cpu.total;
+    this->last_cpu_time = proctime.rtime;
+}
+
+
+
+SmoothRefresh::~SmoothRefresh()
+{
+    if (this->connection)
+        g_signal_handler_disconnect(G_OBJECT(settings), this->connection);
+}
+
+
+
+bool
+SmoothRefresh::get(guint &new_interval)
+{
+    const unsigned config_interval = ProcData::get_instance()->config.update_interval;
+
+    g_assert(this->interval >= config_interval);
+
+    if (not this->active)
+        return false;
+
+
+    const unsigned pcpu = this->get_own_cpu_usage();
+    /*
+      invariant: MAX_UPDATE_INTERVAL >= interval >= config_interval >= MIN_UPDATE_INTERVAL
+
+      i see 3 cases:
+
+      a) interval is too big (CPU usage < 10%)
+      -> increase interval
+
+      b) interval is too small (CPU usage > 10%) AND interval != config_interval
+      >
+      -> decrease interval
+
+      c) interval is config_interval (start or interval is perfect)
+
+    */
+
+    if (pcpu > PCPU_HI && this->last_pcpu > PCPU_HI)
+        new_interval = this->interval * 11 / 10;
+    else if (this->interval != config_interval && pcpu < PCPU_LO && this->last_pcpu < PCPU_LO)
+        new_interval = this->interval * 9 / 10;
+    else
+        new_interval = this->interval;
+
+    new_interval = CLAMP(new_interval, config_interval, config_interval * 2);
+    new_interval = CLAMP(new_interval, MIN_UPDATE_INTERVAL, MAX_UPDATE_INTERVAL);
+
+    bool changed = this->interval != new_interval;
+
+    if (changed)
+        this->interval = new_interval;
+
+    this->last_pcpu = pcpu;
+
+
+    if (changed) {
+        procman_debug("CPU usage is %3u%%, changed refresh_interval to %u (config %u)",
+                      this->last_pcpu,
+                      this->interval,
+                      config_interval);
+    }
+
+    g_assert(this->interval == new_interval);
+    g_assert(this->interval >= config_interval);
+
+    return changed;
+}
+
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/48.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/48.html new file mode 100644 index 00000000..4fd13f6d --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/48.html @@ -0,0 +1,2359 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <libxml/parser.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libxml/xpath.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libxml/xpathInternals.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibtop/fsusage.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mountlist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/mem.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/sysinfo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <netdb.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/socket.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/wait.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <exception><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <vector><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <fstream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sstream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/utsname.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "sysinfo.h"
+#include "procman.h"
+#include "util.h"
+
+
+using std::string;
+using std::vector;
+
+
+namespace {
+
+    class SysInfo
+    {
+    public:
+        string hostname;
+        string distro_name;
+        string distro_release;
+        string kernel;
+        string mate_version;
+        guint64 memory_bytes;
+        guint64 free_space_bytes;
+
+        string graphics;
+        string processors;
+
+        SysInfo()
+        {
+            this->load_processors_info();
+            this->load_graphics_info();
+            this->load_memory_info();
+            this->load_disk_info();
+            this->load_uname_info();
+            this->load_mate_version();
+        }
+
+        virtual ~SysInfo()
+        { }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Virtual function in base class
+        {
+            g_object_set(G_OBJECT(name),
+                        "label",
+                        ("<big><big><b>" + this->distro_name + "</b></big></big>").c_str(),
+                        NULL);
+
+            char* markup;
+#ifdef __linux__
+            if (this->distro_release != "")
+            {
+                /* Translators: The first string parameter is release version (codename),
+                 * the second one is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("Release %s %s"),
+                                         this->distro_release.c_str(),
+                                         SysInfo::get_os_type().c_str());
+            }
+            else
+            {
+                /* Translators: The string parameter is the architecture, 32 or 64-bit */
+                markup = g_strdup_printf(_("%s Version"),
+                                         SysInfo::get_os_type().c_str());
+            }
+#else
+            /* Translators: The string parameter is release version (codename) */
+            markup = g_strdup_printf(_("Release %s"),
+                                     this->distro_release.c_str());
+#endif
+
+            g_object_set(G_OBJECT(release),
+                         "label",
+                         markup,
+                         NULL);
+
+            g_free(markup);
+        }
+
+        static string release()
+        {
+            return uname().release;
+        }
+
+        static string system()
+        {
+            return uname().sysname;
+        }
+
+    private:
+
+        void load_memory_info()
+        {
+            glibtop_mem mem;
+
+            glibtop_get_mem(&mem);
+            this->memory_bytes = mem.total;
+        }
+
+        static string get_os_type ()<--- Unused private function: 'SysInfo::get_os_type'
+        {
+            int bits;
+
+            if (GLIB_SIZEOF_VOID_P == 8)
+                bits = 64;
+            else
+                bits = 32;
+
+            /* translators: This is the type of architecture, for example:
+             * "64-bit" or "32-bit" */
+            char* bytes = g_strdup_printf (_("%d-bit"), bits);
+            string retval(bytes);
+            g_free(bytes);
+            return retval;
+        }
+
+        typedef struct
+        {
+            const char* regex;
+            const char* replacement;
+        } ReplaceStrings;
+
+        static char* remove_duplicate_whitespace (const char* old)
+        {
+            char* result;
+            GRegex* re;
+            GError* error = NULL;
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+
+            re = g_regex_new ("[ \t\n\r]+", G_REGEX_MULTILINE, flags, &error);
+            if (re == NULL) {
+                g_warning ("Error building regex: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+            result = g_regex_replace (re, old, -1, 0, " ", flags, &error);
+            g_regex_unref (re);
+            if (result == NULL) {
+                g_warning ("Error replacing string: %s", error->message);
+                g_error_free (error);
+                return g_strdup (old);
+            }
+
+            return result;
+        }
+
+        static char* prettify_info (const char *info)
+        {
+            char* pretty;
+            const GRegexCompileFlags cflags = static_cast<GRegexCompileFlags>(0);
+            const GRegexMatchFlags mflags = static_cast<GRegexMatchFlags>(0);
+
+            static const ReplaceStrings rs[] = {
+                { "Intel[(]R[)]", "Intel\302\256"},
+                { "Core[(]TM[)]", "Core\342\204\242"},
+                { "Atom[(]TM[)]", "Atom\342\204\242"},
+            };
+
+            pretty = g_markup_escape_text (info, -1);
+
+            for (uint i = 0; i < G_N_ELEMENTS (rs); i++) {
+                GError* error;
+                GRegex* re;
+                char* result;
+
+                error = NULL;
+
+                re = g_regex_new (rs[i].regex, cflags, mflags, &error);
+                if (re == NULL) {
+                    g_warning ("Error building regex: %s", error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                result = g_regex_replace_literal (re, pretty, -1, 0,
+                                             rs[i].replacement, mflags, &error);
+
+                g_regex_unref (re);
+
+                if (error != NULL) {
+                    g_warning ("Error replacing %s: %s", rs[i].regex, error->message);
+                    g_error_free (error);
+                    continue;
+                }
+
+                g_free (pretty);
+                pretty = result;
+            }
+
+            return pretty;
+        }
+
+        static char* get_renderer_from_helper (gboolean discrete_gpu)
+        {
+            int status;
+            const char *argv[] = { LIBEXECDIR "/mate-session-check-accelerated", NULL };
+            g_auto(GStrv) envp = NULL;
+            g_autofree char *renderer = NULL;
+            g_autoptr(GError) error = NULL;
+
+            if (discrete_gpu)
+            {
+                envp = g_get_environ ();
+                envp = g_environ_setenv (envp, "DRI_PRIME", "1", TRUE);
+            }
+
+            if (!g_spawn_sync (NULL, (char **) argv, envp, G_SPAWN_DEFAULT, NULL, NULL, &renderer, NULL, &status, &error))
+            {
+                g_debug ("Failed to get %s GPU: %s",
+                         discrete_gpu ? "discrete" : "integrated",
+                         error->message);
+                return NULL;
+            }
+
+            if (!g_spawn_check_exit_status (status, NULL))
+                return NULL;
+
+            if (renderer == NULL || *renderer == '\0')
+                return NULL;
+
+            return prettify_info (renderer);
+        }
+
+
+        void load_graphics_info()
+        {
+            g_autofree char *renderer = NULL;
+
+            try
+            {
+                g_autoptr(GDBusProxy) session_proxy = NULL;
+                g_autoptr(GVariant) renderer_variant = NULL;
+                g_autoptr(GError) error = NULL;
+
+                session_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                               G_DBUS_PROXY_FLAGS_NONE,
+                                                               NULL,
+                                                               "org.gnome.SessionManager",
+                                                               "/org/gnome/SessionManager",
+                                                               "org.gnome.SessionManager",
+                                                               NULL, &error);
+                if (error != NULL)
+                {
+                    throw std::runtime_error ("Unable to connect to create a proxy for org.gnome.SessionManager");
+                }
+
+                renderer_variant = g_dbus_proxy_get_cached_property (session_proxy, "Renderer");
+                if (!renderer_variant)
+                {
+                    throw std::runtime_error ("Unable to retrieve org.gnome.SessionManager.Renderer property.");
+                }
+
+                renderer = prettify_info (g_variant_get_string (renderer_variant, NULL));
+            }
+            catch (std::exception& e)
+            {
+                g_warning ("%s", e.what());
+            }
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (FALSE);
+
+            if (renderer == NULL)
+                renderer = get_renderer_from_helper (TRUE);
+
+            if (renderer)
+            {
+                this->graphics = g_strdup (renderer);
+            }
+            else
+            {
+                this->graphics = _("Unknown");
+            }
+        }
+
+        void load_processors_info()
+        {
+            const glibtop_sysinfo *info = glibtop_get_sysinfo();
+
+            GHashTable* counts;
+            GString* cpu;
+            GHashTableIter iter;
+            gpointer key, value;
+
+            counts = g_hash_table_new (g_str_hash, g_str_equal);
+
+            /* count duplicates */
+            for (uint i = 0; i != info->ncpu; ++i) {
+                const char* const keys[] = { "model name", "cpu", "Processor" };
+                char* model;
+                int* count;
+
+                model = NULL;
+
+                for (int j = 0; model == NULL && j != G_N_ELEMENTS (keys); ++j) {
+                    model = static_cast<char*>(g_hash_table_lookup (info->cpuinfo[i].values,
+                                                 keys[j]));
+                }
+
+                if (model == NULL)
+                    continue;
+
+                count = static_cast<int*>(g_hash_table_lookup (counts, model));
+                if (count == NULL)
+                    g_hash_table_insert (counts, model, GINT_TO_POINTER (1));
+                else
+                    g_hash_table_replace (counts, model, GINT_TO_POINTER (GPOINTER_TO_INT (count) + 1));
+            }
+
+            cpu = g_string_new (NULL);
+            g_hash_table_iter_init (&iter, counts);
+            while (g_hash_table_iter_next (&iter, &key, &value)) {
+                char* stripped;
+                int   count;
+
+                count = GPOINTER_TO_INT (value);
+                stripped = remove_duplicate_whitespace ((const char *)key);
+                if (count > 1)
+                    g_string_append_printf (cpu, "%s \303\227 %d ", stripped, count);
+                else
+                    g_string_append_printf (cpu, "%s ", stripped);
+                g_free (stripped);
+            }
+
+            g_hash_table_destroy (counts);
+            this->processors = string(prettify_info (cpu->str));
+            g_string_free (cpu, TRUE);
+        }
+
+        void load_disk_info()
+        {
+            GHashTable *devices;
+            glibtop_mountentry *entries;
+            glibtop_mountlist mountlist;
+
+            entries = glibtop_get_mountlist(&mountlist, 0);
+            devices = g_hash_table_new(g_str_hash, g_str_equal);
+            this->free_space_bytes = 0;
+
+            for (guint i = 0; i != mountlist.number; ++i) {
+                if ((string(entries[i].mountdir).compare("/") == 0) && \
+                    (string(entries[i].type).compare("zfs") == 0)) {
+                    // Root filesystem is ZFS based: Calculate usage based on "/".
+                    glibtop_fsusage usage;
+                    glibtop_get_fsusage(&usage, "/");
+                    this->free_space_bytes = usage.bavail * usage.block_size;
+                    break;
+                }
+
+                if (string(entries[i].devname).find("/dev/") != 0)
+                    continue;
+
+                if (string(entries[i].mountdir).find("/media/") == 0)
+                    continue;
+
+                /* avoid adding a device more than once such as for btrfs filesystem */
+                if (g_hash_table_contains (devices, entries[i].devname))
+                    continue;
+                else
+                    g_hash_table_insert (devices, entries[i].devname, entries[i].mountdir);
+
+                glibtop_fsusage usage;
+                glibtop_get_fsusage(&usage, entries[i].mountdir);
+                this->free_space_bytes += usage.bavail * usage.block_size;
+            }
+
+            g_hash_table_destroy (devices);
+            g_free(entries);
+        }
+
+        static const struct utsname & uname()
+        {
+            static struct utsname name;
+
+            if (!name.sysname[0]) {
+                ::uname(&name);
+            }
+
+            return name;
+        }
+
+        void load_uname_info()
+        {
+            this->hostname = uname().nodename;
+#if defined(__linux__)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().machine;
+#elif defined(__sun) && defined(__SVR4)
+            this->kernel = string(uname().sysname) + ' ' + uname().release + ' ' + uname().version + ' ' + uname().machine;
+#else
+            this->kernel = string(uname().version) + ' ' + uname().machine;
+#endif
+        }
+
+
+        void load_mate_version()
+        {
+            xmlDocPtr document;
+            xmlXPathContextPtr context;
+            const string nodes[3] = { "string(/mate-version/platform)",
+                                      "string(/mate-version/minor)",
+                                      "string(/mate-version/micro)" };
+            string values[3];
+
+            if (not (document = xmlParseFile(DATADIR "/mate-about/mate-version.xml")))
+                return;
+
+            if (not (context = xmlXPathNewContext(document)))
+                return;
+
+            for (size_t i = 0; i != 3; ++i)
+            {
+                xmlXPathObjectPtr xpath;
+                xpath = xmlXPathEvalExpression(BAD_CAST nodes[i].c_str(), context);
+
+                if (xpath and xpath->type == XPATH_STRING)
+                    values[i] = reinterpret_cast<const char*>(xpath->stringval);
+
+                xmlXPathFreeObject(xpath);
+            }
+
+            xmlXPathFreeContext(context);
+            xmlFreeDoc(document);
+
+            if (!values[0].empty() && !values[1].empty() && !values[2].empty())
+                this->mate_version = values[0] + '.' + values[1] + '.' + values[2];
+        }
+    };
+
+    class FreeBSDSysInfo
+        : public SysInfo
+    {
+    public:
+	FreeBSDSysInfo()
+        {
+            this->load_freebsd_info();
+        }
+
+    private:
+        void load_freebsd_info()
+        {
+            this->distro_name = "FreeBSD";
+            this->distro_release = release();
+        }
+    };
+
+    class SolarisSysInfo
+        : public SysInfo
+    {
+    public:
+        SolarisSysInfo()
+        {
+            this->load_solaris_info();
+        }
+
+    private:
+        void load_solaris_info()
+        {
+            std::ifstream input("/etc/release");
+
+            if (input) {
+                std::string s;
+                std::getline(input, s);
+                std::size_t found = s.find("OpenIndiana ");
+                if (found!=std::string::npos) {
+                    this->distro_name = "OpenIndiana";
+                    this->distro_release = s.substr(found + strlen("OpenIndiana "));
+                } else if (!s.empty()) {
+                    this->distro_release = s;
+                }
+            }
+
+            if (this->distro_release.empty()) {
+                this->distro_name = "Solaris";
+            }
+        }
+    };
+
+
+    class LSBSysInfo
+        : public SysInfo
+    {
+    public:
+        LSBSysInfo()
+            : re(Glib::Regex::create("^.+?:\\s*(.+)\\s*$"))
+        {
+            // start();
+        }
+
+        virtual void set_distro_labels(GtkWidget* name, GtkWidget* release)<--- Function in derived class
+        {
+            this->name = name;
+            this->release = release;
+
+            this->start();
+        }
+
+
+    private:
+
+        sigc::connection child_watch;
+        int lsb_fd;
+        GtkWidget* name;
+        GtkWidget* release;<--- Shadowed declaration<--- Shadowed declaration
+
+        void strip_description(string &s) const
+        {
+            const GRegexMatchFlags flags = static_cast<GRegexMatchFlags>(0);
+            GMatchInfo* info = 0;
+
+           if (g_regex_match(this->re->gobj(), s.c_str(), flags, &info)) {
+               s = make_string(g_match_info_fetch(info, 1));
+               g_match_info_free(info);
+           }
+        }
+
+        std::istream& get_value(std::istream &is, string &s) const
+        {
+            if (std::getline(is, s))
+                this->strip_description(s);
+            return is;
+        }
+
+
+        void read_lsb(Glib::Pid pid, int status)
+        {
+            this->child_watch.disconnect();
+
+            if (!WIFEXITED(status) or WEXITSTATUS(status) != 0) {
+                g_error("Child %d failed with status %d", int(pid), status);
+                return;
+            }
+
+            Glib::RefPtr<Glib::IOChannel> channel = Glib::IOChannel::create_from_fd(this->lsb_fd);
+            Glib::ustring content;
+
+            while (channel->read_to_end(content) == Glib::IO_STATUS_AGAIN)
+                ;
+
+            channel->close();
+            Glib::spawn_close_pid(pid);
+
+            procman_debug("lsb_release output = '%s'", content.c_str());
+
+            string release, codename;<--- Shadow variable
+            std::istringstream input(content);
+
+            this->get_value(input, this->distro_name)
+                and this->get_value(input, release)
+                and this->get_value(input, codename);
+
+            this->distro_release = release;
+            if (codename != "" && codename != "n/a")
+                this->distro_release += " (" + codename + ')';
+
+            this->SysInfo::set_distro_labels(this->name, this->release);
+        }
+
+
+        void start()
+        {
+            std::vector<string> argv(2);
+            argv[0] = "lsb_release";
+            argv[1] = "-irc";
+
+            Glib::SpawnFlags flags = Glib::SPAWN_DO_NOT_REAP_CHILD
+                | Glib::SPAWN_SEARCH_PATH
+                | Glib::SPAWN_STDERR_TO_DEV_NULL;
+
+            Glib::Pid child;
+
+            try {
+                Glib::spawn_async_with_pipes("/", // wd
+                                             argv,
+                                             flags,
+                                             sigc::slot<void>(), // child setup
+                                             &child,
+                                             0, // stdin
+                                             &this->lsb_fd); // stdout
+            } catch (Glib::SpawnError &e) {
+                g_error("g_spawn_async_with_pipes error: %s", e.what().c_str());
+                return;
+            }
+
+            sigc::slot<void,GPid, int> slot = sigc::mem_fun(this, &LSBSysInfo::read_lsb);
+            this->child_watch = Glib::signal_child_watch().connect(slot, child);
+        }
+
+
+        void sync_lsb_release()<--- Unused private function: 'LSBSysInfo::sync_lsb_release'
+        {
+            char *out= 0;
+            GError *error = 0;
+            int status;
+
+            if (g_spawn_command_line_sync("lsb_release -irc",
+                                          &out,
+                                          0,
+                                          &status,
+                                          &error)) {
+                string release, codename;<--- Shadow variable
+                if (!error and WIFEXITED(status) and WEXITSTATUS(status) == 0) {
+                    std::istringstream input(out);
+                    this->get_value(input, this->distro_name)
+                        and this->get_value(input, release)
+                        and this->get_value(input, codename);
+                    this->distro_release = release;
+                if (codename != "" && codename != "n/a")
+                    this->distro_release += " (" + codename + ')';
+                }
+            }
+
+            if (error)
+                g_error_free(error);
+
+            g_free(out);
+        }
+
+    private:
+        Glib::RefPtr<Glib::Regex> re;
+    };
+
+
+    class NetBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        NetBSDSysInfo()
+        {
+            this->load_netbsd_info();
+        }
+
+    private:
+        void load_netbsd_info()
+        {
+            this->distro_name = "NetBSD";
+
+            std::ifstream input("/etc/release");
+
+            if (input)
+                std::getline(input, this->distro_release);
+        }
+    };
+
+
+    class GenericSysInfo
+        : public SysInfo
+    {
+    public:
+        GenericSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            std::ifstream input("/etc/os-release");
+
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int start;
+                    std::getline(input, s);
+                    if (s.find("NAME=") == 0) {
+                        start = strlen("NAME=");
+                        if ((s.at(start) == '\"') && (s.at(s.size() - 1) == '\"')) {
+                            this->distro_name = s.substr(start + 1, s.size() - start - 2);
+                        } else {
+                            this->distro_name = s.substr(start);
+                        }
+                    } else if (s.find("VERSION=") == 0) {
+                        start = strlen("VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    } else if (s.find("# VERSION=") == 0) {
+                        start = strlen("# VERSION=");
+                        // also strip the surrounding quotes
+                        this->distro_release = s.substr(start + 1, s.size() - start - 2);
+                    }
+                }
+                input.close();
+                input.clear();
+            }
+            if (this->distro_release.empty()) {
+                input.open("/etc/debian_version");
+                if (input) {
+                    getline(input, this->distro_release);
+                }
+            }
+        }
+    };
+
+    class MintSysInfo
+        : public SysInfo
+    {
+    public:
+        MintSysInfo()
+        {
+            this->load_os_release();
+        }
+
+    private:
+        void load_os_release()
+        {
+            this->distro_name = "Linux Mint";
+            std::ifstream input("/etc/linuxmint/info");
+            if (input) {
+                while (!input.eof()) {
+                    string s;
+                    int len;
+                    std::getline(input, s);
+                    if (s.find("DESCRIPTION=") == 0) {
+                        len = strlen("DESCRIPTION=");
+                        // also strip the surrounding quotes
+                       this->distro_release = s.substr(len + 1, s.size() - len - 2);
+                   }
+                }
+            }
+        }
+    };
+
+    class OpenBSDSysInfo
+        : public SysInfo
+    {
+    public:
+        OpenBSDSysInfo()
+        {
+            this->load_openbsd_info();
+        }
+
+    private:
+        void load_openbsd_info()
+        {
+            this->distro_name = "OpenBSD";
+            this->distro_release = this->kernel;
+
+            std::ifstream input("/etc/motd");
+
+            if (input)
+                std::getline(input, this->kernel);
+        }
+    };
+
+    SysInfo* get_sysinfo()
+    {
+        if (g_file_test ("/etc/linuxmint/info", G_FILE_TEST_EXISTS)) {
+            return new MintSysInfo;
+        }
+        else if (g_file_test ("/etc/os-release", G_FILE_TEST_EXISTS)) {
+            return new GenericSysInfo;
+        }
+        else if (char *p = g_find_program_in_path("lsb_release")) {
+            g_free(p);
+            return new LSBSysInfo;
+        }
+        else if (SysInfo::system() == "FreeBSD") {
+            return new FreeBSDSysInfo;
+        }
+        else if (SysInfo::system() == "SunOS") {
+            return new SolarisSysInfo;
+        }
+        else if (SysInfo::system() == "NetBSD") {
+            return new NetBSDSysInfo;
+        }
+        else if (SysInfo::system() == "OpenBSD") {
+            return new OpenBSDSysInfo;
+        }
+
+        return new SysInfo;
+    }
+}
+
+
+#define X_PAD  0
+#define Y_PAD  0
+#define LOGO_W 92
+#define LOGO_H 351
+#define RADIUS 5
+
+static gboolean sysinfo_logo_draw (GtkWidget *widget, cairo_t *context, gpointer data_ptr)
+{
+    GtkAllocation allocation;
+    GtkStyle *style;
+    cairo_t *cr;
+    cairo_pattern_t *cp;
+
+    cr = gdk_cairo_create(gtk_widget_get_window(widget));
+
+    gtk_widget_get_allocation (widget, &allocation);
+    cairo_translate(cr, allocation.x, allocation.y);
+
+    cairo_move_to(cr, X_PAD + RADIUS, Y_PAD);
+    cairo_line_to(cr, X_PAD + LOGO_W - RADIUS, Y_PAD);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + RADIUS, RADIUS, -0.5 * M_PI, 0);
+    cairo_line_to(cr, X_PAD + LOGO_W, Y_PAD + LOGO_H - RADIUS);
+    cairo_arc(cr, X_PAD + LOGO_W - RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0, 0.5 * M_PI);
+    cairo_line_to(cr, X_PAD + RADIUS, Y_PAD + LOGO_H);
+    cairo_arc(cr, X_PAD + RADIUS, Y_PAD + LOGO_H - RADIUS, RADIUS, 0.5 * M_PI, -1.0 * M_PI);
+    cairo_line_to(cr, X_PAD, Y_PAD + RADIUS);
+    cairo_arc(cr,  X_PAD + RADIUS, Y_PAD + RADIUS, RADIUS, -1.0 * M_PI, -0.5 * M_PI);
+
+    cp = cairo_pattern_create_linear(0, Y_PAD, 0, Y_PAD + LOGO_H);
+    style = gtk_widget_get_style (widget);
+    cairo_pattern_add_color_stop_rgba(cp, 0.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      1.0);
+    cairo_pattern_add_color_stop_rgba(cp, 1.0,
+                                      style->base[GTK_STATE_SELECTED].red / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].green / 65535.0,
+                                      style->base[GTK_STATE_SELECTED].blue / 65535.0,
+                                      0.0);
+    cairo_set_source(cr, cp);
+    cairo_fill(cr);
+
+    cairo_pattern_destroy(cp);
+    cairo_destroy(cr);
+
+    return FALSE;
+}
+
+static GtkWidget*
+add_section(GtkBox *vbox , const char * title, int num_row, int num_col, GtkWidget **out_frame)
+{
+    GtkWidget *table;
+
+    GtkWidget *frame = gtk_frame_new(title);
+    gtk_frame_set_label_align(GTK_FRAME(frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
+
+    table = gtk_grid_new();
+    gtk_grid_set_row_spacing(GTK_GRID(table), 6);
+    gtk_grid_set_column_spacing(GTK_GRID(table), 6);
+    gtk_widget_set_margin_start (GTK_WIDGET(table), 12);
+    gtk_container_set_border_width(GTK_CONTAINER(table), 6);
+    gtk_container_add(GTK_CONTAINER(frame), table);
+
+    if(out_frame)
+        *out_frame = frame;
+
+    return table;
+}
+
+
+static GtkWidget*
+add_row(GtkGrid * table, const char * label, const char * value, int row)
+{
+    GtkWidget *header = gtk_label_new(NULL);
+    gtk_label_set_markup(GTK_LABEL(header), label);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        table, header,
+        0, row, 1, 1);
+
+    GtkWidget *label_widget = gtk_label_new(value);
+    gtk_label_set_selectable(GTK_LABEL(label_widget), TRUE);
+    gtk_widget_set_can_focus(label_widget, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (label_widget), 0.0);
+    gtk_grid_attach(
+        table, label_widget,
+        1, row, 1, 1);
+
+    return label_widget;
+}
+
+
+static GtkWidget *
+procman_create_sysinfo_view(void)
+{
+    GtkWidget *hbox;
+    GtkWidget *vbox;
+
+    SysInfo *data = get_sysinfo();;
+
+    GtkWidget * logo;
+
+    GtkWidget *distro_frame;
+    GtkWidget *distro_release_label;
+    GtkWidget *distro_table;
+
+    GtkWidget *hardware_table;
+    GtkWidget *disk_space_table;
+
+    GtkWidget *header;
+
+    gchar *markup;
+
+    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);
+
+    /* left-side logo */
+    if (g_file_test (DATADIR "/pixmaps/mate-system-monitor/distribution/side.png", G_FILE_TEST_EXISTS)) {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/distribution/side.png");
+    }
+    else {
+        logo = gtk_image_new_from_file(DATADIR "/pixmaps/mate-system-monitor/side.png");
+    }
+    gtk_widget_set_valign (logo, GTK_ALIGN_START);
+    gtk_widget_set_margin_start (logo, 5);
+    gtk_widget_set_margin_end (logo, 5);
+    gtk_widget_set_margin_top (logo, 12);
+    gtk_widget_set_margin_bottom (logo, 12);
+    gtk_box_pack_start(GTK_BOX(hbox), logo, FALSE, FALSE, 0);
+
+    g_signal_connect(G_OBJECT(logo), "draw", G_CALLBACK(sysinfo_logo_draw), NULL);
+
+    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+    gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
+    gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
+
+    // hostname
+
+    markup = g_strdup_printf("<big><big><b><u>%s</u></b></big></big>",
+                             data->hostname.c_str());
+    GtkWidget *hostname_frame = gtk_frame_new(markup);
+    g_free(markup);
+    gtk_frame_set_label_align(GTK_FRAME(hostname_frame), 0.0, 0.5);
+    gtk_label_set_use_markup(
+        GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(hostname_frame))),
+        TRUE
+        );
+    gtk_frame_set_shadow_type(GTK_FRAME(hostname_frame), GTK_SHADOW_NONE);
+    gtk_box_pack_start(GTK_BOX(vbox), hostname_frame, FALSE, FALSE, 0);
+
+
+    /* distro section */
+
+    unsigned table_size = 2;
+    if (data->mate_version != "")
+        table_size++;
+    distro_table = add_section(GTK_BOX(vbox), "???", table_size, 1, &distro_frame);
+
+    unsigned table_count = 0;
+
+    distro_release_label = gtk_label_new("???");
+    gtk_label_set_selectable(GTK_LABEL(distro_release_label), TRUE);
+    gtk_widget_set_can_focus(distro_release_label, FALSE);
+    gtk_label_set_xalign (GTK_LABEL (distro_release_label), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), distro_release_label,
+        0, table_count, 1, 1);
+    table_count++;
+    data->set_distro_labels(gtk_frame_get_label_widget(GTK_FRAME(distro_frame)), distro_release_label);
+
+    markup = g_strdup_printf(_("Kernel %s"), data->kernel.c_str());
+    header = gtk_label_new(markup);
+    gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+    gtk_widget_set_can_focus(header, FALSE);
+    g_free(markup);
+    gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+    gtk_grid_attach(
+        GTK_GRID(distro_table), header,
+        0, table_count, 1, 1);
+    table_count++;
+
+    if (data->mate_version != "")
+    {
+        markup = g_strdup_printf(_("MATE %s"), data->mate_version.c_str());
+        header = gtk_label_new(markup);
+        gtk_label_set_selectable(GTK_LABEL(header), TRUE);
+        gtk_widget_set_can_focus(header, FALSE);
+        g_free(markup);
+        gtk_label_set_xalign (GTK_LABEL (header), 0.0);
+        gtk_grid_attach(
+            GTK_GRID(distro_table), header,
+            0, table_count, 1, 1);
+        table_count++;<--- Variable 'table_count' is assigned a value that is never used.
+    }
+
+    /* hardware section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("Hardware"));
+    hardware_table = add_section(GTK_BOX(vbox), markup, 1, 3, NULL);
+    g_free(markup);
+
+    markup = g_format_size_full(data->memory_bytes, G_FORMAT_SIZE_IEC_UNITS);
+    add_row(GTK_GRID(hardware_table), _("Memory:"), markup, 0);
+    g_free(markup);
+
+    add_row(GTK_GRID(hardware_table), _("Processor:"),
+            data->processors.c_str(), 1);
+    add_row(GTK_GRID(hardware_table), _("Graphics:"),
+            data->graphics.c_str(), 2);
+
+    /* disk space section */
+
+    markup = g_strdup_printf("<b>%s</b>", _("System Status"));
+    disk_space_table = add_section(GTK_BOX(vbox), markup, 1, 2, NULL);
+    g_free(markup);
+
+    markup = g_format_size(data->free_space_bytes);
+    add_row(GTK_GRID(disk_space_table), _("Available disk space:"), markup, 0);
+    g_free(markup);
+
+    return hbox;
+}
+
+
+
+namespace procman
+{
+    void build_sysinfo_ui()
+    {
+        static GtkWidget* ui;
+
+        if (!ui) {
+            ProcData* procdata = ProcData::get_instance();
+            ui = procman_create_sysinfo_view();
+            GtkBox* box = GTK_BOX(gtk_notebook_get_nth_page(GTK_NOTEBOOK(procdata->notebook),
+                                                            PROCMAN_TAB_SYSINFO));
+            gtk_box_pack_start(box, ui, TRUE, TRUE, 0);
+            gtk_widget_show_all(ui);
+        }
+    }
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/49.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/49.html new file mode 100644 index 00000000..9c6b1942 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/49.html @@ -0,0 +1,1557 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gprintf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glibtop/proctime.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibtop/procstate.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <stddef.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <cstring><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "util.h"
+#include "procman.h"
+
+gchar *
+procman_format_date_for_display(time_t time_raw)
+{
+    gchar *result = NULL;
+    const char *format;
+    GDateTime *date_time, *today;
+    GTimeSpan date_age;
+
+    date_time = g_date_time_new_from_unix_local (time_raw);
+    today = g_date_time_new_now_local ();
+
+    date_age = g_date_time_difference (today, date_time);
+    if (date_age < G_TIME_SPAN_DAY) {
+        format = _("Today %l:%M %p");
+    } else if (date_age < 2 * G_TIME_SPAN_DAY) {
+        format = _("Yesterday %l:%M %p");
+    } else if (date_age < 7 * G_TIME_SPAN_DAY) {
+        format = _("%a %l:%M %p");
+    } else if (g_date_time_get_year (date_time) == g_date_time_get_year (today)) {
+        format = _("%b %d %l:%M %p");
+    } else {
+	format = _("%b %d %Y");
+    }
+
+    g_date_time_unref (today);
+    result = g_date_time_format (date_time, format);
+    g_date_time_unref (date_time);
+
+    return result;
+}
+
+const char*
+format_process_state(guint state)
+{
+    const char *status;
+
+    switch (state)
+        {
+        case GLIBTOP_PROCESS_RUNNING:
+            status = _("Running");
+            break;
+
+        case GLIBTOP_PROCESS_STOPPED:
+            status = _("Stopped");
+            break;
+
+        case GLIBTOP_PROCESS_ZOMBIE:
+            status = _("Zombie");
+            break;
+
+        case GLIBTOP_PROCESS_UNINTERRUPTIBLE:
+            status = _("Uninterruptible");
+            break;
+
+        default:
+            status = _("Sleeping");
+            break;
+        }
+
+    return status;
+}
+
+
+
+static char *
+mnemonic_safe_process_name(const char *process_name)
+{
+    const char *p;
+    GString *name;
+
+    name = g_string_new ("");
+
+    for(p = process_name; *p; ++p)
+    {
+        g_string_append_c (name, *p);
+
+        if(*p == '_')
+            g_string_append_c (name, '_');
+    }
+
+    return g_string_free (name, FALSE);
+}
+
+
+
+static inline unsigned divide(unsigned *q, unsigned *r, unsigned d)
+{
+    *q = *r / d;
+    *r = *r % d;
+    return *q != 0;
+}
+
+
+/*
+ * @param d: duration in centiseconds
+ * @type d: unsigned
+ */
+gchar *
+procman::format_duration_for_display(unsigned centiseconds)
+{
+    unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
+
+    (void)(divide(&seconds, &centiseconds, 100)
+           && divide(&minutes, &seconds, 60)
+           && divide(&hours, &minutes, 60)
+           && divide(&days, &hours, 24)
+           && divide(&weeks, &days, 7));
+
+    if (weeks)
+        /* xgettext: weeks, days */
+        return g_strdup_printf(_("%uw%ud"), weeks, days);
+
+    if (days)
+        /* xgettext: days, hours (0 -> 23) */
+        return g_strdup_printf(_("%ud%02uh"), days, hours);
+
+    if (hours)
+        /* xgettext: hours (0 -> 23), minutes, seconds */
+        return g_strdup_printf(_("%u:%02u:%02u"), hours, minutes, seconds);
+
+    /* xgettext: minutes, seconds, centiseconds */
+    return g_strdup_printf(_("%u:%02u.%02u"), minutes, seconds, centiseconds);
+}
+
+
+
+GtkWidget*
+procman_make_label_for_mmaps_or_ofiles(const char *format,
+                                       const char *process_name,
+                                       unsigned pid)
+{
+    GtkWidget *label;
+    char *name, *title;
+
+    name = mnemonic_safe_process_name (process_name);
+    title = g_strdup_printf(format, name, pid);
+    label = gtk_label_new_with_mnemonic (title);
+    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+
+    g_free (title);
+    g_free (name);
+
+    return label;
+}
+
+gchar *
+procman::get_nice_level (gint nice)
+{
+    if (nice < -7)
+        return _("Very High");
+    else if (nice < -2)
+        return _("High");
+    else if (nice < 3)
+        return _("Normal");
+    else if (nice < 7)
+        return _("Low");
+    else
+        return _("Very Low");
+}
+
+
+gboolean
+load_symbols(const char *module, ...)
+{
+    GModule *mod;
+    gboolean found_all = TRUE;
+    va_list args;
+
+    mod = g_module_open(module, static_cast<GModuleFlags>(G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL));
+
+    if (!mod)
+        return FALSE;
+
+    procman_debug("Found %s", module);
+
+    va_start(args, module);
+
+    while (1) {
+        const char *name;
+        void **symbol;
+
+        name = va_arg(args, char*);
+
+        if (!name)
+            break;
+
+        symbol = va_arg(args, void**);
+
+        if (g_module_symbol(mod, name, symbol)) {
+            procman_debug("Loaded %s from %s", name, module);
+        }
+        else {
+            procman_debug("Could not load %s from %s", name, module);
+            found_all = FALSE;
+            break;
+        }
+    }
+
+    va_end(args);
+
+
+    if (found_all)
+        g_module_make_resident(mod);
+    else
+        g_module_close(mod);
+
+    return found_all;
+}
+
+
+static gboolean
+is_debug_enabled(void)
+{
+    static gboolean init;
+    static gboolean enabled;
+
+    if (!init) {
+        enabled = g_getenv("MATE_SYSTEM_MONITOR_DEBUG") != NULL;
+        init = TRUE;
+    }
+
+    return enabled;
+}
+
+
+#if GLIB_CHECK_VERSION(2,61,2)
+static gint64
+get_relative_time(void)
+{
+    static unsigned long start_time;
+    gint64 tv;
+
+    if (G_UNLIKELY(!start_time)) {
+        glibtop_proc_time buf;
+        glibtop_get_proc_time(&buf, getpid());
+        start_time = buf.start_time;
+    }
+
+    tv = g_get_real_time ();
+    return tv - (gint64) start_time;
+}
+#else
+static double
+get_relative_time(void)
+{
+    static unsigned long start_time;
+    GTimeVal tv;
+
+    if (G_UNLIKELY(!start_time)) {
+        glibtop_proc_time buf;
+        glibtop_get_proc_time(&buf, getpid());
+        start_time = buf.start_time;
+    }
+
+    g_get_current_time(&tv);
+    return (tv.tv_sec - start_time) + 1e-6 * tv.tv_usec;
+}
+#endif
+
+static guint64
+get_size_from_column(GtkTreeModel* model, GtkTreeIter* first,
+                             const guint index)
+{
+    GValue value = { 0 };
+    gtk_tree_model_get_value(model, first, index, &value);
+
+    guint64 size;
+    switch (G_VALUE_TYPE(&value)) {
+        case G_TYPE_UINT:
+            size = g_value_get_uint(&value);
+            break;
+        case G_TYPE_ULONG:
+            size = g_value_get_ulong(&value);
+            break;
+        case G_TYPE_UINT64:
+            size = g_value_get_uint64(&value);
+            break;
+        default:
+            g_assert_not_reached();
+    }
+
+    g_value_unset(&value);
+    return size;
+}
+
+void
+procman_debug_real(const char *file, int line, const char *func,
+                   const char *format, ...)
+{
+    va_list args;
+    char *msg;
+
+    if (G_LIKELY(!is_debug_enabled()))
+        return;
+
+    va_start(args, format);
+    msg = g_strdup_vprintf(format, args);
+    va_end(args);
+
+#if GLIB_CHECK_VERSION(2,61,2)
+    g_debug("[%li %s:%d %s] %s", get_relative_time(), file, line, func, msg);
+#else
+    g_debug("[%.3f %s:%d %s] %s", get_relative_time(), file, line, func, msg);
+#endif
+    g_free(msg);
+}
+
+
+
+namespace procman
+{
+    void memory_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                    GtkTreeModel *model, GtkTreeIter *iter,
+                                    gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+            case G_TYPE_UINT64:
+                size = g_value_get_uint64(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
+        g_object_set(renderer, "text", str, NULL);
+        g_free(str);
+    }
+
+    /*
+      Same as above but handles size == 0 as not available
+     */
+    void memory_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                       GtkTreeModel *model, GtkTreeIter *iter,
+                                       gpointer user_data)
+    {
+     	const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+          case G_TYPE_UINT64:
+              size = g_value_get_uint64(&value);
+              break;
+
+          default:
+              g_assert_not_reached();
+        }
+
+	g_value_unset(&value);
+
+        if (size == 0) {
+            char *str = g_strdup_printf ("<i>%s</i>", _("N/A"));
+            g_object_set(renderer, "markup", str, NULL);
+            g_free(str);
+        }
+	else {
+            char *str = g_format_size_full(size, G_FORMAT_SIZE_IEC_UNITS);
+            g_object_set(renderer, "text", str, NULL);
+            g_free(str);
+        }
+    }
+
+    void storage_size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                     GtkTreeModel *model, GtkTreeIter *iter,
+                                     gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+            case G_TYPE_UINT64:
+                size = g_value_get_uint64(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        char *str = g_format_size(size);
+        g_object_set(renderer, "text", str, NULL);
+        g_free(str);
+    }
+
+    /*
+      Same as above but handles size == 0 as not available
+     */
+    void storage_size_na_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
+                                        GtkTreeModel *model, GtkTreeIter *iter,
+                                        gpointer user_data)
+    {
+     	const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+          case G_TYPE_UINT64:
+              size = g_value_get_uint64(&value);
+              break;
+
+          default:
+              g_assert_not_reached();
+        }
+
+	g_value_unset(&value);
+
+        if (size == 0) {
+            char *str = g_strdup_printf ("<i>%s</i>", _("N/A"));
+            g_object_set(renderer, "markup", str, NULL);
+            g_free(str);
+        }
+	else {
+            char *str = g_format_size(size);
+            g_object_set(renderer, "text", str, NULL);
+            g_free(str);
+        }
+    }
+
+    void io_rate_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                                GtkTreeModel *model, GtkTreeIter *iter,
+                                gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                size = g_value_get_ulong(&value);
+                break;
+
+            case G_TYPE_UINT64:
+                size = g_value_get_uint64(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        if (size == 0) {
+            char *str = g_strdup_printf ("<i>%s</i>", _("N/A"));
+            g_object_set(renderer, "markup", str, NULL);
+            g_free(str);
+        }
+        else {
+            char *str = g_format_size(size);
+            char *formatted_str = g_strdup_printf(_("%s/s"), str);
+            g_object_set(renderer, "text", formatted_str, NULL);
+            g_free(formatted_str);
+            g_free(str);
+        }
+
+    }
+
+    void duration_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                                 GtkTreeModel *model, GtkTreeIter *iter,
+                                 gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        unsigned time;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+            time = g_value_get_ulong(&value);
+            break;
+
+            case G_TYPE_UINT64:
+                time = g_value_get_uint64(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        time = 100 * time / ProcData::get_instance()->frequency;
+        char *str = format_duration_for_display(time);
+        g_object_set(renderer, "text", str, NULL);
+        g_free(str);
+    }
+
+
+    void time_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                             GtkTreeModel *model, GtkTreeIter *iter,
+                             gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        time_t time;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_ULONG:
+                time = g_value_get_ulong(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        gchar *str = procman_format_date_for_display(time);
+        g_object_set(renderer, "text", str, NULL);
+        g_free(str);
+    }
+
+    void status_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                               GtkTreeModel *model, GtkTreeIter *iter,
+                               gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint state;
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        switch (G_VALUE_TYPE(&value)) {
+            case G_TYPE_UINT:
+                state = g_value_get_uint(&value);
+                break;
+
+            default:
+                g_assert_not_reached();
+        }
+
+        g_value_unset(&value);
+
+        const char *str = format_process_state(state);
+        g_object_set(renderer, "text", str, NULL);
+    }
+
+    void priority_cell_data_func(GtkTreeViewColumn *, GtkCellRenderer *renderer,
+                             GtkTreeModel *model, GtkTreeIter *iter,
+                             gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        GValue value = { 0 };
+
+        gtk_tree_model_get_value(model, iter, index, &value);
+
+        gint priority = g_value_get_int(&value);
+
+        g_value_unset(&value);
+
+        g_object_set(renderer, "text", procman::get_nice_level(priority), NULL);
+
+    }
+
+    gint priority_compare_func(GtkTreeModel* model, GtkTreeIter* first,
+                            GtkTreeIter* second, gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+        GValue value1 = { 0 };
+        GValue value2 = { 0 };
+        gtk_tree_model_get_value(model, first, index, &value1);
+        gtk_tree_model_get_value(model, second, index, &value2);
+        gint result = g_value_get_int(&value1) - g_value_get_int(&value2);
+        g_value_unset(&value1);
+        g_value_unset(&value2);
+        return result;
+    }
+
+    gint number_compare_func(GtkTreeModel* model, GtkTreeIter* first,
+                            GtkTreeIter* second, gpointer user_data)
+    {
+        const guint index = GPOINTER_TO_UINT(user_data);
+
+        guint64 size1, size2;
+        size1 = get_size_from_column(model, first, index);
+        size2 = get_size_from_column(model, second, index);
+
+        if ( size2 > size1 )
+            return 1;
+        else if ( size2 < size1 )
+            return -1;
+        return 0;
+    }
+
+    template<>
+    void tree_store_update<const char>(GtkTreeModel* model, GtkTreeIter* iter, int column, const char* new_value)
+    {
+        char* current_value;
+
+        gtk_tree_model_get(model, iter, column, &current_value, -1);
+
+        if (g_strcmp0(current_value, new_value) != 0)
+            gtk_tree_store_set(GTK_TREE_STORE(model), iter, column, new_value, -1);
+
+        g_free(current_value);
+    }
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/5.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/5.html new file mode 100644 index 00000000..76126381 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/5.html @@ -0,0 +1,435 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
#ifndef _PROCMAN_SMOOTH_REFRESH
+#define _PROCMAN_SMOOTH_REFRESH
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+using std::string;
+
+class SmoothRefresh
+{
+  public:
+
+    /*
+      smooth_refresh_new
+
+      @config_interval : pointer to config_interval so we can observe
+      config_interval changes.
+
+      @return : initialized SmoothRefresh
+    */
+    SmoothRefresh(GSettings *a_settings);
+
+    ~SmoothRefresh();
+
+    /*
+      smooth_refresh_reset
+
+      Resets state and re-read config_interval
+    */
+    void reset();
+
+    /*
+      smooth_refresh_get
+
+      Computes the new refresh_interval so that CPU usage is lower than
+      SMOOTH_REFRESH_PCPU.
+
+      @new_interval : where the new refresh_interval is stored.
+
+      @return : TRUE is refresh_interval has changed. The new refresh_interval
+      is stored in @new_interval. Else FALSE;
+    */
+    bool get(guint &new_interval);
+
+    static const string KEY;
+    static const bool KEY_DEFAULT_VALUE;
+
+  private:
+
+    unsigned get_own_cpu_usage();
+
+    static void status_changed(GSettings *settings,
+                               const gchar *key,
+                               gpointer user_data);
+
+    void load_settings_value(const gchar *key);
+
+    /*
+      fuzzy logic:
+      - decrease refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_LO
+      - increase refresh interval only if current CPU% and last CPU%
+      are higher than PCPU_HI
+
+    */
+
+    enum
+    {
+        PCPU_HI = 22,
+        PCPU_LO = 18
+    };
+
+    /*
+      -self : procman's PID (so we call getpid() only once)
+
+      -interval : current refresh interval
+
+      -config_interval : pointer to the configuration refresh interval.
+      Used to watch configuration changes
+
+      -interval >= -config_interval
+
+      -last_pcpu : to avoid spikes, the last CPU%. See PCPU_{LO,HI}
+
+      -last_total_time:
+      -last_cpu_time: Save last cpu and process times to compute CPU%
+    */
+
+    GSettings *settings;
+    bool active;
+    guint connection;
+    guint interval;
+    unsigned  last_pcpu;
+    guint64 last_total_time;
+    guint64 last_cpu_time;
+};
+
+#endif /* _PROCMAN_SMOOTH_REFRESH */
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/50.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/50.html new file mode 100644 index 00000000..c36573fc --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/50.html @@ -0,0 +1,275 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+int main(int argc, char* argv[])<--- Parameter 'argv' can be declared as const array
+{
+    gchar **argv_modified = g_new0 (gchar *, (size_t)(argc + 1));
+    memcpy (argv_modified, argv, (size_t)(argc) * sizeof (char*));
+    argv_modified[0] = COMMAND;
+    int errsv = 0;
+
+    if (execvp (COMMAND, argv_modified) == -1) {
+        errsv = errno;
+    }
+
+    g_free (argv_modified);
+    return errsv;
+}
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/6.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/6.html new file mode 100644 index 00000000..3b0462a2 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/6.html @@ -0,0 +1,385 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
// -*- c++ -*-
+
+#ifndef _PROCMAN_PRETTYTABLE_H_
+#define _PROCMAN_PRETTYTABLE_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk-pixbuf/gdk-pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/refptr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdkmm/pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <giomm/filemonitor.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <map><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef HAVE_WNCK
+extern "C" {
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+}
+#endif
+
+#include "iconthemewrapper.h"
+
+class ProcInfo;
+
+using std::string;
+
+class PrettyTable
+{
+ public:
+    PrettyTable();
+    ~PrettyTable();
+
+    void set_icon(ProcInfo &);
+
+private:
+
+#ifdef HAVE_WNCK
+    static void on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_opened'
+    static void on_application_closed(WnckScreen* screen, WnckApplication* app, gpointer data);<--- Unused private function: 'PrettyTable::on_application_closed'
+
+    void register_application(pid_t pid, Glib::RefPtr<Gdk::Pixbuf> icon);
+    void unregister_application(pid_t pid);
+#endif
+
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_theme(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_default(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_gio(const ProcInfo &);
+#ifdef HAVE_WNCK
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_wnck(const ProcInfo &);
+#endif
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_name(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_for_kernel(const ProcInfo &);
+    Glib::RefPtr<Gdk::Pixbuf> get_icon_dummy(const ProcInfo &);
+
+    bool get_default_icon_name(const string &cmd, string &name);
+    void file_monitor_event (Glib::RefPtr<Gio::File>,
+                             Glib::RefPtr<Gio::File>,
+                             Gio::FileMonitorEvent);
+    void init_gio_app_cache ();
+
+    typedef std::map<string, Glib::RefPtr<Gdk::Pixbuf> > IconCache;
+    typedef std::map<pid_t, Glib::RefPtr<Gdk::Pixbuf> > IconsForPID;
+    typedef std::map<string, Glib::RefPtr<Gio::AppInfo> > AppCache;
+    typedef std::map<string, Glib::RefPtr<Gio::FileMonitor> > DesktopDirMonitors;
+
+    IconsForPID apps;
+    IconCache defaults;
+    DesktopDirMonitors monitors;
+    AppCache gio_apps;
+    procman::IconThemeWrapper theme;
+};
+
+#endif /* _PROCMAN_PRETTYTABLE_H_ */
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/7.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/7.html new file mode 100644 index 00000000..d3f93acb --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/7.html @@ -0,0 +1,287 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
#ifndef H_PROCMAN_ICONTHEMEWRAPPER_H_1185707711
+#define H_PROCMAN_ICONTHEMEWRAPPER_H_1185707711
+
+#include <glibmm/refptr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glibmm/ustring.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtkmm/icontheme.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdkmm/pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+namespace procman
+{
+    class IconThemeWrapper
+    {
+      public:
+        // returns 0 instead of raising an exception
+        Glib::RefPtr<Gdk::Pixbuf>
+            load_icon(const Glib::ustring& icon_name, int size) const;
+        Glib::RefPtr<Gdk::Pixbuf>
+            load_gicon(const Glib::RefPtr<Gio::Icon>& gicon, int size, Gtk::IconLookupFlags flags) const;
+
+        const IconThemeWrapper* operator->() const
+        { return this; }
+    };
+}
+
+#endif // H_PROCMAN_ICONTHEMEWRAPPER_H_1185707711
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/8.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/8.html new file mode 100644 index 00000000..95ff8980 --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/8.html @@ -0,0 +1,385 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
/*
+ * Mate system monitor color pickers
+ * Copyright (C) 2007 Karl Lattimer <karl@qdh.org.uk>
+ * Copyright (C) 2012-2021 MATE Developers
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with the software; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GSM_COLOR_BUTTON_H__
+#define __GSM_COLOR_BUTTON_H__
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+/* The GtkColorSelectionButton widget is a simple color picker in a button.
+ * The button displays a sample of the currently selected color. When
+ * the user clicks on the button, a color selection dialog pops up.
+ * The color picker emits the "color_set" signal when the color is set.
+ */
+#define GSM_TYPE_COLOR_BUTTON            (gsm_color_button_get_type ())
+G_DECLARE_DERIVABLE_TYPE (GSMColorButton, gsm_color_button, GSM, COLOR_BUTTON, GtkDrawingArea)
+
+/* Widget types */
+enum
+{
+    GSMCP_TYPE_CPU,
+    GSMCP_TYPE_PIE,
+    GSMCP_TYPE_NETWORK_IN,
+    GSMCP_TYPE_NETWORK_OUT,
+    GSMCP_TYPES
+};
+
+struct _GSMColorButtonClass
+{
+    GtkWidgetClass parent_class;
+
+    void (*color_set) (GSMColorButton * cp);
+
+    /* Padding for future expansion */
+    void (*_gtk_reserved1) (void);
+    void (*_gtk_reserved2) (void);
+    void (*_gtk_reserved3) (void);
+    void (*_gtk_reserved4) (void);
+};
+
+GtkWidget *gsm_color_button_new (const GdkRGBA * color, guint type);
+void gsm_color_button_set_color (GSMColorButton * color_button, const GdkRGBA * color);
+void gsm_color_button_set_fraction (GSMColorButton * color_button, const gdouble fraction);
+void gsm_color_button_set_cbtype (GSMColorButton * color_button, guint type);
+void gsm_color_button_get_color (GSMColorButton * color_button, GdkRGBA * color);
+gdouble gsm_color_button_get_fraction (GSMColorButton * color_button);
+guint gsm_color_button_get_cbtype (GSMColorButton * color_button);
+void gsm_color_button_set_title (GSMColorButton * color_button, const gchar * title);
+const gchar* gsm_color_button_get_title(GSMColorButton* color_button);
+
+G_END_DECLS
+#endif /* __GSM_COLOR_BUTTON_H__ */
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/9.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/9.html new file mode 100644 index 00000000..26e3422a --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/9.html @@ -0,0 +1,305 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
/* Procman - main window
+ * Copyright (C) 2001 Kevin Vandersloot
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef _PROCMAN_INTERFACE_H_
+#define _PROCMAN_INTERFACE_H_
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "procman.h"
+
+void            create_main_window (ProcData *data);
+void            update_sensitivity (ProcData *data);
+void            block_priority_changed_handlers(ProcData *data, bool block);
+void            do_popup_menu(ProcData *data, GdkEventButton *event);
+GtkWidget *     make_title_label (const char *text);
+
+#endif /* _PROCMAN_INTERFACE_H_ */
+
+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/index.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/index.html new file mode 100644 index 00000000..e94ea59c --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/index.html @@ -0,0 +1,670 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
checkersReportinformationActive checkers: There was critical errors (use --checkers-report=<filename> to see details)
src/argv.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibmm/optionentry.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/argv.h
4missingIncludeSysteminformationInclude file: <glibmm/optiongroup.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/callbacks.cpp
21missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <giomm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/callbacks.h
24missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/cgroups.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <cstring> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27variableScope398styleThe scope of the variable 'paren_offset' can be reduced.
27variableScope398styleThe scope of the variable 'off' can be reduced.
27variableScope398styleThe scope of the variable 'tmp_size' can be reduced.
55cstyleCast398styleC-style pointer casting
75constVariablePointer398styleVariable 'open_paren' can be declared as pointer to const
src/cgroups.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/defaulttable.h
4missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibmm/refptr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glibmm/regex.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/disks.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <mntent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <giomm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <giomm/themedicon.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <glibtop/mountlist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <glibtop/fsusage.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
202redundantAssignment563styleVariable 'res' is reassigned a value before the old one has been used.
src/gsm_color_button.c
23missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <cairo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <librsvg/rsvg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
522constParameterPointer398styleParameter 'color' can be declared as pointer to const
648variableScope398styleThe scope of the variable 'color_chooser' can be reduced.
723constParameterCallback398styleParameter 'event' can be declared as pointer to const. However it seems that 'gsm_color_button_pressed' is a callback function, if 'event' is declared with const you might also need to cast function pointer(s).
777constVariablePointer398styleVariable 'priv' can be declared as pointer to const
803constVariablePointer398styleVariable 'priv' can be declared as pointer to const
883constVariablePointer398styleVariable 'priv' can be declared as pointer to const
src/gsm_color_button.h
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gdk/gdk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/iconthemewrapper.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <gtkmm/icontheme.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <giomm/error.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/iconthemewrapper.h
4missingIncludeSysteminformationInclude file: <glibmm/refptr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibmm/ustring.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <gtkmm/icontheme.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <gdkmm/pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/interface.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
452cstyleCast398styleC-style pointer casting
454cstyleCast398styleC-style pointer casting
src/interface.h
24missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/load-graph.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <gdkmm/pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <dirent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <glibtop.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
16missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <glibtop/mem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
18missingIncludeSysteminformationInclude file: <glibtop/swap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
19missingIncludeSysteminformationInclude file: <glibtop/netload.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
20missingIncludeSysteminformationInclude file: <glibtop/netlist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
21missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <algorithm> not found. Please note: Cppcheck does not need standard library headers to get proper results.
454unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_GUINT64_FORMAT is a macro then please configure it.
src/load-graph.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36noExplicitConstructor398styleStruct 'LoadGraph' has a constructor with 1 argument that is not explicit.
src/lsof.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <gtkmm/messagedialog.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibmm/regex.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glibtop/procopenfiles.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <sys/wait.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <set> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <sstream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <iterator> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <glibmm/regex.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
164shadowVariable398styleLocal variable 'count' shadows outer variable
src/lsof.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/memmaps.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glibtop/procmap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibtop/mountlist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <map> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <sstream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <iomanip> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <stdexcept> not found. Please note: Cppcheck does not need standard library headers to get proper results.
52unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_GINT64_MODIFIER is a macro then please configure it.
src/memmaps.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/msm-resources.c
1missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9unusedStructMember563styleunion member 'Anonymous0::alignment' is never used.
9unusedStructMember563styleunion member 'Anonymous0::ptr' is never used.
src/openfiles.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibtop/procopenfiles.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <netdb.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <sys/socket.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <netinet/in.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <arpa/inet.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
73nullPointerRedundantCheck476warningEither the condition 'res' is redundant or there is possible null pointer dereference: res.
139constVariablePointer398styleVariable 'openfiles' can be declared as pointer to const
205shadowVariable398styleLocal variable 'openfiles' shadows outer variable
247variableScope398styleThe scope of the variable 'column' can be reduced.
248variableScope398styleThe scope of the variable 'cell' can be reduced.
src/openfiles.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/prettytable.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <libwnck/libwnck.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <dirent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <gdk-pixbuf/gdk-pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <glibtop/procstate.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <giomm/error.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <giomm/file.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
16missingIncludeSysteminformationInclude file: <glibmm/miscutils.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <iostream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
19missingIncludeSysteminformationInclude file: <vector> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/prettytable.h
6missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <gdk-pixbuf/gdk-pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <glibmm/refptr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <gdkmm/pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <giomm/filemonitor.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <map> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
18missingIncludeSysteminformationInclude file: <libwnck/libwnck.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_opened'
40unusedPrivateFunction398styleUnused private function: 'PrettyTable::on_application_closed'
src/procactions.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <sys/time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <sys/resource.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procdialogs.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
294noExplicitConstructor398styleClass 'SpinButtonUpdater' has a constructor with 1 argument that is not explicit.
415shadowVariable398styleLocal variable 'column' shadows outer variable
475cstyleCast398styleC-style pointer casting
498cstyleCast398styleC-style pointer casting
513cstyleCast398styleC-style pointer casting
src/procdialogs.h
23missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman-app.cpp
1missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
2missingIncludeSysteminformationInclude file: <glibtop.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glibtop/close.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibtop/sysinfo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
348uninitMemberVar398warningMember variable 'ProcmanApp::procdata' is not initialized in the constructor.
src/procman-app.h
4missingIncludeSysteminformationInclude file: <gtkmm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman.cpp
21missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gtkmm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34uninitMemberVarPrivate398warningMember variable 'ProcData::uimanager' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::action_group' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::statusbar' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::loadavg' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::endprocessbutton' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::popup_menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::disk_list' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::notebook' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::config' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::selection' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::settings' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::app' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::menu' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::frequency' is not initialized in the constructor.
34uninitMemberVarPrivate398warningMember variable 'ProcData::smooth_refresh' is not initialized in the constructor.
112shadowVariable398styleLocal variable 'order' shadows outer variable
162shadowVariable398styleLocal variable 'order' shadows outer variable
src/procman.h
23missingIncludeSysteminformationInclude file: <glibmm/refptr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <cairo-gobject.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gdk-pixbuf/gdk-pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <map> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
103uninitMemberVar398warningMember variable 'MutableProcInfo::cgroup_name' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::unit' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::session' is not initialized in the constructor.
103uninitMemberVar398warningMember variable 'MutableProcInfo::seat' is not initialized in the constructor.
173noExplicitConstructor398styleClass 'ProcInfo' has a constructor with 1 argument that is not explicit.
src/procman_gksu.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman_gksu.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman_pkexec.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procman_pkexec.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/procproperties.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glibtop/procmem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glibtop/procmap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glibtop/procstate.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
208variableScope398styleThe scope of the variable 'column' can be reduced.
209variableScope398styleThe scope of the variable 'cell' can be reduced.
src/procproperties.h
25missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/proctable.cpp
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <cairo-gobject.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gprintf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glibtop.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <glibtop/loadavg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <glibtop/proclist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <glibtop/procio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <glibtop/procstate.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <glibtop/procmem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <glibtop/procmap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <glibtop/proctime.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <glibtop/procuid.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <glibtop/procargs.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <glibtop/prockernel.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
40missingIncludeSysteminformationInclude file: <glibtop/mem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <glibtop/swap.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
42missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
43missingIncludeSysteminformationInclude file: <pwd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
44missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
46missingIncludeSysteminformationInclude file: <set> not found. Please note: Cppcheck does not need standard library headers to get proper results.
47missingIncludeSysteminformationInclude file: <list> not found. Please note: Cppcheck does not need standard library headers to get proper results.
50missingIncludeSysteminformationInclude file: <systemd/sd-login.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
64missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
606constVariablePointer398styleVariable 'pwd' can be declared as pointer to const
920shadowVariable398styleLocal variable 'arguments' shadows outer variable
929shadowVariable398styleLocal variable 'tooltip' shadows outer variable
1016shadowVariable398styleLocal variable 'it' shadows outer variable
1022shadowVariable398styleLocal variable 'it' shadows outer variable
1052constVariablePointer398styleVariable 'parent' can be declared as pointer to const
1068shadowVariable398styleLocal variable 'it' shadows outer variable
1073shadowVariable398styleLocal variable 'it' shadows outer variable
src/proctable.h
24missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/selection.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/selection.h
4missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <vector> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/selinux.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
21varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
src/selinux.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/settings-keys.h
4missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/smooth_refresh.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <glibtop.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <glibtop/proctime.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <glibtop/cpu.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
11missingIncludeSysteminformationInclude file: <algorithm> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/smooth_refresh.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
22noExplicitConstructor398styleClass 'SmoothRefresh' has a constructor with 1 argument that is not explicit.
src/sysinfo.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glibmm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <libxml/parser.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <libxml/xpath.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <libxml/xpathInternals.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <glibtop/fsusage.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <glibtop/mountlist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <glibtop/mem.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <glibtop/sysinfo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
18missingIncludeSysteminformationInclude file: <netdb.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
19missingIncludeSysteminformationInclude file: <sys/socket.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
20missingIncludeSysteminformationInclude file: <sys/wait.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
21missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
22missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <exception> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <vector> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <fstream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <sstream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <sys/utsname.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
126unusedPrivateFunction398styleUnused private function: 'SysInfo::get_os_type'
233cstyleCast398styleC-style pointer casting
343cstyleCast398styleC-style pointer casting
509uninitMemberVar398warningMember variable 'LSBSysInfo::lsb_fd' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::name' is not initialized in the constructor.
509uninitMemberVar398warningMember variable 'LSBSysInfo::release' is not initialized in the constructor.
515missingOverridestyleThe function 'set_distro_labels' overrides a function in a base class but is not marked with a 'override' specifier.
570shadowVariable398styleLocal variable 'release' shadows outer variable
615unusedPrivateFunction398styleUnused private function: 'LSBSysInfo::sync_lsb_release'
626variableScope398styleThe scope of the variable 'codename' can be reduced.
626shadowVariable398styleLocal variable 'release' shadows outer variable
690stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
697stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
701stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
736variableScope398styleThe scope of the variable 'len' can be reduced.
738stlIfStrFind597performanceInefficient usage of string::find() in condition; string::starts_with() could be faster.
1001unreadVariable563styleVariable 'table_count' is assigned a value that is never used.
src/util.cpp
1missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib/gprintf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <glibtop/proctime.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <glibtop/procstate.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
10missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <stddef.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <cstring> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/util.h
6missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
8missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9missingIncludeSysteminformationInclude file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
123constParameterPointer398styleParameter 'new_value' can be declared as pointer to const
tools/msm_execute_helper.c
1missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
2missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6constParameter398styleParameter 'argv' can be declared as const array
+
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/stats.html b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/stats.html new file mode 100644 index 00000000..2a7543bb --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/stats.html @@ -0,0 +1,205 @@ + + + + + + Cppcheck - HTML report - mate-system-monitor + + + + + +
+ + + +
+

Top 10 files for error severity, total findings: 2
+   1  src/memmaps.cpp
+   1  src/load-graph.cpp
+

+

Top 10 files for warning severity, total findings: 24
+   15  src/procman.cpp
+   4   src/procman.h
+   3   src/sysinfo.cpp
+   1   src/procman-app.cpp
+   1   src/openfiles.cpp
+

+

Top 10 files for portability severity, total findings: 1
+   1  src/selinux.cpp
+

+

Top 10 files for performance severity, total findings: 4
+   4  src/sysinfo.cpp
+

+

Top 10 files for style severity, total findings: 55
+   10  src/sysinfo.cpp
+   8   src/proctable.cpp
+   6   src/gsm_color_button.c
+   5   src/procdialogs.cpp
+   5   src/cgroups.cpp
+   4   src/openfiles.cpp
+   2   src/procproperties.cpp
+   2   src/procman.cpp
+   2   src/prettytable.h
+   2   src/msm-resources.c
+

+

Top 10 files for information severity, total findings: 269
+   26  src/proctable.cpp
+   24  src/sysinfo.cpp
+   18  src/load-graph.cpp
+   14  src/prettytable.cpp
+   12  src/gsm_color_button.c
+   11  src/procman.h
+   11  src/lsof.cpp
+   10  src/util.cpp
+   10  src/memmaps.cpp
+   10  src/interface.cpp
+

+ +
+ +
+ + diff --git a/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/style.css b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/style.css new file mode 100644 index 00000000..3897bfaf --- /dev/null +++ b/2024-01-24-110256-7758-cppcheck@4d3102f305d3_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/CNAME b/CNAME new file mode 100644 index 00000000..7631273c --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +mate-system-monitor.mate-desktop.dev diff --git a/index.html b/index.html new file mode 100644 index 00000000..e8ca0992 --- /dev/null +++ b/index.html @@ -0,0 +1,47 @@ + + + + + + mate-system-monitor Code Analyzer results + + +

+ mate-desktop/mate-system-monitor Static analyzer results +

+ GitHub + Build Status +
+Commit: 4d3102f305d3caf3b242b1635d557007a8a8013d
+Compare: 71c61020bc59...4d3102f305d3
+Branch: master
+Time: 2024-01-24 11:02:56+00:00
+Messages:
+
+ci: use ubuntu jammy as docker
+
+
+ + +