From 93fe2ed4c3a2844a36473638b5809ed94882dde2 Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Thu, 25 Nov 2021 13:40:03 +0800 Subject: [PATCH 01/15] Remove spaces at the end of lines Suggested-by: editors and git --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ec3cedf..ffaa292 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,10 @@ $ sudo crazy ``` ### Binary Package -Debian package is available from [OBS(Open Build Service)](https://build.opensuse.org/package/show/home:tsuroot/CrazyDiskInfo) -Direct Links: -[Debian_8.0](http://download.opensuse.org/repositories/home:/tsuroot/Debian_8.0/) -Ubuntu [14.04](http://download.opensuse.org/repositories/home:/tsuroot/xUbuntu_14.04/)/[16.04](http://download.opensuse.org/repositories/home:/tsuroot/xUbuntu_16.04/)/[16.10](http://download.opensuse.org/repositories/home:/tsuroot/xUbuntu_16.10/) +Debian package is available from [OBS(Open Build Service)](https://build.opensuse.org/package/show/home:tsuroot/CrazyDiskInfo) +Direct Links: +[Debian_8.0](http://download.opensuse.org/repositories/home:/tsuroot/Debian_8.0/) +Ubuntu [14.04](http://download.opensuse.org/repositories/home:/tsuroot/xUbuntu_14.04/)/[16.04](http://download.opensuse.org/repositories/home:/tsuroot/xUbuntu_16.04/)/[16.10](http://download.opensuse.org/repositories/home:/tsuroot/xUbuntu_16.10/) I requested for tSU-RooT. Thank you very much for your accept with my request. From 33f2c70da21943138e891819060c30ce6957ebb4 Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Thu, 25 Nov 2021 12:56:53 +0800 Subject: [PATCH 02/15] Switch from apt-get to apt for installing Debian packages The apt command is the newer interactive package manager for APT. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ffaa292..8a294ab 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ CrazyDiskInfo is an interactive TUI S.M.A.R.T viewer for Unix systems. #### Debian(or derivative) Systems ``` -# apt-get install libatasmart-dev libncurses5-dev libncursesw5-dev +# apt install libatasmart-dev libncurses5-dev libncursesw5-dev ``` ## Build and Run From d9480c0254397f88ea98bca78aea91a29082be33 Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Thu, 25 Nov 2021 12:57:53 +0800 Subject: [PATCH 03/15] Remove libncurses5-dev Debian build dependency It isn't used, only libncursesw5-dev is used. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a294ab..dc960bc 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ CrazyDiskInfo is an interactive TUI S.M.A.R.T viewer for Unix systems. #### Debian(or derivative) Systems ``` -# apt install libatasmart-dev libncurses5-dev libncursesw5-dev +# apt install libatasmart-dev libncursesw5-dev ``` ## Build and Run From 44e6b0d56bfa24d1ac28212938a9f2ef23b686b1 Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Thu, 25 Nov 2021 13:16:34 +0800 Subject: [PATCH 04/15] Switch from libncursesw5-dev to libncurses-dev for Debian build dependency libncursesw5-dev is from an obsolete version of ncurses. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dc960bc..c1c9abf 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ CrazyDiskInfo is an interactive TUI S.M.A.R.T viewer for Unix systems. #### Debian(or derivative) Systems ``` -# apt install libatasmart-dev libncursesw5-dev +# apt install libatasmart-dev libncurses-dev ``` ## Build and Run From 5a50b262a1b8fcb1de446066b3ba16d454be8b7b Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Thu, 25 Nov 2021 13:17:23 +0800 Subject: [PATCH 05/15] Use sudo when installing The default install path is only writable by root. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c1c9abf..5ce4b3e 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ CrazyDiskInfo is an interactive TUI S.M.A.R.T viewer for Unix systems. $ mkdir build $ cd build $ cmake .. -$ make && make install +$ make && sudo make install $ sudo crazy ``` From 34ba626d14bc8f4c9918c79f293cc298277e5d1b Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Thu, 25 Nov 2021 13:21:33 +0800 Subject: [PATCH 06/15] Use cmake to create the build directory This is one less command to copy and run. --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 5ce4b3e..9bd7265 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,8 @@ CrazyDiskInfo is an interactive TUI S.M.A.R.T viewer for Unix systems. ## Build and Run ``` -$ mkdir build +$ cmake -B build $ cd build -$ cmake .. $ make && sudo make install $ sudo crazy ``` From c128c4edf01bdca59e1ad754eda1d181064282a9 Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Thu, 25 Nov 2021 13:38:11 +0800 Subject: [PATCH 07/15] Add information about CrazyDiskInfo in distributions Link to the Repology service to list the versions and use the SVG badges provided by Repology for a local list. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 9bd7265..6edc3b6 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,12 @@ $ sudo crazy ``` ### Binary Package +CrazyDiskInfo binary packages are available in several distributions, +[versions are listed on Repology](https://repology.org/project/crazydiskinfo/versions). + +Packaging status + + Debian package is available from [OBS(Open Build Service)](https://build.opensuse.org/package/show/home:tsuroot/CrazyDiskInfo) Direct Links: [Debian_8.0](http://download.opensuse.org/repositories/home:/tsuroot/Debian_8.0/) From 7ab17974d00de65315dee704b11aa3c99dc8b109 Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Thu, 25 Nov 2021 13:43:21 +0800 Subject: [PATCH 08/15] Switch URLs from http to https This prevents network attackers from manipulating transferred data. Suggested-by: check-all-the-things --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6edc3b6..bd5790d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # CrazyDiskInfo -![](http://raw.github.com/wiki/otakuto/CrazyDiskInfo/images/0.png) +![](https://raw.github.com/wiki/otakuto/CrazyDiskInfo/images/0.png) ## Introduction CrazyDiskInfo is an interactive TUI S.M.A.R.T viewer for Unix systems. @@ -34,8 +34,8 @@ CrazyDiskInfo binary packages are available in several distributions, Debian package is available from [OBS(Open Build Service)](https://build.opensuse.org/package/show/home:tsuroot/CrazyDiskInfo) Direct Links: -[Debian_8.0](http://download.opensuse.org/repositories/home:/tsuroot/Debian_8.0/) -Ubuntu [14.04](http://download.opensuse.org/repositories/home:/tsuroot/xUbuntu_14.04/)/[16.04](http://download.opensuse.org/repositories/home:/tsuroot/xUbuntu_16.04/)/[16.10](http://download.opensuse.org/repositories/home:/tsuroot/xUbuntu_16.10/) +[Debian_8.0](https://download.opensuse.org/repositories/home:/tsuroot/Debian_8.0/) +Ubuntu [14.04](https://download.opensuse.org/repositories/home:/tsuroot/xUbuntu_14.04/)/[16.04](https://download.opensuse.org/repositories/home:/tsuroot/xUbuntu_16.04/)/[16.10](https://download.opensuse.org/repositories/home:/tsuroot/xUbuntu_16.10/) I requested for tSU-RooT. Thank you very much for your accept with my request. From 6464455322874a7bbd4ec01517183e80a237c7c0 Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Thu, 25 Nov 2021 12:07:50 +0800 Subject: [PATCH 09/15] Preserve C++ build flags passed to cmake This lets distros apply extra hardening flags, while keeping the supplied C++ build flags. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cebc142..a7a9f8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.0) option(RAW_VALUES_DEC "Display Raw Values in Decimal instead of Hex" OFF) project(CrazyDiskInfo CXX) add_executable(CrazyDiskInfo main.cpp) -set(CMAKE_CXX_FLAGS "-Wall -std=c++11") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11") SET_TARGET_PROPERTIES(CrazyDiskInfo PROPERTIES OUTPUT_NAME crazy) target_link_libraries(CrazyDiskInfo atasmart) target_link_libraries(CrazyDiskInfo tinfow) From 7575c58463118080582599bcf44af4ffb30dea9e Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Thu, 25 Nov 2021 12:21:44 +0800 Subject: [PATCH 10/15] Don't link against tinfow It does not appear to be used. Fixes: https://github.com/otakuto/crazydiskinfo/issues/27 --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a7a9f8e..be93e0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,5 @@ add_executable(CrazyDiskInfo main.cpp) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11") SET_TARGET_PROPERTIES(CrazyDiskInfo PROPERTIES OUTPUT_NAME crazy) target_link_libraries(CrazyDiskInfo atasmart) -target_link_libraries(CrazyDiskInfo tinfow) target_link_libraries(CrazyDiskInfo ncursesw) INSTALL(TARGETS CrazyDiskInfo RUNTIME DESTINATION /usr/sbin) From 320c15940902258dc232e0de9a09619fddcb9b9d Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Thu, 25 Nov 2021 12:22:11 +0800 Subject: [PATCH 11/15] Install executable using GNUInstallDirs and CMAKE_INSTALL_SBINDIR The executable should not be in /usr/sbin as that is for packages only. Using GNUInstallDirs gives the right dir by default and allows distros to install into /usr/sbin when they want. Fixes: https://github.com/otakuto/crazydiskinfo/issues/29 --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index be93e0f..bc4b7f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,4 +6,5 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11") SET_TARGET_PROPERTIES(CrazyDiskInfo PROPERTIES OUTPUT_NAME crazy) target_link_libraries(CrazyDiskInfo atasmart) target_link_libraries(CrazyDiskInfo ncursesw) -INSTALL(TARGETS CrazyDiskInfo RUNTIME DESTINATION /usr/sbin) +include(GNUInstallDirs) +INSTALL(TARGETS CrazyDiskInfo RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}) From 30ee4cde52fb976732cc6311671c43d10277f910 Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Thu, 25 Nov 2021 12:46:36 +0800 Subject: [PATCH 12/15] Format strings: use %s when printing strings Otherwise the string itself could be interpreted as a format string. Suggested-by: g++ --- main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 7dcdf05..7d8b42c 100644 --- a/main.cpp +++ b/main.cpp @@ -214,7 +214,7 @@ void drawVersion(WINDOW * window) auto title = " " + TITLE + "-" + VERSION + " "; wattrset(window, COLOR_PAIR(TITLE_COLOR)); - mvwprintw(window, 0, (width - title.length()) / 2, title.c_str()); + mvwprintw(window, 0, (width - title.length()) / 2, "%s", title.c_str()); wattroff(window, COLOR_PAIR(TITLE_COLOR)); wnoutrefresh(window); @@ -247,7 +247,7 @@ void drawDeviceBar(WINDOW * window, std::vector const & smartList, int se if (i == select) { wattrset(window, COLOR_PAIR(HEALTH_COLOR) | A_BOLD); - mvwprintw(window, 2, x, smartList[i].deviceName.c_str()); + mvwprintw(window, 2, x, "%s", smartList[i].deviceName.c_str()); wattroff(window, COLOR_PAIR(HEALTH_COLOR) | A_BOLD); wattrset(window, COLOR_PAIR(HEALTH_COLOR)); @@ -256,7 +256,7 @@ void drawDeviceBar(WINDOW * window, std::vector const & smartList, int se } else { - mvwprintw(window, 2, x, smartList[i].deviceName.c_str()); + mvwprintw(window, 2, x, "%s", smartList[i].deviceName.c_str()); mvwhline(window, 3, x, ' ', smartList[i].deviceName.length()); } x += smartList[i].deviceName.length() + 1; From 277f398fae781f216359474564dcd3d80159db42 Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Thu, 25 Nov 2021 12:47:51 +0800 Subject: [PATCH 13/15] Format strings: get individual value of a std::pair Suggested-by: g++ --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 7d8b42c..0f1c490 100644 --- a/main.cpp +++ b/main.cpp @@ -232,7 +232,7 @@ void drawDeviceBar(WINDOW * window, std::vector const & smartList, int se if (std::get<0>(smartList[i].temperature)) { wattrset(window, COLOR_PAIR(HEALTH_INV_COLOR + static_cast(temperatureToHealth(std::get<1>(smartList[i].temperature))))); - mvwprintw(window, 1, x, "%.1f ", smartList[i].temperature); + mvwprintw(window, 1, x, "%.1f ", std::get<1>(smartList[i].temperature)); waddch(window, ACS_DEGREE); waddstr(window, "C"); wattroff(window, COLOR_PAIR(HEALTH_INV_COLOR + static_cast(temperatureToHealth(std::get<1>(smartList[i].temperature))))); From e1ac1fa6555f0286592cce134ddab307f20c482f Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Thu, 25 Nov 2021 12:48:54 +0800 Subject: [PATCH 14/15] Format strings: use macro instead of format constant when printing a uint64_t value This is more portable as it will use the right constant for each platform. Suggested-by: g++ --- main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 0f1c490..d010aab 100644 --- a/main.cpp +++ b/main.cpp @@ -355,7 +355,7 @@ void drawStatus(WINDOW * window, SMART const & smart, Option const & option) mvwprintw(window, 2, (int)(STATUS_WIDTH * (3.0 / 5)), "Power On Count:"); wattroff(window, COLOR_PAIR(HEALTH_COLOR)); wattrset(window, COLOR_PAIR(HEALTH_COLOR) | A_BOLD); - wprintw(window, " %llu ", std::get<1>(smart.powerOnCount)); + wprintw(window, " %" PRIu64 " ", std::get<1>(smart.powerOnCount)); wattroff(window, COLOR_PAIR(HEALTH_COLOR) | A_BOLD); wattrset(window, COLOR_PAIR(HEALTH_COLOR)); wprintw(window, "count"); @@ -372,7 +372,7 @@ void drawStatus(WINDOW * window, SMART const & smart, Option const & option) mvwprintw(window, 3, (int)(STATUS_WIDTH * (3.0 / 5)), "Power On Hours:"); wattroff(window, COLOR_PAIR(HEALTH_COLOR)); wattrset(window, COLOR_PAIR(HEALTH_COLOR) | A_BOLD); - wprintw(window, " %llu ", std::get<1>(smart.powerOnHour)); + wprintw(window, " %" PRIu64 " ", std::get<1>(smart.powerOnHour)); wattroff(window, COLOR_PAIR(HEALTH_COLOR) | A_BOLD); wattrset(window, COLOR_PAIR(HEALTH_COLOR)); wprintw(window, "hours"); From 8563aa8636c37f0b889f3b4b27338691efdeac2b Mon Sep 17 00:00:00 2001 From: Yangfl Date: Thu, 25 Nov 2021 14:05:57 +0800 Subject: [PATCH 15/15] Initialise sigaction separately to sa_handler member The sa_handler member is the first member on most platforms but is not the first on MIPS. Fixes: https://bugs.debian.org/987829 --- main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index d010aab..517f914 100644 --- a/main.cpp +++ b/main.cpp @@ -507,7 +507,8 @@ int main() update(); { - struct sigaction s = {{actionWINCH}}; + struct sigaction s = {0}; + s.sa_handler = actionWINCH; sigaction(SIGWINCH, &s, nullptr); }