Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libxo for devinfo #1450

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open

libxo for devinfo #1450

wants to merge 45 commits into from

Conversation

ktullavik
Copy link

@ktullavik ktullavik commented Oct 6, 2024

This was more involved and invasive than I imagened. But I think I've done what I can now, at least without guidance/review. "Works for me".

@bsdimp
Copy link
Member

bsdimp commented Oct 6, 2024

Oh! This is one on my list! I'll review this in detail, but it may be towards the end of the week...

@ktullavik
Copy link
Author

Thanks @bsdimp , I actually got it from the list of ideas on your website.

usr.sbin/devinfo/devinfo.c Outdated Show resolved Hide resolved
usr.sbin/devinfo/devinfo.c Outdated Show resolved Hide resolved
usr.sbin/devinfo/devinfo.c Outdated Show resolved Hide resolved
usr.sbin/devinfo/devinfo.c Outdated Show resolved Hide resolved
usr.sbin/devinfo/devinfo.c Outdated Show resolved Hide resolved
printf(" ");
printf("%s:\n", rman->dm_desc);

safe_desc = (char*) malloc(sizeof(rman->dm_desc));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sizeof or strlen here?


/* print resources */
ia->indent = indent + 4;
devinfo_foreach_rman_resource(rman,
print_device_matching_resource, ia);
print_device_matching_resource, ia);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the indentation was right before. We do 4 space continuation lines.

usr.sbin/devinfo/devinfo.c Outdated Show resolved Hide resolved
@@ -168,8 +270,13 @@ print_device(struct devinfo_dev *dev, void *arg)
}
}

return(devinfo_foreach_device_child(dev, print_device,
int ret = (devinfo_foreach_device_child(dev, print_device,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style(9) (man style) says that ret should be declared at the start of the block.

usr.sbin/devinfo/devinfo.c Outdated Show resolved Hide resolved
print_resource(res);
struct devinfo_rman *rman;
int hexmode;
char s[32];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 32? Is there a #define that can be used here?


if (hexmode) {
if (res->dr_size > 1)
snprintf(s, 32, "0x%lx-0x%lx",
Copy link
Member

@bsdimp bsdimp Oct 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sizeof(s) is better. but this isn't 32, but really 5 ("0x-0x") + 1 NUL + 2 * (sizeof(long) * 2) so this can be at most 38, so 32 is a little small... and I think this is the longest one.

printf("%s:\n", rman->dm_desc);
char* safe_desc;

safe_desc = (char*) malloc(sizeof(rman->dm_desc));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question as above. sizeof vs strlen?

static void
print_device_path_entry(struct devinfo_dev *dev, const char* devname) {
xo_open_container(devname);
if (open_tag_index >= MAX_OPEN_TAGS) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, why 32 nesting limit?

@bsdimp
Copy link
Member

bsdimp commented Oct 7, 2024

So I think this is generally OK. There's a number of mostly style issues, and a few more substantive things that should be easy to fix.

Though the commit breakup needs a lot of work. There's a fair number of cleanup changes can be separated out before the XO-ification can be done...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants