-
Notifications
You must be signed in to change notification settings - Fork 387
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
vrt: Turn hdr_t into a structured type #4308
base: master
Are you sure you want to change the base?
Conversation
It poses two problems alleviated by the previous char[] type: - assigning a "string literal" that is considered const - referencing a pointer in a static lookup table The const problem is temporarily avoided with a char[] _H_Header static variable only used to store the string the actual H_Header symbol will point to. The static table limitation is worked around, storing pointers to the offending symbols. This workaround is permanent, because headers should eventually take a new structured type that will pose the same problem.
Using the established hdr_t type definition. Solves varnishcache#4304
It could be part of the well-known headers table, along with the h2 pseudo-header fields, but that would require an update of the perfect hash lookup table. The main goal so far is to formalize the hdr_t nature of this string.
It's a clunky macro, but its current shape is only a transition towards something structured.
Without changing the memory layout of our pseudo-pascal-string for header names, this structured alternative clarifies the semantics and removes error-prone pointer arithmetics spread out everywhere. The new structure adds type safety to this specific use case. It comes with a new static analyzer with the HDR() macro, and a CAST_HDR() macro that includes a check with the CHECK_HDR() macro that was already present. Closes varnishcache#3215
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
all of bugwash approved
looks good to me |
I meant of course static initializer... I will fix that before merging. |
Maybe before I get around to fixing the commit message someone™ could run flexelint and see how it fares? |
|
I am working on a suggestion to make Flexelint happy(er). |
Without changing the memory layout of our pseudo-pascal-string for header names, this structured alternative clarifies the semantics and removes error-prone pointer arithmetics spread out everywhere.
The new structure adds type safety to this specific use case.
It comes with a new static analyzer with the
HDR()
macro, and aCAST_HDR()
macro that includes a check with theCHECK_HDR()
macro also introduced by this patch series.Solves #4304
Closes #3215