[PATCH v10 1/4] elf: Add la_activity during application exit

Florian Weimer fweimer@redhat.com
Fri Jan 21 10:50:36 GMT 2022


* Adhemerval Zanella via Libc-alpha:

> +static int
> +do_test (int argc, char *argv[])
> +{
> +  /* We must have either:
> +     - One our fource parameters left if called initially:
> +       + path to ld.so         optional
> +       + "--library-path"      optional
> +       + the library path      optional
> +       + the application name  */
> +  if (restart)
> +    return handle_restart ();
> +
> +  char *spargv[9];
> +  int i = 0;
> +  for (; i < argc - 1; i++)
> +    spargv[i] = argv[i + 1];
> +  spargv[i++] = (char *) "--direct";
> +  spargv[i++] = (char *) "--restart";
> +  spargv[i] = NULL;

Please add a check for an out-of-range argc value, or allocate the array
on the heap.

> +  while (xgetline (&buffer, &buffer_length, out))
> +    {
> +      if (startswith (buffer, "la_activity: "))
> +	{
> +	  uintptr_t cookie;
> +	  int this_act;
> +	  int r = sscanf (buffer + strlen ("la_activity: "),
> +			  "%d %"SCNxPTR"", &this_act, &cookie);
> +	  TEST_COMPARE (r, 2);

I wonder if you can fold the startswith check into the sscanf.  At least
you could put "la_activity: " into the format string.

Thanks,
Florian



More information about the Libc-alpha mailing list