I use lsmod a lot. In the current version very long module names don't fit in the tabular format, like: snd_hda_codec 52287 3 snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel snd_hda_codec_hdmi 20329 4 snd_hda_codec_realtek 273500 1 snd_hda_intel 18481 4 snd_hwdep 5262 1 snd_hda_codec here the name of the module snd_hda_codec_realtek is too long.
the one or two spaces could be tweaked for this specific instance, but i dont think lsmod should pre-scan the whole list and calculate the required alignment across all of them.
Hm if I remember programming well (it is a long time ago) either a valid assumption about the maximum length of module names can be made or long entries should be truncated...
the code already makes an assumption about the length. but anyone can make a module with a longer name. a slightly padded display is a lot better than arbitrary truncation.
ok, looking at the code, it basically does: "%-19s %8s ....." so if we add brackets to make things clearer, we see: {1234567890123456789} {12345678} {snd_hda_codec } { 52287} {snd_hda_codec_hdmi } { 20329} {snd_hda_codec_realtek} { 273500} the realtek module has already violated the 19 char limit that lsmod uses. a quick sample of all the modules i have available on my system shows that there are quite a few that are larger than 20 chars, so increasing the 19 only makes it look OK for some modules ... it will still be exceeded by some other module. since the current code is pretty simple (less than 3KiB of .text on 64bit!), i dont see much value in making this work. you'd have to scan the file twice, the first would be just to calculate the longest line. feel free to make your case with the upstream project ... who knows, maybe they'll implement the overly complicated solution.
(In reply to comment #4) > > since the current code is pretty simple (less than 3KiB of .text on 64bit!), i > dont see much value in making this work. you'd have to scan the file twice, > the first would be just to calculate the longest line. > I see your point. Didn't know that module name length is unrestricted. My simple suggestion would be to increase the 19 char limit to, say, 30. Of course that's not set in stone. If I knew how to do it I would propose such a patch upstream.