13 when /modversion changed/
15 when /^In file included from/
16 yield msg if msg.length > 0
21 if seen_infu or seen_warn then
29 when /:[0-9]+:[0-9]+: note:/
31 when /:[0-9]+:([0-9]+:)? ?warning: /
41 msg << l if l =~ /:[0-9]+:[0-9]+: / #junk lines that don't have line number or any other significant info
44 yield msg if msg.length > 0
49 attr_accessor :file, :origin, :reason, :text, :object, :function
51 file.hash | reason.hash | object.hash | function.hash
54 (other.file == file) && (other.reason == reason) && (other.object == object) && (other.function == function)
57 other.class == self.class && self == other
59 def initialize warning
64 @file = l.sub(/:.*/,'').chomp
65 @function = (l.match /: In function ‘([^‘’]+)’/)[1] rescue (l.match /: In function '([^']+)'/)[1] rescue nil
66 when /:[0-9]+:([0-9]+:)? ?warning: /
67 file = l.sub(/:.*/,'').chomp
68 if @file and @file != file
73 @reason = (l.match /\[-W([^\]]+)\]/)[1] rescue (l.match /warning: (.+)/)[1]
74 @object = (l.match /‘([^‘’]+)’/)[1] rescue (l.match /'([^']+)'/)[1] rescue nil
80 s << " Origin: '#@origin'" if @origin
81 s << " Reason: '#@reason'" if @reason
82 s << " Object: '#@object'" if @reason
92 @hash = Hash.new {|hsh, key| hsh[key] = [] }
93 WarnSplit.new(log).each{|w|
99 return '' unless self.length > 0
100 s="***** #{self.length} warnings *****\n"
102 #s << "*** file: " << k << " ***\n"
104 #s << "* " << w.reason if w.reason
105 #s << " (" << w.object << ")" if w.object
106 #s << " in " << w.function if w.function
107 #s << " (from " << w.origin << ")" if w.origin
108 #s << "\n" if w.origin or w.reason
109 s << w.text if ! short
123 ws = self[k] - old[k]
124 res[k].concat ws if ws.length > 0
131 res += self[k].length
137 def printhelp error=0
138 STDOUT << "#{$0} oldlog newlog\n#{$0} --test\n"
142 @sampledata = "include/config/auto.conf:7381:warning: symbol value '/etc/keys/x509_ima.der' invalid for IMA_X509_PATH
143 include/config/auto.conf:7825:warning: symbol value 'm' invalid for BRIDGE_NETFILTER
144 include/config/auto.conf:8206:warning: symbol value 'm' invalid for SPI_FSL_SPI
145 include/config/auto.conf:8518:warning: symbol value 'm' invalid for DEVFREQ_GOV_USERSPACE
146 include/config/auto.conf:8757:warning: symbol value 'm' invalid for SND_HDA_CODEC_ANALOG
147 include/config/auto.conf:8819:warning: symbol value 'm' invalid for SND_HDA_CODEC_REALTEK
148 "+'In file included from drivers/ata/libata-core.c:65:0:
149 drivers/ata/libata-core.c: In function ‘ata_dev_configure’:
150 include/linux/libata.h:1318:16: warning: ‘native_sectors’ may be used uninitialized in this function [-Wmaybe-uninitialized]
151 ata_dev_printk(dev, KERN_INFO, fmt, ##__VA_ARGS__)
153 drivers/ata/libata-core.c:1324:6: note: ‘native_sectors’ was declared here
156 drivers/atm/ambassador.c: In function ‘ucode_init’:
157 drivers/atm/ambassador.c:1971:19: warning: ‘fw’ may be used uninitialized in this function [-Wmaybe-uninitialized]
158 release_firmware(fw);
160 sound/drivers/serial-u16550.c: In function ‘snd_serial_probe’:
161 sound/drivers/serial-u16550.c:966:9: warning: ‘uart’ may be used uninitialized in this function [-Wmaybe-uninitialized]
162 sprintf(card->longname, "%s [%s] at %#lx, irq %d",
164 In file included from include/linux/cache.h:4:0,
165 from include/linux/time.h:7,
166 from include/linux/stat.h:60,
167 from include/linux/module.h:10,
168 from drivers/block/floppy.c:167:
169 drivers/block/floppy.c: In function ‘fd_locked_ioctl’:
170 include/linux/kernel.h:625:26: warning: ‘size’ may be used uninitialized in this function [-Wmaybe-uninitialized]
171 __min1 < __min2 ? __min1: __min2; })
173 drivers/block/floppy.c:3379:6: note: ‘size’ was declared here
176 sound/pci/atiixp_modem.c: In function ‘snd_atiixp_probe’:
177 sound/pci/atiixp_modem.c:299:20: warning: ‘chip2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
178 writel(value, chip2->remap_addr + ATI_REG_##reg)
180 sound/pci/atiixp_modem.c:1290:23: note: ‘chip2’ was declared here
181 struct atiixp_modem *chip2;
183 sound/pci/atiixp_modem.c: In function ‘snd_atiixp_probe’:
184 sound/pci/atiixp_modem.c:299:20: warning: ‘chip’ may be used uninitialized in this function [-Wnonsense]
185 writel(value, chip->remap_addr + ATI_REG_##reg)
187 sound/pci/atiixp_modem.c:1290:23: note: ‘chip’ was declared here
188 struct atiixp_modem *chip;
190 sound/pci/atiixp.c: In function ‘snd_atiixp_probe’:
191 sound/pci/atiixp.c:1685:14: warning: ‘chip’ may be used uninitialized in this function [-Wmaybe-uninitialized]
192 chip->ac97[0] ? snd_ac97_get_short_name(chip->ac97[0]) : "?",
196 @sampledata2 = "include/config/auto.conf:7381:warning: symbol value '/etc/keys/x509_ima.der' invalid for IMA_X509_PATH
197 include/config/auto.conf:7825:warning: symbol value 'm' invalid for BRIDGE_NETFILTER
198 include/config/auto.conf:8206:warning: symbol value 'm' invalid for SPI_FSL_SPI
199 include/config/auto.conf:8518:warning: symbol value 'm' invalid for DEVFREQ_GOV_FANTASY
200 include/config/auto.conf:8757:warning: symbol value 'm' invalid for SND_HDA_CODEC_ANALOG
201 include/config/auto.conf:8819:warning: symbol value 'm' invalid for SND_HDA_CODEC_REALTEK
202 "+'In file included from drivers/ata/libata-core.c:65:0:
203 drivers/ata/libata-core.c: In function ‘ata_dev_configure’:
204 include/linux/libata.h:1318:16: warning: ‘native_sectors’ may be used uninitialized in this function [-Wmaybe-uninitialized]
205 ata_dev_printk(dev, KERN_INFO, fmt, ##__VA_ARGS__)
207 drivers/ata/libata-core.c:1324:6: note: ‘native_sectors’ was declared here
210 drivers/atm/ambassador.c: In function ‘ucode_init’:
211 drivers/atm/ambassador.c:1971:19: warning: ‘fw’ may be used uninitialized in this function [-Wmaybe-uninitialized]
212 release_firmware(fw);
214 sound/drivers/serial-u16550.c: In function ‘snd_serial_probe’:
215 sound/drivers/serial-u16550.c:966:9: warning: ‘uart’ may be used uninitialized in this function [-Wmaybe-uninitialized]
216 sprintf(card->longname, "%s [%s] at %#lx, irq %d",
218 In file included from include/linux/cache.h:4:0,
219 from include/linux/time.h:7,
220 from include/linux/stat.h:60,
221 from include/linux/module.h:10,
222 from drivers/block/floppy.c:167:
223 sound/pci/atiixp_modem.c: In function ‘snd_atiixp_probe’:
224 sound/pci/atiixp_modem.c:299:20: warning: ‘chip2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
225 writel(value, chip2->remap_addr + ATI_REG_##reg)
227 sound/pci/atiixp_modem.c:1290:23: note: ‘chip2’ was declared here
228 struct atiixp_modem *chip2;
230 sound/pci/atiixp_modem.c: In function ‘snd_atiixp_probe’:
231 sound/pci/atiixp_modem.c:299:20: warning: ‘chip3’ may be used uninitialized in this function [-Wnonsense]
232 writel(value, chip3->remap_addr + ATI_REG_##reg)
234 sound/pci/atiixp_modem.c:1290:23: note: ‘chip’ was declared here
235 struct atiixp_modem *chip;
237 sound/pci/atiixp.c: In function ‘snd_atiixp_probe’:
238 sound/pci/atiixp.c:1685:14: warning: ‘chip’ may be used uninitialized in this function [-Wmaybe-uninitialized]
239 chip->ac97[0] ? snd_ac97_get_short_name(chip->ac97[0]) : "?",
241 sound/pci/atiixp.c: In function ‘snd_atiixp_probe’:
242 sound/pci/atiixp.c:1685:14: warning: ‘chip2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
243 chip2->ac97[0] ? snd_ac97_get_short_name(chip2->ac97[0]) : "?",
247 class AssertionError < RuntimeError
251 raise AssertionError unless yield
254 def diffstrings s1, s2
256 dta1 = Tempfile.new(File.basename $0)
259 dta2 = Tempfile.new(File.basename $0)
262 diff = `diff -u #{dta1.path} #{dta2.path}`
269 #STDOUT << WarnSplit.new(@sampledata).map{|w| WarnParse.new(w)}.to_a.join("\n-----------------------------------------------\n")
270 t = WarnSort.new(@sampledata)
272 assert { t['include/config/auto.conf'].length == 6 }
273 assert { t['sound/pci/atiixp.c'].length == 1 }
274 assert { t['sound/pci/atiixp_modem.c'].length == 2 }
275 assert { t['drivers/block/floppy.c'].length == 1 }
276 assert { t['sound/drivers/serial-u16550.c'].length == 1 }
277 assert { t['drivers/atm/ambassador.c'].length == 1 }
278 assert { t['drivers/ata/libata-core.c'].length == 1 }
280 assert { t['sound/pci/atiixp_modem.c'][1].reason == 'nonsense' }
281 assert { t['sound/pci/atiixp_modem.c'][0].object == 'chip2' }
282 assert { t['sound/pci/atiixp_modem.c'][1].object == 'chip' }
283 assert { t['sound/pci/atiixp_modem.c'][0].function == 'snd_atiixp_probe' }
284 assert { t['drivers/ata/libata-core.c'][0].function == 'ata_dev_configure' }
285 assert { t['drivers/block/floppy.c'][0].function == 'fd_locked_ioctl' }
289 when 'drivers/block/floppy.c'
290 assert { t[k][0].origin == 'include/linux/kernel.h' }
291 when 'drivers/ata/libata-core.c'
292 assert { t[k][0].origin == 'include/linux/libata.h' }
294 t[k].each{|w| assert { ! w.origin } }
299 if t[k].length == 6 then
300 assert{ t[k][0].reason =~ /symbol value/ }
302 assert{ t[k][0].reason == 'maybe-uninitialized' }
306 STDOUT << (diffstrings @sampledata, @sampledata2)
307 STDOUT << "\n-----------------------------------------------\n"
308 t2 = WarnSort.new(@sampledata2)
309 STDOUT << (t2.diff t).to_s(true)
310 STDOUT << "\n-----------------------------------------------\n"
311 STDOUT << (t2.diff t).to_s
316 if ARGV.length == 1 then
317 runtest if ARGV[0] == '--test'
318 printhelp if ARGV[0] == '--help'
321 printhelp(-1) if ARGV.length != 2
323 oldfile = File.open(ARGV[0])
324 newfile = File.open(ARGV[1])
325 old = WarnSort.new oldfile
326 new = WarnSort.new newfile
329 #STDERR << (diffstrings old.to_s, new.to_s)
330 exit diff.length if diff.length < 100