On Friday 21 June 2013 01:52:20 Thomas De Schampheleire wrote:
> --- a/procps/lsof.c
> +++ b/procps/lsof.c
> @@ -61,12 +61,24 @@ int lsof_main(int argc UNUSED_PARAM, cha
> d_fd = opendir(name);
> if (d_fd) {
> while ((entry = readdir(d_fd)) != NULL) {
> - if (entry->d_type == DT_LNK) {
> - safe_strncpy(name + baseofs,
> entry->d_name, 10);
> - fdlink = xmalloc_readlink(name);
> - printf("%d\t%s\t%s\n", proc->pid,
> proc->exe, fdlink);
> - free(fdlink);
> + safe_strncpy(name + baseofs, entry->d_name, 10);
> +
> + if (entry->d_type == DT_UNKNOWN) {
it's too bad busybox doesn't have unlikely() as this would be a good place to
slap that
i would rewrite the code a little to avoid the constant strncpy (assuming it
doesn't severely impact code size):
while (...) {
if (entry->d_type != DT_UNKNOWN && entry->d_type != DT_LNK)
continue;
safe_strncpy(name + baseofs, entry->d_name, 10);
if (entry->d_type == DT_UNKNOWN) {
... new lstat logic ...
}
... readlink + printf ...
}
-mike
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
