Skip to content

Remove unused function in pipe.c - #14

Merged
jserv merged 1 commit into
sysprog21:mainfrom
G36maid:llvm
Oct 23, 2025
Merged

Remove unused function in pipe.c#14
jserv merged 1 commit into
sysprog21:mainfrom
G36maid:llvm

Conversation

@G36maid

@G36maid G36maid commented Jul 7, 2025

Copy link
Copy Markdown
Contributor

This PR fixes build errors for building Linmo with the LLVM toolchain.
related to #2 , #12

Changes

  • Fixes build errors for LLVM:
    • Mark pipe byte helpers as UNUSED in kernel/pipe.c

Comment thread arch/riscv/build.mk Outdated

@jserv jserv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Always write complete English sentences in Git commit messages.

@jserv jserv changed the title Add LLVM Toolchain Support to RISC-V Build System Support LLVM Toolchain Jul 7, 2025
Comment thread arch/riscv/build.mk Outdated
Comment thread arch/riscv/build.mk Outdated
Comment thread arch/riscv/build.mk Outdated
@G36maid
G36maid force-pushed the llvm branch 2 times, most recently from d096b17 to 1f54ad2 Compare July 7, 2025 06:37
Comment thread arch/riscv/build.mk Outdated
Comment thread arch/riscv/build.mk Outdated
Comment thread kernel/pipe.c Outdated
Comment thread arch/riscv/build.mk Outdated
@jserv

This comment was marked as duplicate.

Comment thread kernel/pipe.c Outdated
}

static inline void pipe_put_byte(pipe_t *p, char c)
static inline __attribute__((__unused__)) void pipe_put_byte(pipe_t *p, char c)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It looks like these two functions have no callers.
Why are we adding compiler attributes here instead of just removing them?

Comment thread arch/riscv/build.mk Outdated
CFLAGS += -Wall -Wextra -Wshadow -Wno-unused-parameter -Werror
CROSS_COMPILE ?= riscv32-unknown-elf-
CC_DEFAULT := $(CROSS_COMPILE)gcc
CC_IS_CLANG := $(shell $(CC_DEFAULT) --version 2>/dev/null | grep -qi clang && echo 1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I find this approach a bit odd. Why append the gcc suffix and then check for clang? It feels a bit roundabout.

@G36maid
G36maid marked this pull request as draft October 22, 2025 16:15
@G36maid
G36maid marked this pull request as ready for review October 22, 2025 17:21
@G36maid
G36maid requested a review from jserv October 22, 2025 17:21

@visitorckw visitorckw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

So what I'm seeing now is just one commit that marks the functions as unused using a compiler attribute, but this doesn't seem to line up with the PR title 'LLVM support'?

And again, where is this function intended to be used? What is the reason for marking these functions with a compiler attribute instead of removing them entirely?

Without an explanation for this, this is a NAK from me.

@G36maid G36maid changed the title Support LLVM Toolchain Fix LLVM warnings by marking unused pipe functions Oct 22, 2025
@G36maid

G36maid commented Oct 22, 2025

Copy link
Copy Markdown
Contributor Author

These functions are currently unused and I don’t intend to use them.
@jserv suggested marking them as UNUSED to avoid LLVM warnings.

If you prefer that I remove them entirely, I can do that instead.

@visitorckw

Copy link
Copy Markdown
Collaborator

These functions are currently unused and I don’t intend to use them. @jserv suggested marking them as UNUSED to avoid LLVM warnings.

I think he was just expressing a preference for __attribute__((__unused__)) vs UNUSED, rather than an opinion on removing vs adding compiler attributes?

If you prefer that I remove them entirely, I can do that instead.

I'm not necessarily against keeping these functions. But if we really decide to keep them, I do really think we need to explain why we need to keep them - under what circumstances they are valuable or how they will be used in future plans - rather than mindlessly adding attributes as a workaround.

@visitorckw visitorckw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also, the term "certain configurations" is way too confusing. Specifically, what configurations are we talking about? The changelog needs improvement.

@G36maid

G36maid commented Oct 22, 2025

Copy link
Copy Markdown
Contributor Author

I agree with the compiler warning here.
These functions are currently unused, and I’ll remove them.

The CI pipeline can also help prevent similar unused functions from being introduced in future PRs.

Remove unused function  pipe_get_byte and pipe_put_byte
@G36maid G36maid changed the title Fix LLVM warnings by marking unused pipe functions Remove unused function in pipe.c Oct 22, 2025
@jserv
jserv merged commit 9c0420d into sysprog21:main Oct 23, 2025
@jserv

jserv commented Oct 23, 2025

Copy link
Copy Markdown
Contributor

Thank @G36maid for contributing!

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.

3 participants