This is an archive of the discontinued LLVM Phabricator instance.

Size and element numbers are often swapped when calling calloc
AbandonedPublic

Authored by gAlfonso-bit on Apr 21 2023, 2:00 PM.

Details

Reviewers
MaskRay

Diff Detail

Event Timeline

gAlfonso-bit created this revision.Apr 21 2023, 2:00 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 21 2023, 2:00 PM
Herald added a subscriber: Enna1. · View Herald Transcript
gAlfonso-bit requested review of this revision.Apr 21 2023, 2:00 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 21 2023, 2:00 PM
Herald added subscribers: Restricted Project, cfe-commits, jdoerfert. · View Herald Transcript
MaskRay requested changes to this revision.EditedApr 21 2023, 2:24 PM

This is an unnecessary change. The arguments are interchangeable.
In musl, there are at least 2 places where the parameters could be swapped, but I not unsure this warrants a commit.

This revision now requires changes to proceed.Apr 21 2023, 2:24 PM
vzakhari added a subscriber: vzakhari.EditedApr 21 2023, 2:40 PM

This is an unnecessary change. The arguments are interchangeable.
In musl, there are at least 2 places where the parameters could be swapped, but I not unsure this warrants a commit.

Isn't the memory alignment dependent on the element size in general? In this case it might be a potential correctness issue fix.
I understand that many calloc implementations may align them to works-for-all boundary, but it may still worth be "fixing".

This is an unnecessary change. The arguments are interchangeable.
In musl, there are at least 2 places where the parameters could be swapped, but I not unsure this warrants a commit.

Isn't the memory alignment dependent on the element size in general? In this case it might be a potential correctness issue fix.
I understand that many calloc implementations may align them to works-for-all boundary, but it may still worth be "fixing".

No. The two arguments are interchangeable. Neither argument affects the alignment. Use aligned_alloc to control alignment.

gAlfonso-bit abandoned this revision.Sep 27 2023, 11:16 AM
gAlfonso-bit edited the summary of this revision. (Show Details)