From ed51c2a75178bde30fa59b1bca4ce9090a9c4349 Mon Sep 17 00:00:00 2001 From: Xoris Date: Sat, 15 Jun 2024 10:49:23 +0800 Subject: [PATCH 1/6] fix divide 0 error when caculating disk usage percentage (#791) --- src/freebsd/btop_collect.cpp | 9 +++++++-- src/linux/btop_collect.cpp | 9 +++++++-- src/openbsd/btop_collect.cpp | 9 +++++++-- src/osx/btop_collect.cpp | 9 +++++++-- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/freebsd/btop_collect.cpp b/src/freebsd/btop_collect.cpp index b4034c776..29e54bf2b 100644 --- a/src/freebsd/btop_collect.cpp +++ b/src/freebsd/btop_collect.cpp @@ -771,8 +771,13 @@ namespace Mem { disk.total = vfs.f_blocks * vfs.f_frsize; disk.free = vfs.f_bfree * vfs.f_frsize; disk.used = disk.total - disk.free; - disk.used_percent = round((double)disk.used * 100 / disk.total); - disk.free_percent = 100 - disk.used_percent; + if (disk.total != 0) { + disk.used_percent = round((double)disk.used * 100 / disk.total); + disk.free_percent = 100 - disk.used_percent; + } else { + disk.used_percent = 0; + disk.free_percent = 0; + } } //? Setup disks order in UI and add swap if enabled diff --git a/src/linux/btop_collect.cpp b/src/linux/btop_collect.cpp index d9f571f17..0541357a6 100644 --- a/src/linux/btop_collect.cpp +++ b/src/linux/btop_collect.cpp @@ -1936,8 +1936,13 @@ namespace Mem { disk.total = vfs.f_blocks * vfs.f_frsize; disk.free = (free_priv ? vfs.f_bfree : vfs.f_bavail) * vfs.f_frsize; disk.used = disk.total - disk.free; - disk.used_percent = round((double)disk.used * 100 / disk.total); - disk.free_percent = 100 - disk.used_percent; + if (disk.total != 0) { + disk.used_percent = round((double)disk.used * 100 / disk.total); + disk.free_percent = 100 - disk.used_percent; + } else { + disk.used_percent = 0; + disk.free_percent = 0; + } return pair{disk, -1}; }); ++it; diff --git a/src/openbsd/btop_collect.cpp b/src/openbsd/btop_collect.cpp index a8c395e35..480b83465 100644 --- a/src/openbsd/btop_collect.cpp +++ b/src/openbsd/btop_collect.cpp @@ -723,8 +723,13 @@ namespace Mem { disk.total = vfs.f_blocks * vfs.f_frsize; disk.free = vfs.f_bfree * vfs.f_frsize; disk.used = disk.total - disk.free; - disk.used_percent = round((double)disk.used * 100 / disk.total); - disk.free_percent = 100 - disk.used_percent; + if (disk.total != 0) { + disk.used_percent = round((double)disk.used * 100 / disk.total); + disk.free_percent = 100 - disk.used_percent; + } else { + disk.used_percent = 0; + disk.free_percent = 0; + } } //? Setup disks order in UI and add swap if enabled diff --git a/src/osx/btop_collect.cpp b/src/osx/btop_collect.cpp index 8c6570506..4d54e328e 100644 --- a/src/osx/btop_collect.cpp +++ b/src/osx/btop_collect.cpp @@ -795,8 +795,13 @@ namespace Mem { disk.total = vfs.f_blocks * vfs.f_frsize; disk.free = vfs.f_bfree * vfs.f_frsize; disk.used = disk.total - disk.free; - disk.used_percent = round((double)disk.used * 100 / disk.total); - disk.free_percent = 100 - disk.used_percent; + if (disk.total != 0) { + disk.used_percent = round((double)disk.used * 100 / disk.total); + disk.free_percent = 100 - disk.used_percent; + } else { + disk.used_percent = 0; + disk.free_percent = 0; + } } //? Setup disks order in UI and add swap if enabled From be1b9c36dc862b6c6abe89463f4ce4571eddc229 Mon Sep 17 00:00:00 2001 From: Gerald Pottler Date: Sun, 23 Jun 2024 23:15:04 +0200 Subject: [PATCH 2/6] fix io_graph_speeds parsing Issue #868 --- src/btop_draw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/btop_draw.cpp b/src/btop_draw.cpp index c54f6342a..fb2af48c2 100644 --- a/src/btop_draw.cpp +++ b/src/btop_draw.cpp @@ -1162,7 +1162,7 @@ namespace Mem { if (not Config::getS("io_graph_speeds").empty()) { auto split = ssplit(Config::getS("io_graph_speeds")); for (const auto& entry : split) { - auto vals = ssplit(entry); + auto vals = ssplit(entry,':'); if (vals.size() == 2 and mem.disks.contains(vals.at(0)) and isint(vals.at(1))) try { custom_speeds[vals.at(0)] = std::stoi(vals.at(1)); From 4702716ae0651d947c3b969a7cf60d252496e9dc Mon Sep 17 00:00:00 2001 From: Gerald Pottler Date: Sun, 23 Jun 2024 23:31:49 +0200 Subject: [PATCH 3/6] Update spacing --- src/btop_draw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/btop_draw.cpp b/src/btop_draw.cpp index fb2af48c2..9b51bf9a0 100644 --- a/src/btop_draw.cpp +++ b/src/btop_draw.cpp @@ -1162,7 +1162,7 @@ namespace Mem { if (not Config::getS("io_graph_speeds").empty()) { auto split = ssplit(Config::getS("io_graph_speeds")); for (const auto& entry : split) { - auto vals = ssplit(entry,':'); + auto vals = ssplit(entry, ':'); if (vals.size() == 2 and mem.disks.contains(vals.at(0)) and isint(vals.at(1))) try { custom_speeds[vals.at(0)] = std::stoi(vals.at(1)); From b9ac360a69c8d60eec069d0ec65ff594ae036108 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Mon, 24 Jun 2024 17:38:17 +0200 Subject: [PATCH 4/6] Removed deprecated macos-11 and add macos-13 and macos-14 --- .github/workflows/continuous-build-macos.yml | 45 ++++++++++++++++---- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/.github/workflows/continuous-build-macos.yml b/.github/workflows/continuous-build-macos.yml index c8915dd7c..511c706f6 100644 --- a/.github/workflows/continuous-build-macos.yml +++ b/.github/workflows/continuous-build-macos.yml @@ -28,27 +28,31 @@ on: - '.github/workflows/continuous-build-macos.yml' jobs: - build-macos11: - runs-on: macos-11 + build-macos12: + runs-on: macos-12 steps: + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + - uses: actions/checkout@v3 with: submodules: recursive - name: Compile run: | - make CXX=g++-11 ARCH=x86_64 STATIC=true STRIP=true + make CXX=g++-12 ARCH=x86_64 STATIC=true STRIP=true GIT_HASH=$(git rev-parse --short "$GITHUB_SHA") - mv bin/btop bin/btop-x86_64-BigSur-$GIT_HASH + mv bin/btop bin/btop-x86_64-Monterey-$GIT_HASH ls -alh bin - uses: actions/upload-artifact@v3 with: - name: btop-x86_64-macos11-BigSur + name: btop-x86_64-macos12-Monterey path: 'bin/*' - build-macos12: - runs-on: macos-12 + build-macos13: + runs-on: macos-13 steps: - uses: maxim-lobanov/setup-xcode@v1 with: @@ -62,10 +66,33 @@ jobs: run: | make CXX=g++-12 ARCH=x86_64 STATIC=true STRIP=true GIT_HASH=$(git rev-parse --short "$GITHUB_SHA") - mv bin/btop bin/btop-x86_64-Monterey-$GIT_HASH + mv bin/btop bin/btop-x86_64-Ventura-$GIT_HASH ls -alh bin - uses: actions/upload-artifact@v3 with: - name: btop-x86_64-macos12-Monterey + name: btop-x86_64-macos13-Ventura path: 'bin/*' + + build-macos14: + runs-on: macos-14 + steps: + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Compile + run: | + make CXX=g++-12 ARCH=x86_64 STATIC=true STRIP=true + GIT_HASH=$(git rev-parse --short "$GITHUB_SHA") + mv bin/btop bin/btop-x86_64-Sonoma-$GIT_HASH + ls -alh bin + + - uses: actions/upload-artifact@v3 + with: + name: btop-x86_64-macos14-Sonoma + path: 'bin/*' \ No newline at end of file From 18716e736285a420a98c28db37366b386fb1934e Mon Sep 17 00:00:00 2001 From: aristocratos Date: Mon, 24 Jun 2024 17:45:56 +0200 Subject: [PATCH 5/6] Removed macos-14 for now due to XCode bug when compiling with gcc --- .github/workflows/continuous-build-macos.yml | 23 -------------------- 1 file changed, 23 deletions(-) diff --git a/.github/workflows/continuous-build-macos.yml b/.github/workflows/continuous-build-macos.yml index 511c706f6..2ea27ce3a 100644 --- a/.github/workflows/continuous-build-macos.yml +++ b/.github/workflows/continuous-build-macos.yml @@ -73,26 +73,3 @@ jobs: with: name: btop-x86_64-macos13-Ventura path: 'bin/*' - - build-macos14: - runs-on: macos-14 - steps: - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: latest-stable - - - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Compile - run: | - make CXX=g++-12 ARCH=x86_64 STATIC=true STRIP=true - GIT_HASH=$(git rev-parse --short "$GITHUB_SHA") - mv bin/btop bin/btop-x86_64-Sonoma-$GIT_HASH - ls -alh bin - - - uses: actions/upload-artifact@v3 - with: - name: btop-x86_64-macos14-Sonoma - path: 'bin/*' \ No newline at end of file From e4f69cd72868d60c40f2861a46c085ee6014f004 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Mon, 24 Jun 2024 17:53:14 +0200 Subject: [PATCH 6/6] Updated soon to be deprecated actions to latest versions --- .github/workflows/continuous-build-linux.yml | 4 ++-- .github/workflows/continuous-build-macos.yml | 8 ++++---- .github/workflows/continuous-build-openbsd.yml | 2 +- .github/workflows/test-snap-can-build.yml | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/continuous-build-linux.yml b/.github/workflows/continuous-build-linux.yml index 39de640b9..712e8c5b6 100644 --- a/.github/workflows/continuous-build-linux.yml +++ b/.github/workflows/continuous-build-linux.yml @@ -95,7 +95,7 @@ jobs: run: git config --global --add safe.directory /__w/btop/btop - name: Checkout source - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive @@ -121,7 +121,7 @@ jobs: cp bin/btop .artifacts/$FILENAME - name: Upload artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: btop-${{ matrix.toolchain }} path: '.artifacts/**' diff --git a/.github/workflows/continuous-build-macos.yml b/.github/workflows/continuous-build-macos.yml index 2ea27ce3a..6245e7e95 100644 --- a/.github/workflows/continuous-build-macos.yml +++ b/.github/workflows/continuous-build-macos.yml @@ -35,7 +35,7 @@ jobs: with: xcode-version: latest-stable - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive @@ -46,7 +46,7 @@ jobs: mv bin/btop bin/btop-x86_64-Monterey-$GIT_HASH ls -alh bin - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: btop-x86_64-macos12-Monterey path: 'bin/*' @@ -58,7 +58,7 @@ jobs: with: xcode-version: latest-stable - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive @@ -69,7 +69,7 @@ jobs: mv bin/btop bin/btop-x86_64-Ventura-$GIT_HASH ls -alh bin - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: btop-x86_64-macos13-Ventura path: 'bin/*' diff --git a/.github/workflows/continuous-build-openbsd.yml b/.github/workflows/continuous-build-openbsd.yml index 6925ebbbf..84d631f25 100644 --- a/.github/workflows/continuous-build-openbsd.yml +++ b/.github/workflows/continuous-build-openbsd.yml @@ -50,7 +50,7 @@ jobs: mv bin/btop bin/btop-GCC11-"$GIT_HASH" ls -alh bin - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: btop-x86_64-openbsd-7.4 path: 'bin/*' diff --git a/.github/workflows/test-snap-can-build.yml b/.github/workflows/test-snap-can-build.yml index 6df8e4708..a59b58d09 100644 --- a/.github/workflows/test-snap-can-build.yml +++ b/.github/workflows/test-snap-can-build.yml @@ -4,7 +4,7 @@ on: push: branches: [ main ] tags-ignore: - - '*.*' + - '*.*' paths: - 'src/**' - '!src/osx/**' @@ -21,16 +21,16 @@ on: - 'include/**' - 'Makefile' - '.github/workflows/test-snap-can-build.yml' - + jobs: build: runs-on: ubuntu-latest strategy: matrix: node-version: [20.x] - + steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: snapcore/action-build@v1 id: build