Page MenuHomeFreeBSD

sesutil: don't malloc in a tight loop
ClosedPublic

Authored by asomers on Feb 9 2023, 10:24 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jan 5, 7:14 AM
Unknown Object (File)
Sun, Dec 22, 5:49 AM
Unknown Object (File)
Fri, Dec 13, 8:23 PM
Unknown Object (File)
Nov 23 2024, 6:00 PM
Unknown Object (File)
Nov 22 2024, 6:41 AM
Unknown Object (File)
Nov 22 2024, 5:51 AM
Unknown Object (File)
Nov 22 2024, 5:13 AM
Unknown Object (File)
Nov 20 2024, 12:14 AM
Subscribers

Details

Summary

Reported by: mav
MFC after: 1 week
Sponsored by: Axcient

Test Plan

Ran all subcommands with valgrind

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I have no objections, just some comments to polish.

usr.sbin/sesutil/sesutil.c
496–497

You've left this assignment here, but removed elm_names_size assignment below. Moving this up would look cleaner. I was thinking about some constant, but if variable assignment would be moved up and passed as a variable to malloc(), it would be less needed.

This revision is now accepted and ready to land.Feb 13 2023, 2:48 PM
usr.sbin/sesutil/sesutil.c
496–497

Actually, elm_desc_len is a R/W argument to ENCIOC_GETELMDESC. On entry, it indicates the space available in elm_devnames. On return, it indicates the size of the string, which is not nul-terminated. That's why I have to set it here instead of next to the calloc.

This revision was automatically updated to reflect the committed changes.