[DTrace-devel] [PATCH 13/17] fbt, syscall: use getline(), not fgets()
Eugene Loh
eugene.loh at oracle.com
Thu Sep 1 21:38:38 UTC 2022
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
with one question:
On 8/10/22 18:07, Nick Alcock via DTrace-devel wrote:
> diff --git a/libdtrace/dt_prov_fbt.c b/libdtrace/dt_prov_fbt.c
> @@ -77,27 +77,16 @@ static int populate(dtrace_hdl_t *dtp)
>
> - while (fgets(buf, sizeof(buf), f)) {
> + while (getline(&buf, &n, f) >= 0) {
> /*
> * Here buf is either "funcname\n" or "funcname [modname]\n".
> + * The last line may not have a linefeed.
> */
> p = strchr(buf, '\n');
> if (p) {
> *p = '\0';
> if (p > buf && *(--p) == ']')
> *p = '\0';
> - } else {
> - /*
> - * If we didn't see a newline, the line was too long.
> - * Report it, and skip until the end of the line.
> - */
> - fprintf(stderr, "%s: Line too long: %s\n",
> - PROBE_LIST, buf);
> -
> - do
> - fgets(buf, sizeof(buf), f);
> - while (strchr(buf, '\n') == NULL);
> - continue;
> }
Is there a pre-existing problem here? What if the last line does not
have a linefeed? Do we then fail to strip off the trailing ']'?
More information about the DTrace-devel
mailing list