From 002cecf2022de3ab01c87f905477aa3b063d73fc Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 2 Mar 2018 16:14:57 +0100 Subject: pkg/compiler: allow specifying static size for filename's Sometimes filenames are embed into structs and need to take fixed space. --- prog/analysis.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'prog/analysis.go') diff --git a/prog/analysis.go b/prog/analysis.go index 626af7446..7d5cc0099 100644 --- a/prog/analysis.go +++ b/prog/analysis.go @@ -73,11 +73,16 @@ func (s *state) analyzeImpl(c *Call, resources bool) { case *BufferType: a := arg.(*DataArg) if typ.Dir() != DirOut && len(a.Data()) != 0 { + val := string(a.Data()) + // Remove trailing zero padding. + for len(val) >= 2 && val[len(val)-1] == 0 && val[len(val)-2] == 0 { + val = val[:len(val)-1] + } switch typ.Kind { case BufferString: - s.strings[string(a.Data())] = true + s.strings[val] = true case BufferFilename: - s.files[string(a.Data())] = true + s.files[val] = true } } } -- cgit mrf-deployment