mirror of https://github.com/thesofproject/sof.git
Tools: Tune: Common: Add checks for file open failures
This patch adds checks and errors for fopen() failures. The check is useful with setup scripts paths changes. Aborting the script avoids the errors in blob exports to be missed. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This commit is contained in:
parent
7f212411cc
commit
e4b4ac7b4c
|
@ -3,6 +3,10 @@ function alsactl_write(fn, blob8)
|
||||||
%% Write blob
|
%% Write blob
|
||||||
check_create_dir(fn);
|
check_create_dir(fn);
|
||||||
fh = fopen(fn, 'w');
|
fh = fopen(fn, 'w');
|
||||||
|
if fh < 0
|
||||||
|
fprintf(1, 'Error: Could not open file %s\n', fn);
|
||||||
|
error("Failed.");
|
||||||
|
end
|
||||||
|
|
||||||
%% Pad blob length to multiple of four bytes
|
%% Pad blob length to multiple of four bytes
|
||||||
n_orig = length(blob8);
|
n_orig = length(blob8);
|
||||||
|
|
|
@ -4,6 +4,11 @@ function blob_write(fn, blob8)
|
||||||
%% Write blob
|
%% Write blob
|
||||||
check_create_dir(fn);
|
check_create_dir(fn);
|
||||||
fh = fopen(fn, 'wb');
|
fh = fopen(fn, 'wb');
|
||||||
|
if fh < 0
|
||||||
|
fprintf(1, 'Error: Could not open file %s\n', fn);
|
||||||
|
error("Failed.");
|
||||||
|
end
|
||||||
|
|
||||||
fwrite(fh, blob8, 'uint8');
|
fwrite(fh, blob8, 'uint8');
|
||||||
fclose(fh);
|
fclose(fh);
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,11 @@ ublob8(9:end) = blob8;
|
||||||
%% Write blob
|
%% Write blob
|
||||||
check_create_dir(fn);
|
check_create_dir(fn);
|
||||||
fh = fopen(fn, 'wb');
|
fh = fopen(fn, 'wb');
|
||||||
|
if fh < 0
|
||||||
|
fprintf(1, 'Error: Could not open file %s\n', fn);
|
||||||
|
error("Failed.");
|
||||||
|
end
|
||||||
|
|
||||||
fwrite(fh, ublob8, 'uint8');
|
fwrite(fh, ublob8, 'uint8');
|
||||||
fclose(fh);
|
fclose(fh);
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,10 @@ end
|
||||||
|
|
||||||
%% Write blob
|
%% Write blob
|
||||||
fh = fopen(fn, 'w');
|
fh = fopen(fn, 'w');
|
||||||
|
if fh < 0
|
||||||
|
fprintf(1, 'Error: Could not open file %s\n', fn);
|
||||||
|
error("Failed.");
|
||||||
|
end
|
||||||
nl = 8;
|
nl = 8;
|
||||||
fprintf(fh, '# %s %s\n', comment, date());
|
fprintf(fh, '# %s %s\n', comment, date());
|
||||||
if ~isempty(howto)
|
if ~isempty(howto)
|
||||||
|
|
|
@ -15,6 +15,10 @@ blob8_new(1:n_orig) = blob8;
|
||||||
|
|
||||||
%% Write blob
|
%% Write blob
|
||||||
fh = fopen(fn, 'w');
|
fh = fopen(fn, 'w');
|
||||||
|
if fh < 0
|
||||||
|
fprintf(1, 'Error: Could not open file %s\n', fn);
|
||||||
|
error("Failed.");
|
||||||
|
end
|
||||||
nl = 8;
|
nl = 8;
|
||||||
fprintf(fh, '# %s %s\n', comment, date());
|
fprintf(fh, '# %s %s\n', comment, date());
|
||||||
if ~isempty(howto)
|
if ~isempty(howto)
|
||||||
|
|
Loading…
Reference in New Issue