Re: undefined references since newlib-3.2.0
Keith Packard via Newlib <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
Josef Wolf <[email protected]> writes: > I don't really understand this. The classical way to return error from > functions returning a pointer is to return NULL. One has to make sure not to > leak, of course. Which return values would be needed beyond NULL? The issue is that you need to reflect the allocation error all the way up to the initial libc entry point, and you need to use a defined error return value at that point, preferably one which indicates that the library had an internal allocation failure. Here are some affected libc functions which don't return a pointer and which have no error indication of any kind: atof atoff These are defined to just return strtod/strtof, so they continue to inherit whatever those functions do. Which is now: These have errnos defined, but those do not include ENOMEM: strtod strtof strtold wcstod wcstold strtodg These now return infinity and set errno to ERANGE on allocation failure. (not ideal, but the options are limited) Here are some which do return a pointer, but do not document any errors: ecvt fcvt gcvt ecvtbuf fcvtbuf gcvtbuf These now can return NULL on allocation failure. They do not set errno. And here's a list of functions which I feel reasonable applications should not expect an allocation error from: sprintf snprintf sscanf These return EOF on allocation failure. I wasn't too concerned with the exact semantics as there are no good answers when libc uses malloc in these functions, so once I had eliminated the internal aborts, I moved on to adding the ryu conversion code to tinystdio to eliminate allocation in that path entirely. -- -keith
signature.asc
(application/pgp-signature, 832 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEw4O3eCVWE9/bQJ2R2yIaaQAAABEFAl7lCvYACgkQ2yIaaQAA ABF66xAAtC+QwkEWyf3A23gw33GFrPjXYZFs5v3JFENYiscSCcrbthZOnk+It+tv 4L6ssuxUrXxn7T4Bf+tJ0X3EGEeGEdGiUYUnG+WINrntCS+Zb2YaHaimXhkM3AQl kWcQ10wWgcKswsByT6dmc+t0+0+F8tvuLCbLqxmzPfh3RkFydfB56ev5kiDRoXNN u7/8Yr0CEOC81uhkgGPSfip9QHrQGkvH93OoP62fpHuF5Tdq9KIwYw0/JGP/b7jH fn3yQOEB/Pb2FufoapWWxrcp3wIldMGuyACSAUEOe4QjJOIeiJs2+nSrDbFuFVxQ hn9ov76ngPpje2G6AEso30eUb7m/pzkgexen8WsB2xmgjo5edPVnmmSUay26d1HE ByBE/EDDdHRckkyfkogLknTMWNtWTT5HsmEvHac3f6V/b8k5kvyRzMkeUsUQyhZh lpgBs9dQlARYyVP65AqhPGbB14MnlUg4unJDDnMf/xhCWGFRUpVZ0R0hDBlddEJI BUp+J6rlrzZHKwWVQlb0JUa31w9ozxcHXIxTTSuc7o2jzhX/iNcZSSwJpFfBKsJG r87e3mq6LwYmXMFHUmgBTdCpSLaUWv9rlR9puTnFwCcE0JsgCSvTZjY9ntdFvZyv 70zhDlaCjw/hZ8bTxeojuaL/0ncuNYyUt/fr70av7GmRXG/DdO8= =NgEh -----END PGP SIGNATURE-----