Re: [PATCH 2/4] ld: Refactor input_statement_is_archive_path() to not touch its argument

Project / Subsystem

binutils / ld

Date

2026-05-02

Proposer

Calvin Owens <calvin@wbinvd.org>

Source type

public_inbox

Consensus

Proposed

Sentiment

/10

Technical tradeoffs

  • Eliminates unnecessary memory allocation.
  • Improves code safety by preventing modification of input arguments.
  • Increases code clarity and maintainability.

All attributes

project
binutils
subsystem
ld
patch_id
discussion_id
afXK1aC_OSpZlefr@mozart.vkv.me
source_type
public_inbox
title
Re: [PATCH 2/4] ld: Refactor input_statement_is_archive_path() to not touch its argument
headline
Ld: Refactor input_statement_is_archive_path() to not touch its argument
tldr
The linker's input_statement_is_archive_path function is refactored to avoid modifying its input argument, improving code safety.
proposer
Calvin Owens <calvin@wbinvd.org>
consensus
Proposed
outcome
proposed
sentiment_score
technical_tradeoffs
  • Eliminates unnecessary memory allocation.
  • Improves code safety by preventing modification of input arguments.
  • Increases code clarity and maintainability.
series_id
binutils:ld: refactor input_statement_is_archive_path() to not touch its argument
series_role
reply
series_parts
  • {"title":"ld: Refactor input_statement_is_archive_path() to not touch its argument","url":"https://inbox.sourceware.org/binutils/afWwkUQyfAvTUGTw@squeak.grove.modra.org"}
tags
  • ld
  • refactoring
  • const correctness
  • linker
  • code safety
bugzilla_url
date
2026-05-02T00:00:00.000Z

Re: [PATCH 2/4] ld: Refactor input_statement_is_archive_path() to not touch its argument

This patch refactors the input_statement_is_archive_path function in the linker to avoid modifying its input argument file_spec. Alan Modra applied a modified version of Calvin Owens’ original patch, eliminating an unnecessary copy of the input string. The refactoring involves assigning the result of strchr to a const char* and ensuring archive_path returns a const char*. This prevents unintended side effects and improves the overall safety and maintainability of the code.