Skip to content

Use const char pointer in redismodule.h as far as possible#10064

Merged
oranagra merged 3 commits intoredis:unstablefrom
ShooterIT:digest-module
Jan 18, 2022
Merged

Use const char pointer in redismodule.h as far as possible#10064
oranagra merged 3 commits intoredis:unstablefrom
ShooterIT:digest-module

Conversation

@ShooterIT
Copy link
Member

@ShooterIT ShooterIT commented Jan 6, 2022

When I used C++ to develop a redis module. i used string.data() as the second parameter ele
of RedisModule_DigestAddStringBuffer, but there is a warning, since we never change the ele,
i think we should use const char for it.

This PR adds const to just a handful of module APIs that required it, all not very widely used.
The implication is a breaking change in terms of compilation error that's easy to resolve, and no ABI impact.
The affected APIs are around Digest, Info injection, and Cluster bus messages.

Copy link
Member

@oranagra oranagra left a comment

Choose a reason for hiding this comment

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

wouldn't that be a breaking change for modules that used to pass non-const pointers?
@yossigo do you think we should?

@yossigo
Copy link
Collaborator

yossigo commented Jan 6, 2022

@oranagra I think at the API level const correctness is important, so I think we should change that. Also, it doesn't break the ABI, just a compilation warning/error.

@oranagra
Copy link
Member

oranagra commented Jan 9, 2022

@yossigo i agree, but my concern is weather or not this is worth the breakage.
i suppose it's not very harmful because many modules don't use this digest API.

but, maybe we should use this opportunity to add const correctness to all APIs?
and if we do that? wouldn't we consider that as too much breakage for the cause?

@yossigo
Copy link
Collaborator

yossigo commented Jan 9, 2022

@oranagra It's hard to tell without seeing the scope of change, but I tend to say if it's not a big issue if it's only a compilation issue. I suppose most modules ship their own redismodule.h anyway and will only update it as part of a manual process.

@oranagra
Copy link
Member

oranagra commented Jan 9, 2022

@ShooterIT do you wanna look into it and see the cope of doing it for the rest of the API?
or shall we just merge this one and move on..?

@ShooterIT
Copy link
Member Author

Hi @oranagra @yossigo i try best to handle the rest of the API, please have a look

@ShooterIT ShooterIT changed the title Use const char for string digest Use const char in redismodule.h as far as possible Jan 14, 2022
Copy link
Member

@oranagra oranagra left a comment

Choose a reason for hiding this comment

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

ok. so the only changes that where required are in Digest, Info injection, and Cluster bus messages?
i suppose all of these are relatively unused by most of the modules.
and it's interesting to see that many of the test modules didn't have to be changed.

@yossigo i'm ok with this.

Copy link
Collaborator

@yossigo yossigo left a comment

Choose a reason for hiding this comment

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

@oranagra me too.

@ShooterIT ShooterIT changed the title Use const char in redismodule.h as far as possible Use const char pointer in redismodule.h as far as possible Jan 16, 2022
@oranagra
Copy link
Member

@redis/core-team not sure if we consider that a breaking change or a major decision.
don't see much point to mention it in the release notes.
comment if you want.

Copy link
Contributor

@madolson madolson left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me.

@oranagra oranagra merged commit d697daa into redis:unstable Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants