Thread (15 messages) 15 messages, 5 authors, 2021-07-30

Re: [dpdk-dev] [PATCH] app/procinfo: add device registers dump

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2021-07-17 17:53:39

On Sun, 25 Apr 2021 21:02:22 +0800
"Min Hu (Connor)" [off-list ref] 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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help