[PATCH v2] net/cpfl: get running host ID for CPFL PMD
Stephen Hemminger
stephen at networkplumber.org
Thu May 23 16:52:36 CEST 2024
On Thu, 23 May 2024 06:10:45 +0000
Shaiq Wani <shaiq.wani at intel.com> wrote:
> +static uint8_t
> +get_running_host_id(void)
> +{
> + struct utsname unameData;
> + uint8_t host_id = CPFL_INVALID_HOST_ID;
> + uname(&unameData);
>
> + if (uname(&unameData) != 0) {
Why do it twice?
> + PMD_INIT_LOG(ERR, "Cannot fetch node_name for host\n");
> + return host_id;
> + }
> + /* get the first line */
> + if (strstr(unameData.nodename, "ipu_imc"))
Indentation is off.
> + PMD_INIT_LOG(ERR, "CPFL PMD cannot be running on IMC.");
> + else if (strstr(unameData.nodename, "ipu_acc"))
> + host_id = CPFL_HOST_ID_ACC;
> + else
> + host_id = CPFL_HOST_ID_HOST;
>
> + return host_id;
You could change this to be one string of ifs as:
+static uint8_t
+get_running_host_id(void)
+{
+ struct utsname unameData;
+ uint8_t host_id = CPFL_INVALID_HOST_ID;
+
+ if (uname(&unameData) != 0)
+ PMD_INIT_LOG(ERR, "Cannot fetch node_name for host\n");
+ else if (strstr(unameData.nodename, "ipu_imc"))
+ PMD_INIT_LOG(ERR, "CPFL PMD cannot be running on IMC.");
+ else if (strstr(unameData.nodename, "ipu_acc"))
+ host_id = CPFL_HOST_ID_ACC;
+ else
+ host_id = CPFL_HOST_ID_HOST;
+ return host_id;
+}
More information about the dev
mailing list