Allocator sizeof operand mismatch (src/backend/regex/regcomp.c)

Started by Ranier Vilelaabout 4 years ago4 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

appliesbuild failedCI history

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t46359_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t46359_1 && git checkout t46359_1

Patchset v1 (message #1) is on t46359_1

Jump to latest
#1Ranier Vilela
ranier.vf@gmail.com

Hi,

About the error:
Result of 'malloc' is converted to a pointer of type 'char', which is
incompatible with sizeof operand type 'struct guts'

The patch attached tries to fix this.

regards,
Ranier Vilela

Attachments:

t46359_1
001-fix-allocator-sizeof-operand-mismatch.patchtext/x-patch; charset=US-ASCII; name=001-fix-allocator-sizeof-operand-mismatch.patchDownload+1-1
#2Zhang Mingli
zmlpostgres@gmail.com
In reply to: Ranier Vilela (#1)
Re: Allocator sizeof operand mismatch (src/backend/regex/regcomp.c)

I think it’s ok, re_guts is converted when  used

(struct guts *) re->re_guts;

And there is comments in regex.h

char *re_guts; /* `char *' is more portable than `void *' */

Regards,
Zhang Mingli

Show quoted text

On Aug 6, 2022, 20:13 +0800, Ranier Vilela <ranier.vf@gmail.com>, wrote:

Hi,

About the error:
Result of 'malloc' is converted to a pointer of type 'char', which is incompatible with sizeof operand type 'struct guts'

The patch attached tries to fix this.

regards,
Ranier Vilela

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Zhang Mingli (#2)
Re: Allocator sizeof operand mismatch (src/backend/regex/regcomp.c)

Zhang Mingli <zmlpostgres@gmail.com> writes:

I think it’s ok, re_guts is converted when  used
(struct guts *) re->re_guts;
And there is comments in regex.h
char *re_guts; /* `char *' is more portable than `void *' */

Boy, that comment is showing its age isn't it? If we were to do
anything about this, I'd be more inclined to change re_guts to void*.
But, never having seen any compiler warnings about this code,
I don't feel a strong need to do something.

regards, tom lane

#4Zhang Mingli
zmlpostgres@gmail.com
In reply to: Tom Lane (#3)
Re: Allocator sizeof operand mismatch (src/backend/regex/regcomp.c)

On Aug 6, 2022, 22:47 +0800, Tom Lane <tgl@sss.pgh.pa.us>, wrote:

Zhang Mingli <zmlpostgres@gmail.com> writes:

I think it’s ok, re_guts is converted when  used
(struct guts *) re->re_guts;
And there is comments in regex.h
char *re_guts; /* `char *' is more portable than `void *' */

Boy, that comment is showing its age isn't it? If we were to do
anything about this, I'd be more inclined to change re_guts to void*.

Got it , thanks.