freebsd-src icon indicating copy to clipboard operation
freebsd-src copied to clipboard

which: Use size_t instead of ssize_t for pathlen

Open collinfunk opened this issue 1 year ago • 1 comments

The "pathlen" variable is the return value of strlen(3) and is then passed as an argument to malloc(3) and memcpy(3). The size_t type matches the prototype for these functions. The size_t type is unsigned so it can fit larger $PATH values than ssize_t. However, In practice ssize_t should be larger enough so this change is just for clarity.

collinfunk avatar Feb 11 '24 04:02 collinfunk

this seems sensible. I'm surprised it's not been throwing a warning

I think it might have thrown -Wsign-compare if it started to be used for comparison. I assume that's probably turned off in most places because it would cause meaningless (mostly) spam with old code. I just noticed it while looking at something else and it annoyed me. :)

collinfunk avatar Feb 12 '24 00:02 collinfunk

Merged in 8268a31bcceb9ebe32d380cab792c89c5d897d15, thank you.

markjdb avatar Apr 05 '24 18:04 markjdb