Skip to content

Fix build errors and warnings in NetBSD.#1360

Merged
BenBE merged 2 commits intohtop-dev:mainfrom
fraggerfox:fix-netbsd-build
Jan 9, 2024
Merged

Fix build errors and warnings in NetBSD.#1360
BenBE merged 2 commits intohtop-dev:mainfrom
fraggerfox:fix-netbsd-build

Conversation

@fraggerfox
Copy link
Copy Markdown
Contributor

@fraggerfox fraggerfox commented Jan 1, 2024

  • Fix build in NetBSD from the renaming done in b74673f.
  • Simplify the ProcessTable_goThroughEntries() and also apply the fixes for the compiler warning.
    netbsd/NetBSDProcessTable.c: In function 'NetBSDProcessTable_scanProcs':
    netbsd/NetBSDProcessTable.c:185:53: warning: comparison is always true due to limited range of data type [-Wtype-limits]
             const char* name = ((int64_t)kproc->p_tdev != (int64_t)KERN_PROC_TTY_NODEV) ? devname(kproc->p_tdev, S_IFCHR): NULL;
    
    The fix came in as part of the discussion here.

@fraggerfox fraggerfox marked this pull request as ready for review January 1, 2024 12:53
@Explorer09
Copy link
Copy Markdown
Contributor

Do you have a build log, i.e. a list of compiler warnings and errors of your build from the original code? That would save us time reviewing the code.

@fraggerfox
Copy link
Copy Markdown
Contributor Author

fraggerfox commented Jan 1, 2024

Do you have a build log, i.e. a list of compiler warnings and errors of your build from the original code? That would save us time reviewing the code.

Yes, this makes sense, I should have added it when I was making PR. 🤦

@fraggerfox
Copy link
Copy Markdown
Contributor Author

netbsd/NetBSDProcess.c: In function 'NetBSDProcess_rowWriteField':
netbsd/NetBSDProcess.c:240:26: error: incompatible type for argument 1 of 'Process_writeField'
       Process_writeField(np->super, str, field);
                          ^~
In file included from ./netbsd/NetBSDProcess.h:17:0,
                 from netbsd/NetBSDProcess.c:13:
./Process.h:219:6: note: expected 'const Process * {aka const struct Process_ *}' but argument is of type 'Process {aka const struct Process_}'
 void Process_writeField(const Process* row, RichString* str, ProcessField field);
      ^~~~~~~~~~~~~~~~~~
*** [netbsd/NetBSDProcess.o] Error code 1

make[1]: stopped in /usr/pkgsrc-current/wip/htop-git/work/htop-c3b4a770c02c28662980014b5a893e01451ec2b2
--- netbsd/NetBSDMachine.o ---
netbsd/NetBSDMachine.c: In function 'NetBSDMachine_updateCPUcount':
netbsd/NetBSDMachine.c:84:7: error: 'opl' undeclared (first use in this function); did you mean 'open'?
       opl->cpuData = xReallocArray(this->cpuData, value + 1, sizeof(CPUData));
       ^~~
       open
netbsd/NetBSDMachine.c:84:7: note: each undeclared identifier is reported only once for each function it appears in
netbsd/NetBSDMachine.c: In function 'Machine_new':
netbsd/NetBSDMachine.c:130:11: warning: return from incompatible pointer type [-Wincompatible-pointer-types]
    return this;
           ^~~~
netbsd/NetBSDMachine.c: In function 'Machine_scan':
netbsd/NetBSDMachine.c:271:4: warning: implicit declaration of function 'NetBSDProcessTable_scanMemoryInfo'; did you mean 'NetBSDMachine_scanMemoryInfo'? [-Wimplicit-function-declaration]
    NetBSDProcessTable_scanMemoryInfo(this);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    NetBSDMachine_scanMemoryInfo
netbsd/NetBSDMachine.c:272:4: warning: implicit declaration of function 'NetBSDProcessTable_scanCPUTime'; did you mean 'NetBSDMachine_scanCPUTime'? [-Wimplicit-function-declaration]
    NetBSDProcessTable_scanCPUTime(this);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    NetBSDMachine_scanCPUTime
netbsd/NetBSDMachine.c:275:7: warning: implicit declaration of function 'NetBSDProcessTable_scanCPUFrequency'; did you mean 'NetBSDMachine_scanCPUFrequency'? [-Wimplicit-function-declaration]
       NetBSDProcessTable_scanCPUFrequency(npl);
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       NetBSDMachine_scanCPUFrequency
netbsd/NetBSDMachine.c:275:43: error: 'npl' undeclared (first use in this function); did you mean 'nl'?
       NetBSDProcessTable_scanCPUFrequency(npl);
                                           ^~~
                                           nl
At top level:
netbsd/NetBSDMachine.c:222:13: warning: 'NetBSDMachine_scanCPUFrequency' defined but not used [-Wunused-function]
 static void NetBSDMachine_scanCPUFrequency(NetBSDMachine* this) {
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
netbsd/NetBSDMachine.c:197:13: warning: 'NetBSDMachine_scanCPUTime' defined but not used [-Wunused-function]
 static void NetBSDMachine_scanCPUTime(NetBSDMachine* this) {
             ^~~~~~~~~~~~~~~~~~~~~~~~~
netbsd/NetBSDMachine.c:145:13: warning: 'NetBSDMachine_scanMemoryInfo' defined but not used [-Wunused-function]
 static void NetBSDMachine_scanMemoryInfo(NetBSDMachine* this) {
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
*** [netbsd/NetBSDMachine.o] Error code 1

Relevant section of the build log showing the failure.

Comment thread netbsd/NetBSDProcessTable.c
@BenBE BenBE added bug 🐛 Something isn't working NetBSD 🎏 NetBSD related issues labels Jan 2, 2024
Copy link
Copy Markdown
Member

@BenBE BenBE left a comment

Choose a reason for hiding this comment

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

Just a very small idea. Apart from this the changes look reasonable.

IIRC there was a similar PR done for FreeBSD/OpenBSD already. Maybe compare there too for changes.

Comment thread netbsd/NetBSDProcessTable.c Outdated
@fraggerfox fraggerfox changed the title Fix build in NetBSD. Fix build errors and warnings in NetBSD. Jan 7, 2024
Copy link
Copy Markdown
Member

@BenBE BenBE left a comment

Choose a reason for hiding this comment

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

LGTM.

@BenBE BenBE merged commit f9fb93a into htop-dev:main Jan 9, 2024
@fraggerfox fraggerfox deleted the fix-netbsd-build branch January 9, 2024 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐛 Something isn't working NetBSD 🎏 NetBSD related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants