Skip to content

rust: take str literal instead bstr literal in module! macro #858

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

Merged
merged 1 commit into from
Aug 5, 2022

Conversation

nbdd0121
Copy link
Member

@nbdd0121 nbdd0121 commented Aug 5, 2022

Not a complete fix to #252 because only a subset of string literals are accepted: For simplicity (avoid parsing), escape sequences are not yet handled.

Copy link
Member

@ojeda ojeda left a comment

Choose a reason for hiding this comment

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

LGTM, I tested it with some non-ASCII characters:

$ modinfo samples/rust/rust_minimal.ko
filename:      .../samples/rust/rust_minimal.ko
author:         周琰杰

@@ -28,6 +28,21 @@ pub(crate) fn try_byte_string(it: &mut token_stream::IntoIter) -> Option<String>
})
}

pub(crate) fn try_string(it: &mut token_stream::IntoIter) -> Option<String> {
try_literal(it).and_then(|string| {
// TODO: handle raw string literals
Copy link
Member

Choose a reason for hiding this comment

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

Maybe as documentation of the function, to avoid the TODO (if we do not expect tot need raw literals).

Or maybe panic, if you can detect it is a raw literal?

@ojeda
Copy link
Member

ojeda commented Aug 5, 2022

It could be good to have a expect_string_ascii to check when it is supposed to be ASCII, e.g. for the module name.

For simplicity (avoid parsing), escape sequences and raw string literals
are not yet handled.

Module names, aliases and license strings are restricted to ASCII only.

Link: Rust-for-Linux#252
Link: https://lore.kernel.org/lkml/[email protected]/
Signed-off-by: Gary Guo <[email protected]>
@ojeda
Copy link
Member

ojeda commented Aug 5, 2022

Thanks Gary!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants