Opened 2 months ago

Closed 4 weeks ago

Last modified 4 weeks ago

#70702 closed enhancement (fixed)

Provide a compatibility wrapper for scandir in legacy-support

Reported by: fhgwright (Fred Wright) Owned by: fhgwright (Fred Wright)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: mascguy (Christopher Nielsen), barracuda156
Port: legacy-support

Description

The signature for scandir() changed between the 10.7 and 10.8 SDKs, causing a pointer-type mismatch in some builds. This is usually just a warning, but gcc14 started treating this as an error by default, causing broken builds.

The fix should consist of creating a wrapper function to "launder" the argument type, and then optionally defining scandir as a macro expanding to the wrapper. This can't be done unconditionally, since that could break anything that assumes the default behavior.

Change History (2)

comment:1 Changed 4 weeks ago by fhgwright (Fred Wright)

Resolution: fixed
Status: assignedclosed

In 866a0807191148098974d0f502a9409b49fb46e0/macports-legacy-support (master):

Add scandir() compatibility feature.

This adds a wrapper to make the scandir() 'compar' argument and the
provided alphasort() function match the types used in 10.8+, thereby
avoiding warnings, and in some cases errors, due to the pointer type
mismatch.

To avoid breaking code expecting the old behavior, this hack is only
applied when _MACPORTS_LEGACY_COMPATIBLE_SCANDIR is defined nonzero.

Closes: #70702

TESTED:
Tests pass on all OS versions with this fix.

comment:2 Changed 4 weeks ago by fhgwright (Fred Wright)

In d546d8ad537ed152740566caa8fc2d303940d2c9/macports-legacy-support (master):

Add test for scandir() 'compar' type.

This tests for the pointer-type mismatch issue with the scandir()
'compar' arg. There are two versions, one verifying the expected old
behavior, and another verifying the fix.

See: #70702

Also adds alphasort() and scandir() to the darwin_c tests.

TESTED:
Fails or gets warning on <10.8 without fix. Passes with fix.

Note: See TracTickets for help on using tickets.