-
Notifications
You must be signed in to change notification settings - Fork 449
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
Improve module
macro
#215
Comments
will try myself on this now, as I need alias for the net stuff. |
I commented on this somewhere else. While the C side allows any ordering (and uses separate macros), I think forcing always the same order will be better for consistency long-term and to always see our (Also, we need to be mindful that if we allow arbitrary orderings now, it will be harder to go back and enforce a fixed order later on because it will require fixing many modules). |
If we have a fixed ordering, what if we don't need a field in a driver? For example alias_rtnl_link I only need in the network driver. what about drivers not using that field. IMHO it's easier to implement without fixed ordering, and also I don't see a real reason for ordering, besides convenience. |
I don't mind if we decide to force a strict order. (I'm more interested in making optional arguments truly optional.) However, at the moment I'm failing to see the benefits we get from it (the strict ordering). |
Optional fields are OK, that is orthogonal to the ordering.
Consistency is the reason :) In my view, anything that allows arbitrary ordering needs to be justified, rather than the opposite... |
Basically, we need to choose between easier-to-write vs. easier-to-read. Since most of the time we are reading, I think it is best to enforce the fixed ordering. In the end, I assume people will be copy-pasting the macro from one file to another, so I thought it was not a big deal to have a fixed ordering. As you know, I usually "fight" for consistency everywhere. :-P But if people really hate it (three people so far have suggested arbitrary orderings already), I am not going to be against everyone -- we can change it. |
@wedsonaf you said |
One alternative could be the file/crate name, since kernel modules that are single-file typically have the same name as the kernel module name. |
We do need to make it minimally easy to write. For example, if I swap the order of author and description, here's what I get:
So IMO we either need to allow any order or have a better error reporting when we get things out of order. |
im building something like |
Suppose I'm writing a driver and I get the error message above. It's certainly more helpful than what I get today, but it doesn't guide me to a solution: perhaps also specify what is allowed? |
Agreed, better error reporting for |
I only see this unstable api[1], to get the file/crate name. as I could stringify the |
Hmm... usually kernel module names have |
To improve error reporting easily, what you can do is walk the token stream as if ordering was arbitrary, since that it is easy, but keep a list of seen keys. Then, at the very end, check that the list is as expected, and otherwise you can panic with:
e.g. if the user gave That way, errors that are about invalid keys or invalid values are reported first, without bothering the user about the ordering. Then, at the end, where you know everything is valid but only the ordering was wrong, you can report exactly that, since you know only the ordering was wrong. |
…ent event class While running checkpatch.pl against a patch that modifies the btrfs_qgroup_extent event class, it complained about using a comma instead of a semicolon: $ ./scripts/checkpatch.pl qgroups/0003-btrfs-qgroups-remove-bytenr-field-from-struct-btrfs_.patch WARNING: Possible comma where semicolon could be used #215: FILE: include/trace/events/btrfs.h:1720: + __entry->bytenr = bytenr, __entry->num_bytes = rec->num_bytes; total: 0 errors, 1 warnings, 184 lines checked So replace the comma with a semicolon to silence checkpatch and possibly other tools. It also makes the code consistent with the rest. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
license
andtype
should be mandatory, the others should be optionalThe text was updated successfully, but these errors were encountered: