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

Fix warnings regarding pointer arithmetics with void * #105

Closed
wants to merge 1 commit into from

Conversation

krlmlr
Copy link

@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
@@ -678,7 +678,7 @@ coff_add (struct backtrace_state *state, int descriptor,
sects_view_valid = 1;
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);

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
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
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