[lttng-dev] Bug in lttng-ust tool lttng-gen-tp which replaces all ".c" with ".h" in the path
    Gunnar Strand 
    Gunnar.Strand at ericsson.com
       
    Mon Sep 18 09:47:28 UTC 2017
    
    
  
Hi,
It does not seem like anonymous bug reporting is supported, so I am 
submitting the report here instead.
I found the following bug in the tools/lttng-gen-tp tool in the 
lttng-ust component, which is present in the latest commit on master, 
d0f6cf574ef992620b09c183cb3a0ea771070ea5:
  66 class CFile:
...
  79     def write(self):
  80         outputFile = open(self.outputFilename,"w")
  81
  82         headerFilename = self.outputFilename.replace(".c",".h")
Line 82 replaces all occurrences of ".c" with ".h" which breaks 
compilation if the path to the source contains ".c" anywhere, eg.: 
/path/to/my.cigar/source/...
Only the last occurrence should be replaced, eg.:
if self.outputFilename.endswith(".c"):
     headerFilename = self.outputFilename[:-2] + ".h"
Or just the second line if the code can assume that the string has a 
".c" suffix.
BR
Gunnar
    
    
More information about the lttng-dev
mailing list