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
|
||||
check_create_dir(fn);
|
||||
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
|
||||
n_orig = length(blob8);
|
||||
|
|
|
@ -4,6 +4,11 @@ function blob_write(fn, blob8)
|
|||
%% Write blob
|
||||
check_create_dir(fn);
|
||||
fh = fopen(fn, 'wb');
|
||||
if fh < 0
|
||||
fprintf(1, 'Error: Could not open file %s\n', fn);
|
||||
error("Failed.");
|
||||
end
|
||||
|
||||
fwrite(fh, blob8, 'uint8');
|
||||
fclose(fh);
|
||||
|
||||
|
|
|
@ -25,6 +25,11 @@ ublob8(9:end) = blob8;
|
|||
%% Write blob
|
||||
check_create_dir(fn);
|
||||
fh = fopen(fn, 'wb');
|
||||
if fh < 0
|
||||
fprintf(1, 'Error: Could not open file %s\n', fn);
|
||||
error("Failed.");
|
||||
end
|
||||
|
||||
fwrite(fh, ublob8, 'uint8');
|
||||
fclose(fh);
|
||||
|
||||
|
|
|
@ -24,6 +24,10 @@ end
|
|||
|
||||
%% Write blob
|
||||
fh = fopen(fn, 'w');
|
||||
if fh < 0
|
||||
fprintf(1, 'Error: Could not open file %s\n', fn);
|
||||
error("Failed.");
|
||||
end
|
||||
nl = 8;
|
||||
fprintf(fh, '# %s %s\n', comment, date());
|
||||
if ~isempty(howto)
|
||||
|
|
|
@ -15,6 +15,10 @@ blob8_new(1:n_orig) = blob8;
|
|||
|
||||
%% Write blob
|
||||
fh = fopen(fn, 'w');
|
||||
if fh < 0
|
||||
fprintf(1, 'Error: Could not open file %s\n', fn);
|
||||
error("Failed.");
|
||||
end
|
||||
nl = 8;
|
||||
fprintf(fh, '# %s %s\n', comment, date());
|
||||
if ~isempty(howto)
|
||||
|
|
Loading…
Reference in New Issue