Skip to content

Haiku port: more modules#2358

Merged
CarterLi merged 4 commits into
fastfetch-cli:devfrom
mmuman:haiku-port
May 31, 2026
Merged

Haiku port: more modules#2358
CarterLi merged 4 commits into
fastfetch-cli:devfrom
mmuman:haiku-port

Conversation

@mmuman
Copy link
Copy Markdown
Contributor

@mmuman mmuman commented May 30, 2026

Summary

Adds bootmgr, brightness and wmtheme module implementations for Haiku.

Checklist

  • I have tested my changes locally.

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 30, 2026

Not up to standards ⛔

🔴 Issues 5 medium

Alerts:
⚠ 5 issues (≤ 0 issues of at least minor severity)

Results:
5 new issues

Category Results
ErrorProne 5 medium

View in Codacy

🟢 Metrics 9 complexity · 0 duplication

Metric Results
Complexity 9
Duplication 0

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@mmuman mmuman marked this pull request as ready for review May 30, 2026 20:35
Copy link
Copy Markdown

@codacy-production codacy-production Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

The PR introduces several Haiku-specific detection modules but is currently not up to standards due to high-severity logic and architectural issues. Most critical is the multiple instantiation of BApplication across modules, which will lead to process crashes since Haiku strictly enforces a single application instance per process.

Additionally, the wmtheme implementation contains a guaranteed memory leak and relies on unstable private headers. The boot manager detection is also quite limited, lacking support for EFI and 64-bit loaders which are standard in modern Haiku installations. These architectural and stability issues must be addressed before merging.

About this PR

  • The wmtheme implementation uses a private Haiku header (<private/interface/DecorInfo.h>). This is unstable and may break in future OS updates without notice.

Test suggestions

  • Missing: Verify ffDetectBootmgr identifies the bios_ia32 loader path when it exists
  • Missing: Verify ffDetectBrightness correctly iterates through multiple screens and reports current brightness
  • Missing: Verify ffDetectWmTheme retrieves the active decorator name via BApplication and DecorInfoUtility
  • Missing: Verify ffDetectWmTheme gracefully handles null returns from CurrentDecorator()
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Missing: Verify ffDetectBootmgr identifies the bios_ia32 loader path when it exists
2. Missing: Verify ffDetectBrightness correctly iterates through multiple screens and reports current brightness
3. Missing: Verify ffDetectWmTheme retrieves the active decorator name via BApplication and DecorInfoUtility
4. Missing: Verify ffDetectWmTheme gracefully handles null returns from CurrentDecorator()
Low confidence findings
  • The brightness implementation relies on the experimental Haiku API 'GetMonitorInfo' for vendor and model details, which may exhibit inconsistent behavior across different hardware.

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

Comment thread src/detection/wmtheme/wmtheme_haiku.cpp Outdated
Comment on lines +14 to +21
DecorInfoUtility* util = new DecorInfoUtility();
DecorInfo* decor = NULL;

if (util) {
decor = util->CurrentDecorator();
}

if (util == NULL || decor == NULL) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 HIGH RISK

Memory leak: 'util' is allocated via 'new' but never deleted. Use stack allocation to ensure proper cleanup and remove the redundant null check.

Try running the following prompt in your IDE agent:

In src/detection/wmtheme/wmtheme_haiku.cpp, refactor the DecorInfoUtility usage to use stack allocation instead of heap allocation (e.g., DecorInfoUtility util;) and update the pointer access (->) to member access (.) to prevent a memory leak. Remove the redundant if (util) checks as well.


const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
// We need a valid be_app to query the app_server here.
BApplication app("application/x-vnd.fastfetch-cli-fastfetch");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 HIGH RISK

Haiku only allows one BApplication per process. Multiple modules are creating their own instances, which will lead to a crash. Check if 'be_app' is already initialized.

Try running the following prompt in your coding agent:

Refactor the BApplication initialization in Haiku modules to check if be_app is already non-null before creating a new BApplication instance.

FFBrightnessResult* brightness = FF_LIST_ADD(FFBrightnessResult, *result);

if (err == B_OK) {
ffStrbufInitF(&brightness->name, "%s %s (%ld)", monitor.vendor, monitor.name, screen.ID().id);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

Potential format string mismatch for int32 on 64-bit systems. screen.ID().id returns an int32, but %ld is used.

Suggested change
ffStrbufInitF(&brightness->name, "%s %s (%ld)", monitor.vendor, monitor.name, screen.ID().id);
ffStrbufInitF(&brightness->name, "%s %s (%ld)", monitor.vendor, monitor.name, (long) screen.ID().id);

#include "common/strutil.h"
}

#include <Application.h>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ LOW RISK

Nitpick: The std::nanf function requires the <cmath> header.

Suggested change
#include <Application.h>
#include <cmath>
#include <Application.h>

Comment thread src/detection/brightness/brightness_haiku.cpp Outdated
@CarterLi CarterLi merged commit a63d854 into fastfetch-cli:dev May 31, 2026
24 of 25 checks passed
@mmuman mmuman deleted the haiku-port branch May 31, 2026 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants