Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fcoe-utils: Use enum fcoe_status for all status codes

There are multiple enums used for error and status
codes. This causes problems when converting error codes
from fcoemon to fcoeadm. This patch makes it so that
only one enum is used for error and status codes.

checkpatch.pl returns a few WARNINGS due to
non-negative error codes. This should be fine.

Signed-off-by: Robert Love <robert.w.love@intel.com>
Tested-by: Ross Brattain <ross.b.brattain@intel.com>
  • Loading branch information...
commit 75756784434d519ae15466ba45b2888078ae3f4e 1 parent 22acd27
Robert Love authored
Showing with 36 additions and 35 deletions.
  1. +0 −6 fcoe_clif.h
  2. +9 −1 fcoeadm.c
  3. +25 −28 fcoemon.c
  4. +2 −0  include/fcoe_utils.h
View
6 fcoe_clif.h
@@ -36,12 +36,6 @@
#define CLIF_CMD_RESPONSE_TIMEOUT 5
#define MAX_MSGBUF 512
-enum clif_status {
- CLI_SUCCESS = 0,
- CLI_FAIL,
- CLI_NO_ACTION
-};
-
enum clif_action {
CLIF_NONE = 0,
CLIF_CREATE_CMD,
View
10 fcoeadm.c
@@ -349,6 +349,14 @@ int main(int argc, char *argv[])
err:
if (rc) {
switch (rc) {
+ case EFAIL:
+ FCOE_LOG_ERR("Command failed\n");
+ break;
+
+ case ENOACTION:
+ FCOE_LOG_ERR("No action was taken\n");
+ break;
+
case EFCOECONN:
FCOE_LOG_ERR("Connection already created on "
"interface %s\n", ifname);
@@ -406,7 +414,7 @@ int main(int argc, char *argv[])
/*
* This will catch EOPNOTSUPP which should never happen
*/
- FCOE_LOG_ERR("Unknown error\n");
+ FCOE_LOG_ERR("Unknown error code %d\n", rc);
break;
}
View
53 fcoemon.c
@@ -89,12 +89,6 @@
#define FCM_VLAN_DISC_MAX 10 /* stop after 10 attempts */
void fcm_vlan_disc_timeout(void *arg);
-enum fcm_srv_status {
- fcm_success = 0,
- fcm_fail,
- fcm_no_action
-};
-
/*
* fcoe service configuration data
* Note: These information are read in from the fcoe service
@@ -142,7 +136,7 @@ static void fcm_dcbd_event(char *, size_t);
static void fcm_dcbd_cmd_resp(char *, cmd_status);
static void fcm_netif_advance(struct fcm_netif *);
static void fcm_fcoe_action(struct fcm_netif *, struct fcoe_port *);
-static int fcm_fcoe_if_action(char *, char *);
+static enum fcoe_err fcm_fcoe_if_action(char *, char *);
struct fcm_clif {
int cl_fd;
@@ -1958,10 +1952,10 @@ static void fcm_cli_reply(struct sock_info *r, int status)
r->fromlen);
}
-static int fcm_fcoe_if_action(char *path, char *ifname)
+static enum fcoe_err fcm_fcoe_if_action(char *path, char *ifname)
{
FILE *fp = NULL;
- int ret = fcm_fail;
+ enum fcoe_err ret = EFAIL;
fp = fopen(path, "w");
if (!fp) {
@@ -1976,7 +1970,7 @@ static int fcm_fcoe_if_action(char *path, char *ifname)
goto out;
}
- ret = fcm_success;
+ ret = NOERR;
out:
fclose(fp);
err_out:
@@ -2028,9 +2022,9 @@ static void fcm_fcoe_action(struct fcm_netif *ff, struct fcoe_port *p)
char *ifname = p->ifname;
char fchost[FCHOSTBUFLEN];
char path[256];
- int rc;
+ enum fcoe_err rc;
- rc = fcm_success;
+ rc = NOERR;
switch (p->action) {
case FCP_CREATE_IF:
FCM_LOG_DBG("OP: CREATE %s\n", p->ifname);
@@ -2046,7 +2040,7 @@ static void fcm_fcoe_action(struct fcm_netif *ff, struct fcoe_port *p)
fcp_set_next_action(vp, FCP_DESTROY_IF);
vp = fcm_find_next_fcoe_port(vp, p->ifname);
}
- rc = fcm_success;
+ rc = NOERR;
break;
}
rc = fcm_fcoe_if_action(FCOE_DESTROY, ifname);
@@ -2077,7 +2071,7 @@ static void fcm_fcoe_action(struct fcm_netif *ff, struct fcoe_port *p)
* the fc_host in sysfs.
*/
if (fcoe_find_fchost(ifname, fchost, FCHOSTBUFLEN)) {
- fcm_cli_reply(p->sock_reply, CLI_FAIL);
+ fcm_cli_reply(p->sock_reply, EFAIL);
return;
}
@@ -2092,7 +2086,7 @@ static void fcm_fcoe_action(struct fcm_netif *ff, struct fcoe_port *p)
* the fc_host in sysfs.
*/
if (fcoe_find_fchost(ifname, fchost, FCHOSTBUFLEN)) {
- fcm_cli_reply(p->sock_reply, CLI_FAIL);
+ fcm_cli_reply(p->sock_reply, EFAIL);
return;
}
@@ -2256,7 +2250,7 @@ static void fcm_handle_changes()
if (!ff) {
FCM_LOG_DBG("no fcoe_action.\n");
if (p->sock_reply) {
- fcm_cli_reply(p->sock_reply, CLI_FAIL);
+ fcm_cli_reply(p->sock_reply, EFAIL);
free(p->sock_reply);
p->sock_reply = NULL;
p->action = FCP_WAIT;
@@ -2374,14 +2368,15 @@ static struct fcoe_port *fcm_port_create(char *ifname, int cmd)
return p;
}
-static int fcm_cli_create(char *ifname, int cmd, struct sock_info **r)
+static enum fcoe_err fcm_cli_create(char *ifname, int cmd,
+ struct sock_info **r)
{
struct fcoe_port *p, *vp;
p = fcm_find_fcoe_port(ifname, FCP_CFG_IFNAME);
if (p && p->fcoe_enable) {
/* no action needed */
- return CLI_NO_ACTION;
+ return ENOACTION;
}
/* re-enable previous VLANs */
if (p && p->auto_vlan) {
@@ -2394,12 +2389,13 @@ static int fcm_cli_create(char *ifname, int cmd, struct sock_info **r)
}
p = fcm_port_create(ifname, cmd);
if (!p)
- return fcm_fail;
+ return EFAIL;
p->sock_reply = *r;
- return fcm_success;
+ return NOERR;
}
-static int fcm_cli_destroy(char *ifname, int cmd, struct sock_info **r)
+static enum fcoe_err fcm_cli_destroy(char *ifname, int cmd,
+ struct sock_info **r)
{
struct fcoe_port *p;
@@ -2409,18 +2405,19 @@ static int fcm_cli_destroy(char *ifname, int cmd, struct sock_info **r)
p->fcoe_enable = 0;
fcp_set_next_action(p, cmd);
p->sock_reply = *r;
- return fcm_success;
+ return NOERR;
} else {
/* no action needed */
- return CLI_NO_ACTION;
+ return ENOACTION;
}
}
FCM_LOG_ERR(errno, "%s is not in port list.\n", ifname);
- return fcm_fail;
+ return EFAIL;
}
-static int fcm_cli_action(char *ifname, int cmd, struct sock_info **r)
+static enum fcoe_err fcm_cli_action(char *ifname, int cmd,
+ struct sock_info **r)
{
struct fcoe_port *p;
@@ -2428,11 +2425,11 @@ static int fcm_cli_action(char *ifname, int cmd, struct sock_info **r)
if (p) {
fcp_set_next_action(p, cmd);
p->sock_reply = *r;
- return fcm_success;
+ return NOERR;
}
FCM_LOG_ERR(errno, "%s is not in port list.\n", ifname);
- return fcm_fail;
+ return EFAIL;
}
static struct sock_info *fcm_alloc_reply(struct sockaddr_un *f,
@@ -2521,7 +2518,7 @@ static void fcm_srv_receive(void *arg)
free(ifname);
free(reply);
err:
- snprintf(rbuf, MSG_RBUF, "%d", CLI_FAIL);
+ snprintf(rbuf, MSG_RBUF, "%d", EFAIL);
sendto(snum, rbuf, MSG_RBUF, 0, (struct sockaddr *)&from, fromlen);
}
View
2  include/fcoe_utils.h
@@ -61,6 +61,8 @@
enum fcoe_err {
NOERR = 0, /* No error */
+ EFAIL, /* Command Failed */
+ ENOACTION, /* No action was taken */
EFCOECONN, /* FCoE connection already exists */
ENOFCOECONN, /* No FCoE connection on interface */
EINTERR, /* Internal error */
Please sign in to comment.
Something went wrong with that request. Please try again.