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

core: Explicitly cast void* to char* #2191

Closed

Conversation

jamesaimonetti
Copy link
Contributor

When compiling a custom module, including shm_mem.h caused the
following compilation error:

In file included from ../../core/mem/shm_mem.h:32,
from custom_code.cpp:40:
../../core/parser/../ut.h: In function ‘char* shm_char_dup(const char*)’:
../../core/mem/shm.h:67:49: error: invalid conversion from ‘void*’ to ‘char*’ [-fpermissive]
67 | # define shm_malloc(s) _shm_root.xmalloc(_shm_root.mem_block, (s))
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| void*
../../core/parser/../ut.h:811:9: note: in expansion of macro ‘shm_malloc’
811 | rval = shm_malloc(len);
| ^~~~~~~~~~

gcc version: gcc (Debian 9.2.1-22) 9.2.1 20200104

Pre-Submission Checklist

  • Commit message has the format required by CONTRIBUTING guide
  • Commits are split per component (core, individual modules, libs, utils, ...)
  • Each component has a single commit (if not, squash them into one commit)
  • No commits to README files for modules (changes must be done to docbook files
    in doc/ subfolder, the README file is autogenerated)

Type Of Change

  • Small bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds new functionality)
  • Breaking change (fix or feature that would change existing functionality)

Checklist:

  • PR should be backported to stable branches
  • Tested changes locally
  • Related to issue #XXXX (replace XXXX with an open issue number)

Description

When compiling a custom module, including `shm_mem.h` caused the
following compilation error:

In file included from ../../core/mem/shm_mem.h:32,
                 from custom_code.cpp:40:
../../core/parser/../ut.h: In function ‘char* shm_char_dup(const char*)’:
../../core/mem/shm.h:67:49: error: invalid conversion from ‘void*’ to ‘char*’ [-fpermissive]
   67 | # define shm_malloc(s)         _shm_root.xmalloc(_shm_root.mem_block, (s))
      |                                ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                 |
      |                                                 void*
../../core/parser/../ut.h:811:9: note: in expansion of macro ‘shm_malloc’
  811 |  rval = shm_malloc(len);
      |         ^~~~~~~~~~

gcc version: `gcc (Debian 9.2.1-22) 9.2.1 20200104`
@jamesaimonetti jamesaimonetti changed the title Explicitly cast void* to char* core: Explicitly cast void* to char* Jan 7, 2020
miconda pushed a commit that referenced this pull request Jan 8, 2020
@miconda
Copy link
Member

miconda commented Jan 8, 2020

Thanks! I pushed the patch manually, because the commit message was not formatted properly (the subject of PR has the format for the commit message):

@miconda miconda closed this Jan 8, 2020
@jamesaimonetti jamesaimonetti deleted the cast-to-char-star branch January 8, 2020 16:19
@jamesaimonetti
Copy link
Contributor Author

@miconda thanks! Noted on the commit message. To clarify for me, what I put should have been a comment here on the PR and not in the commit message itself, yes?

@miconda
Copy link
Member

miconda commented Jan 8, 2020

It is about the first line of the commit messages which should be prefixed with the component name. The title of PR is:

core: Explicitly cast void* to char*

which is fine for first line of a commit message.

But your commit message had the first line:

Explicitly cast void* to char*

not indicating the component (core in this case).

You had another PR where the commit message was formatted ok.

@jamesaimonetti
Copy link
Contributor Author

Ah right, I submitted the PR before reviewing the commit requirements, then editing the PR itself not the commit message. Thanks again for the feedback.

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.

None yet

2 participants