Skip to content

Fix warnings regarding pointer arithmetics with void *#105

Closed
krlmlr wants to merge 1 commit intoianlancetaylor:masterfrom
krlmlr:b-pointer-arith
Closed

Fix warnings regarding pointer arithmetics with void *#105
krlmlr wants to merge 1 commit intoianlancetaylor:masterfrom
krlmlr:b-pointer-arith

Conversation

@krlmlr
Copy link
Copy Markdown

@krlmlr krlmlr commented Jan 31, 2023

Compiling with -Wpointer-arith triggers the following warnings:

  pecoff.c:647:37: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
  pecoff.c:681:22: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
  pecoff.c:721:45: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]

johnsonjh added a commit to johnsonjh/libbacktrace that referenced this pull request Feb 2, 2023
Comment thread pecoff.c
opt_hdr = (const b_coff_optional_header *) sects_view.data;
sects = (const b_coff_section_header *)
(sects_view.data + fhdr.size_of_optional_header);
(void *)((const char *)sects_view.data + fhdr.size_of_optional_header);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

...so, including the unchanged one on the previous line, that's what, 3 casts in a row here? I wonder if there's a way to make that more efficient?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Casts don't carry any runtime cost, so there is efficiency issue here.

@ianlancetaylor
Copy link
Copy Markdown
Owner

Thanks. I committed a version of your change upstream and merged the patch back into this repo in 6ce91a2.

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.

3 participants