Commit 058a0f0
committed
liblibc: Fix prototype of functions taking
The execv family of functions do not modify their arguments, so they do
not need mutable pointers. The C prototypes take a constant array of
mutable C-strings, but that's a legacy quirk from before C had const
(since C string literals have type `char *`). The Rust prototypes had
`*mut` in the wrong place, anyway: to match the C prototypes, it should
have been `*const *mut c_char`. But it is safe to pass constant strings
(like string literals) to these functions.
getopt is a special case, since GNU getopt modifies its arguments
despite the `const` claim in the prototype. It is apparently only
well-defined to call getopt on the actual argc and argv parameters
passed to main, anyway. Change it to take `*mut *mut c_char` for an
attempt at safety, but probably nobody should be using it from Rust,
since there's no great way to get at the parameters as passed to main.
Also fix the one caller of execvp in libstd, which now no longer needs
an unsafe cast.
Fixes #16290.char *const argv[]
1 parent a951569 commit 058a0f0
2 files changed
+19
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5493 | 5493 | | |
5494 | 5494 | | |
5495 | 5495 | | |
5496 | | - | |
| 5496 | + | |
5497 | 5497 | | |
5498 | | - | |
5499 | | - | |
| 5498 | + | |
| 5499 | + | |
5500 | 5500 | | |
5501 | 5501 | | |
5502 | 5502 | | |
5503 | | - | |
| 5503 | + | |
5504 | 5504 | | |
5505 | | - | |
5506 | | - | |
| 5505 | + | |
| 5506 | + | |
5507 | 5507 | | |
5508 | 5508 | | |
5509 | 5509 | | |
| |||
5687 | 5687 | | |
5688 | 5688 | | |
5689 | 5689 | | |
5690 | | - | |
5691 | | - | |
5692 | | - | |
| 5690 | + | |
| 5691 | + | |
| 5692 | + | |
5693 | 5693 | | |
5694 | 5694 | | |
5695 | | - | |
| 5695 | + | |
5696 | 5696 | | |
5697 | 5697 | | |
5698 | 5698 | | |
| |||
5702 | 5702 | | |
5703 | 5703 | | |
5704 | 5704 | | |
5705 | | - | |
| 5705 | + | |
| 5706 | + | |
| 5707 | + | |
5706 | 5708 | | |
5707 | 5709 | | |
5708 | 5710 | | |
| |||
5752 | 5754 | | |
5753 | 5755 | | |
5754 | 5756 | | |
5755 | | - | |
5756 | | - | |
5757 | | - | |
| 5757 | + | |
| 5758 | + | |
| 5759 | + | |
5758 | 5760 | | |
5759 | 5761 | | |
5760 | | - | |
| 5762 | + | |
5761 | 5763 | | |
5762 | 5764 | | |
5763 | 5765 | | |
5764 | 5766 | | |
5765 | 5767 | | |
5766 | 5768 | | |
5767 | | - | |
| 5769 | + | |
5768 | 5770 | | |
5769 | 5771 | | |
5770 | 5772 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
316 | | - | |
| 316 | + | |
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
| |||
0 commit comments