zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 24b272e243a4b766a4cb3bee290a083d708cc3d1
parent 4bbf06627af302086ac42d1d09a668e4cf21d984
Author: Julien Olivain <[email protected]>
Date:   Fri, 31 Dec 2021 00:44:52 +0100

Nio: fix a gcc compiler warning on Linux

A pipe stream opened with popen() should be closed with pclosed() rather
than fclose().

See popen(3) man page:
https://man7.org/linux/man-pages/man3/popen.3.html

This commit fixes the warning:

    src/Nio/Nio.cpp: In function ‘void zyn::Nio::preferredSampleRate(unsigned int&)’:
    src/Nio/Nio.cpp:146:11: warning: ‘int fclose(FILE*)’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc]
      146 |     fclose(ps);
          |     ~~~~~~^~~~
    src/Nio/Nio.cpp:141:21: note: returned from ‘FILE* popen(const char*, const char*)’
      141 |     FILE *ps = popen("ps aux", "r");
          |                ~~~~~^~~~~~~~~~~~~~~

Note: this warning is reported by gcc 11.2.1, on Fedora 35.

Signed-off-by: Julien Olivain <[email protected]>

Diffstat:
Msrc/Nio/Nio.cpp | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Nio/Nio.cpp b/src/Nio/Nio.cpp @@ -143,7 +143,7 @@ void Nio::preferredSampleRate(unsigned &rate) while(fgets(buffer, sizeof(buffer), ps)) if(strstr(buffer, "jack")) break; - fclose(ps); + pclose(ps); if(!strstr(buffer, "jack")) return;