Tobias Klausmann
2015-Jul-08 18:27 UTC
[Nouveau] [PATCH 1/2] nouveau/compiler: fix trivial compiler warnings
nouveau_compiler.c: In function ‘main’: nouveau_compiler.c:216:27: warning: ‘code’ may be used uninitialized in this function [-Wmaybe-uninitialized] printf("%08x ", code[i / 4]); ^ nouveau_compiler.c:215:4: warning: ‘size’ may be used uninitialized in this function [-Wmaybe-uninitialized] for (i = 0; i < size; i += 4) { Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de> --- src/gallium/drivers/nouveau/nouveau_compiler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/nouveau/nouveau_compiler.c b/src/gallium/drivers/nouveau/nouveau_compiler.c index 8660498..ca128b5 100644 --- a/src/gallium/drivers/nouveau/nouveau_compiler.c +++ b/src/gallium/drivers/nouveau/nouveau_compiler.c @@ -144,7 +144,7 @@ main(int argc, char *argv[]) const char *filename = NULL; FILE *f; char text[65536] = {0}; - unsigned size, *code; + unsigned size = 0, *code = NULL; for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-a")) -- 2.4.5
Tobias Klausmann
2015-Jul-08 18:27 UTC
[Nouveau] [PATCH 2/2] nv50/ir: fix a compiler warning with debug-only code
codegen/nv50_ir_emit_nv50.cpp: In member function ‘void nv50_ir::CodeEmitterNV50::emitLOAD(const nv50_ir::Instruction*)’: codegen/nv50_ir_emit_nv50.cpp:620:12: warning: unused variable ‘offset’ [-Wunused-variable] int32_t offset = i->getSrc(0)->reg.data.offset; Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de> --- src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nv50.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nv50.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nv50.cpp index 67ea6df..86b16f2 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nv50.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nv50.cpp @@ -616,8 +616,11 @@ CodeEmitterNV50::emitLoadStoreSizeCS(DataType ty) void CodeEmitterNV50::emitLOAD(const Instruction *i) { - DataFile sf = i->src(0).getFile(); +#ifdef DEBUG int32_t offset = i->getSrc(0)->reg.data.offset; +#endif + + DataFile sf = i->src(0).getFile(); switch (sf) { case FILE_SHADER_INPUT: -- 2.4.5
Ilia Mirkin
2015-Jul-08 18:38 UTC
[Nouveau] [PATCH 1/2] nouveau/compiler: fix trivial compiler warnings
Compiler is wrong. On Wed, Jul 8, 2015 at 2:27 PM, Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de> wrote:> nouveau_compiler.c: In function ‘main’: > nouveau_compiler.c:216:27: warning: ‘code’ may be used uninitialized in > this function [-Wmaybe-uninitialized] > printf("%08x ", code[i / 4]); > ^ > nouveau_compiler.c:215:4: warning: ‘size’ may be used uninitialized in > this function [-Wmaybe-uninitialized] > for (i = 0; i < size; i += 4) { > > Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de> > --- > src/gallium/drivers/nouveau/nouveau_compiler.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/gallium/drivers/nouveau/nouveau_compiler.c b/src/gallium/drivers/nouveau/nouveau_compiler.c > index 8660498..ca128b5 100644 > --- a/src/gallium/drivers/nouveau/nouveau_compiler.c > +++ b/src/gallium/drivers/nouveau/nouveau_compiler.c > @@ -144,7 +144,7 @@ main(int argc, char *argv[]) > const char *filename = NULL; > FILE *f; > char text[65536] = {0}; > - unsigned size, *code; > + unsigned size = 0, *code = NULL; > > for (i = 1; i < argc; i++) { > if (!strcmp(argv[i], "-a")) > -- > 2.4.5 > > _______________________________________________ > Nouveau mailing list > Nouveau at lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/nouveau
Tobias Klausmann
2015-Jul-08 19:09 UTC
[Nouveau] [PATCH 1/2] nouveau/compiler: fix trivial compiler warnings
On 08.07.2015 20:38, Ilia Mirkin wrote:> Compiler is wrong.So just "nouveau: ..." then? Anyway, change it to your liking.> On Wed, Jul 8, 2015 at 2:27 PM, Tobias Klausmann > <tobias.johannes.klausmann at mni.thm.de> wrote: >> nouveau_compiler.c: In function ‘main’: >> nouveau_compiler.c:216:27: warning: ‘code’ may be used uninitialized in >> this function [-Wmaybe-uninitialized] >> printf("%08x ", code[i / 4]); >> ^ >> nouveau_compiler.c:215:4: warning: ‘size’ may be used uninitialized in >> this function [-Wmaybe-uninitialized] >> for (i = 0; i < size; i += 4) { >> >> Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de> >> --- >> src/gallium/drivers/nouveau/nouveau_compiler.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/src/gallium/drivers/nouveau/nouveau_compiler.c b/src/gallium/drivers/nouveau/nouveau_compiler.c >> index 8660498..ca128b5 100644 >> --- a/src/gallium/drivers/nouveau/nouveau_compiler.c >> +++ b/src/gallium/drivers/nouveau/nouveau_compiler.c >> @@ -144,7 +144,7 @@ main(int argc, char *argv[]) >> const char *filename = NULL; >> FILE *f; >> char text[65536] = {0}; >> - unsigned size, *code; >> + unsigned size = 0, *code = NULL; >> >> for (i = 1; i < argc; i++) { >> if (!strcmp(argv[i], "-a")) >> -- >> 2.4.5 >> >> _______________________________________________ >> Nouveau mailing list >> Nouveau at lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/nouveau
Emil Velikov
2015-Jul-08 19:31 UTC
[Nouveau] [PATCH 1/2] nouveau/compiler: fix trivial compiler warnings
Curious how many times this needs to come along, for you to change your mind. :-) On 8 July 2015 at 19:38, Ilia Mirkin <imirkin at alum.mit.edu> wrote:> Compiler is wrong. > > On Wed, Jul 8, 2015 at 2:27 PM, Tobias Klausmann > <tobias.johannes.klausmann at mni.thm.de> wrote: >> nouveau_compiler.c: In function ‘main’: >> nouveau_compiler.c:216:27: warning: ‘code’ may be used uninitialized in >> this function [-Wmaybe-uninitialized] >> printf("%08x ", code[i / 4]); >> ^ >> nouveau_compiler.c:215:4: warning: ‘size’ may be used uninitialized in >> this function [-Wmaybe-uninitialized] >> for (i = 0; i < size; i += 4) { >> >> Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de> >> --- >> src/gallium/drivers/nouveau/nouveau_compiler.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/src/gallium/drivers/nouveau/nouveau_compiler.c b/src/gallium/drivers/nouveau/nouveau_compiler.c >> index 8660498..ca128b5 100644 >> --- a/src/gallium/drivers/nouveau/nouveau_compiler.c >> +++ b/src/gallium/drivers/nouveau/nouveau_compiler.c >> @@ -144,7 +144,7 @@ main(int argc, char *argv[]) >> const char *filename = NULL; >> FILE *f; >> char text[65536] = {0}; >> - unsigned size, *code; >> + unsigned size = 0, *code = NULL; >> >> for (i = 1; i < argc; i++) { >> if (!strcmp(argv[i], "-a")) >> -- >> 2.4.5 >> >> _______________________________________________ >> Nouveau mailing list >> Nouveau at lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/nouveau > _______________________________________________ > Nouveau mailing list > Nouveau at lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/nouveau
Emil Velikov
2015-Jul-08 19:34 UTC
[Nouveau] [PATCH 2/2] nv50/ir: fix a compiler warning with debug-only code
On 8 July 2015 at 19:27, Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de> wrote:> codegen/nv50_ir_emit_nv50.cpp: In member function > ‘void nv50_ir::CodeEmitterNV50::emitLOAD(const nv50_ir::Instruction*)’: > codegen/nv50_ir_emit_nv50.cpp:620:12: warning: unused variable ‘offset’ > [-Wunused-variable] > int32_t offset = i->getSrc(0)->reg.data.offset; > > Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de> > --- > src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nv50.cpp | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nv50.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nv50.cpp > index 67ea6df..86b16f2 100644 > --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nv50.cpp > +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nv50.cpp > @@ -616,8 +616,11 @@ CodeEmitterNV50::emitLoadStoreSizeCS(DataType ty) > void > CodeEmitterNV50::emitLOAD(const Instruction *i) > { > - DataFile sf = i->src(0).getFile(); > +#ifdef DEBUG > int32_t offset = i->getSrc(0)->reg.data.offset; > +#endif > +assert is (normally) guarded by NDEBUG. Mesa/gallium has an in-house replacement, which (not 100% sure) should be fine as well. -Emil
Apparently Analagous Threads
- [PATCH 2/2] nv50/ir: fix a compiler warning with debug-only code
- [PATCH 1/2] nouveau/compiler: fix trivial compiler warnings
- [PATCH mesa 1/6] tgsi_build: Fix return of uninitialized memory in tgsi_*_instruction_memory
- [PATCH mesa 5/6] nouveau: codegen: Add support for OpenCL global memory buffers
- [PATCH mesa 4/6] nouveau: codegen: s/FILE_MEMORY_GLOBAL/FILE_MEMORY_BUFFER/