From 0aca04afa585e87bc900fb3b9c19c92d78b3e8f7 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Mon, 22 Jun 2020 13:33:21 +0200 Subject: [PATCH] aco: fix printing ASM on GFX6-7 again MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Checking errno is actually wrong because it's only updated if popen() fails (ie. NULL). One solution is to check if the first line is empty. Fixes: c95d258d1bc ("aco: fix printing ASM on GFX6-7 if clrxdisasm is not found") Signed-off-by: Samuel Pitoiset Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_print_asm.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/amd/compiler/aco_print_asm.cpp b/src/amd/compiler/aco_print_asm.cpp index 2e6519fe57b..d4b0e0edbcf 100644 --- a/src/amd/compiler/aco_print_asm.cpp +++ b/src/amd/compiler/aco_print_asm.cpp @@ -69,11 +69,17 @@ void print_asm_gfx6_gfx7(Program *program, std::vector& binary, sprintf(command, "clrxdisasm --gpuType=%s -r %s", gpu_type, path); p = popen(command, "r"); - if (!p || errno == ENOENT) { - out << "clrxdisasm not found\n"; - } else { - while (fgets(line, sizeof(line), p)) + if (p) { + if (!fgets(line, sizeof(line), p)) { + out << "clrxdisasm not found\n"; + pclose(p); + goto fail; + } + + do { out << line; + } while (fgets(line, sizeof(line), p)); + pclose(p); } -- 2.30.2