On Sun, 25 Apr 2021 21:02:22 +0800 "Min Hu (Connor)" <humi...@huawei.com> wrote:
> snprintf(file_name, MAX_FILE_NAME_SZ, "%s-port%u", > + file_prefix, i); > + fp_regs = fopen(file_name, "wb"); > + if (fp_regs == NULL) { > + printf("Error during opening '%s' for writing\n", > + file_name); > + } else { > + if ((int)fwrite(buf_data, 1, buf_size, fp_regs) != > + buf_size) > + printf("Error during writing %s\n", > + file_prefix); > + else > + printf("dump device (%s) regs successfully, " > + "driver:%s version:0X%08X\n", > + dev_info.device->name, > + dev_info.driver_name, reg_info.version); > + > + fclose(fp_regs); > + I don't like applications opening and writing an arbitrary file in the current directory. Any file should be an argument to the application and optional. Also, since you are writing binary data, there is no point in using stdio here.