Skip to contentSkip to conversation

This patch set removes the ASSERT code in Open-FCoE.

PATCH New Robert Love 1 participant 11 messages Jan 23, 2008 SCSI

lore
Share & tools
lore
#0 lore raw

cover This patch set removes the ASSERT code in Open-FCoE.

The following series removes the sa_assert.[ch] files. It also converts all calls to ASSERT* to either WARN_ON or ERROR_ON calls. This is part of the effort to remove libsa.

--
Signature

#1 lore raw

PATCH 1/10 Changing all ASSERT_NOTIMPL to WARN_ON(1)

Trigger the warning every time the block is encountered.

---

 drivers/scsi/ofc/libfc/fc_exch.c       |   11 +----------
 drivers/scsi/ofc/libfc/fc_frame.c      |    2 +-
 drivers/scsi/ofc/libfc/fc_local_port.c |    2 +-
 drivers/scsi/ofc/openfc/openfc_scsi.c  |    4 ++--
 4 files changed, 5 insertions(+), 14 deletions(-)
drivers/scsi/ofc/libfc/fc_exch.c +1 -10
index 4a19936..9a5cd98 100644
@@ -203,14 +203,6 @@ static int fc_exch_mgr_init(struct fc_exch_mgr *mp, enum fc_class class,
 	u_int pool_count;
 	u_int cpu;
 
-	/*
-	 * Check to make sure the declaration of ESB and SSB structures came out
-	 * with the right size and no unexpected padding.
-	 */
-	ASSERT_NOTIMPL(sizeof(struct fc_esb) == FC_ESB_SIZE);
-	ASSERT_NOTIMPL(sizeof(struct fc_ssb) == FC_SSB_SIZE);
-	ASSERT_NOTIMPL(sizeof(struct fc_frame_header) == FC_FRAME_HEADER_LEN);
-
 	mp->em_class = class;
 
 	/*
@@ -562,7 +554,6 @@ static struct fc_exch *fc_exch_alloc(struct fc_exch_mgr *mp)
 
 	spin_lock_bh(&pp->emp_lock);
 	if (list_empty(&pp->emp_exch_free)) {
-		ASSERT_NOTIMPL(ep);	/* not generally handled */
 		atomic_inc(&mp->em_stats.ems_error_no_free_exch);
 		spin_unlock_bh(&pp->emp_lock);
 	} else {
@@ -1144,7 +1135,7 @@ static void fc_seq_send_ack(struct fc_seq *sp, const struct fc_frame *rx_fp)
 	 */
 	if (fc_sof_needs_ack(rx_fp->fr_sof)) {
 		fp = fc_frame_alloc(fc_seq_exch(sp)->ex_port, 0);
-		ASSERT_NOTIMPL(fp);
+		BUG_ON(!fp);
 		if (!fp)
 			return;
 		fc_seq_fill_hdr(sp, fp);
drivers/scsi/ofc/libfc/fc_frame.c +1 -1
index 056df3d..c609ebd 100644
@@ -44,7 +44,7 @@ u_int32_t fc_frame_crc_check(struct fc_frame *fp)
 	const u_int8_t *bp;
 	u_int len;
 
-	ASSERT_NOTIMPL(fc_frame_is_linear(fp));
+	WARN_ON(!fc_frame_is_linear(fp));
 	fp->fr_flags &= ~FCPHF_CRC_UNCHECKED;
 	len = (fp->fr_len + 3) & ~3;	/* round up length to include fill */
 	bp = (const u_int8_t *)fp->fr_hdr;
drivers/scsi/ofc/libfc/fc_local_port.c +1 -1
index 311b5e9..cd70c74 100644
@@ -1329,7 +1329,7 @@ static void fc_local_port_rscn_req(struct fc_seq *sp, struct fc_frame *fp,
 			if (fc_local_port_debug)
 				OFC_DBG("RSCN received: rediscovering");
 			error = fc_disc_targ_restart(lp);
-			ASSERT_NOTIMPL(error == 0);
+			WARN_ON(error != 0);
 		} else if (fc_local_port_debug) {
 			OFC_DBG("RSCN received: not rediscovering. "
 			       "redisc %d state %d disc_cb %p in_prog %d",
drivers/scsi/ofc/openfc/openfc_scsi.c +2 -2
index cd3afb7..9c7f9bb 100644
@@ -309,7 +309,7 @@ static void openfc_scsi_send_data(struct fc_scsi_pkt *fsp, struct fc_seq *sp,
 							 tlen);
 				data = (void *)(fp->fr_hdr + 1);
 			}
-			ASSERT_NOTIMPL(fp != NULL);	/* XXX */
+			BUG_ON(!fp);
 			fc_frame_setup(fp, FC_RCTL_DD_SOL_DATA, FC_TYPE_FCP);
 			fc_frame_set_offset(fp, frame_offset);
 		}
@@ -442,7 +442,7 @@ static void openfc_scsi_rcv(struct fc_seq *sp, struct fc_frame *fp, void *arg)
 		 */
 		ASSERT(!(fp->fr_flags & FCPHF_CRC_UNCHECKED));
 		dd = fc_frame_payload_get(fp, sizeof(*dd));
-		ASSERT_NOTIMPL(dd != NULL);
+		WARN_ON(!dd);
 		fsp->state = OPENFC_SRB_IN_DATA_TRANS;
 
 		/*
#2 lore raw

PATCH 2/10 Convert one ASSERT_NOTREACHED to WARN_ON(1)

In reply to Robert Love

---

 drivers/scsi/ofc/openfc/openfc_if.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/ofc/openfc/openfc_if.c +1 -1
index 8725845..0b0c782 100644
@@ -1059,7 +1059,7 @@ out_host_rem:
 	scsi_remove_host(openfcp->host);
 out_host_put:
 	scsi_host_put(openfcp->host);
-	ASSERT_NOTREACHED;	/* XXX caller doesn't check return yet */
+	WARN_ON(1);
 	return -1;
 }
 EXPORT_SYMBOL(openfc_register);
#3 lore raw

PATCH 3/10 Remove DEBUG_ASSERTS statements

In reply to Robert Love

---

 drivers/scsi/ofc/include/fc_els.h |   17 -----------------
 drivers/scsi/ofc/include/fc_fs.h  |   13 -------------
 drivers/scsi/ofc/include/fc_gs.h  |   12 ------------
 drivers/scsi/ofc/libfc/fc_ils.h   |   33 ---------------------------------
 drivers/scsi/ofc/libfc/fc_sess.c  |   14 --------------
 5 files changed, 0 insertions(+), 89 deletions(-)
drivers/scsi/ofc/include/fc_els.h +0 -17
index 8ef10c0..6bff73e 100644
@@ -808,21 +808,4 @@ enum fc_els_clid_ic {
 	ELS_CLID_IC_LIP =	8,	/* receiving LIP */
 };
 
-#ifdef DEBUG_ASSERTS
-/*
- * Static checks for packet structure sizes.
- * These catch some obvious errors in structure definitions.
- * They should generate no code since they can be tested at compile time.
- */
-static inline void fc_els_size_checks(void)
-{
-	ASSERT_NOTIMPL(sizeof(struct fc_els_csp) == FC_ELS_CSP_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_els_cssp) == FC_ELS_CSSP_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_els_flogi) == FC_ELS_FLOGI_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_els_spp) == FC_ELS_SPP_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_els_prli) == FC_ELS_PRLI_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_els_logo) == FC_ELS_LOGO_LEN);
-}
-#endif /* DEBUG_ASSERTS */
-
 #endif /* _FC_ELS_H_ */
drivers/scsi/ofc/include/fc_fs.h +0 -13
index 150a711..fdbed64 100644
@@ -324,17 +324,4 @@ struct fc_data_desc {
 
 #define FC_DATA_DESC_LEN    12	/* expected length of structure */
 
-#ifdef DEBUG_ASSERTS
-/*
- * Static checks for packet structure sizes.
- * These catch some obvious errors in structure definitions.
- * This should generate no code.  The check should be true at compile time.
- */
-static inline void fc_fs_size_checks(void)
-{
-	ASSERT_NOTIMPL(sizeof(struct fc_frame_header) == FC_FRAME_HEADER_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_data_desc) == FC_DATA_DESC_LEN);
-}
-#endif /* DEBUG_ASSERTS */
-
 #endif /* _FC_FS_H_ */
drivers/scsi/ofc/include/fc_gs.h +0 -12
index 2ac3d24..6738535 100644
@@ -90,16 +90,4 @@ enum fc_ct_explan {
 	/* definitions not complete */
 };
 
-#ifdef DEBUG_ASSERTS
-/*
- * Static checks for packet structure sizes.
- * These catch some obvious errors in structure definitions.
- * These should generate no code since they can be tested at compile time.
- */
-static inline void fc_gs_size_checks(void)
-{
-	ASSERT_NOTIMPL(sizeof(struct fc_ct_hdr) == FC_CT_HDR_LEN);
-}
-#endif /* DEBUG_ASSERTS */
-
 #endif /* _FC_GS_H_ */
drivers/scsi/ofc/libfc/fc_ils.h +0 -33
index 7225ac5..c421df7 100644
@@ -521,37 +521,4 @@ struct fc_ils_mrra_resp {
 #define	FC_MRRR_AVAIL	1		/* resources available */
 #define	FC_MRRR_UNAV	2		/* resources unavailable */
 
-#ifdef DEBUG_ASSERTS
-/*
- * Static checks for packet structure sizes.
- * These catch some obvious errors in structure definitions.
- * This should generate no code.  The check should be true at compile time.
- */
-static inline void fc_ils_size_checks(void)
-{
-	ASSERT_NOTIMPL(sizeof(struct fc_ils_sw_rjt) == FC_ILS_SW_RJT_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_ils_gnf) == FC_ILS_GNF_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_elp_f_params) ==
-		       FC_ILS_ELP_F_PARAMS_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_ils_elp) == FC_ILS_ELP_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_ils_elp_r_rdy) == FC_ILS_ELP_R_RDY_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_ils_elp_vc_rdy) ==
-		       FC_ILS_ELP_VC_RDY_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_ils_efp) == FC_ILS_EFP_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_ils_efp_rec) == FC_ILS_EFP_REC_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_ils_mcast_id_rec) ==
-		       FC_ILS_MCAST_ID_REC_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_ils_dia) == FC_ILS_DIA_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_ils_rdi) == FC_ILS_RDI_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_ils_fspf) == FC_ILS_FSPF_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_ils_hlo) == FC_ILS_HLO_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_ils_lsu) == FC_ILS_LSU_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_ils_lsr) == FC_ILS_LSR_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_link_desc) == FC_LINK_DESC_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_ils_esc) == FC_ILS_ESC_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_ils_mrra) == FC_ILS_MRRA_LEN);
-	ASSERT_NOTIMPL(sizeof(struct fc_ils_mrra_resp) == FC_ILS_MRRA_RESP_LEN);
-}
-#endif /* DEBUG_ASSERTS */
-
 #endif /* _FC_ILS_H_ */
drivers/scsi/ofc/libfc/fc_sess.c +0 -14
index 65204ae..ee08c97 100644
@@ -116,20 +116,6 @@ static inline void fc_sess_unlock(struct fc_sess *sess)
 	spin_unlock_bh(&sess->fs_lock);
 }
 
-#ifdef DEBUG_ASSERTS
-/*
- * Check whether session is locked.
- */
-static inline int fc_sess_locked(const struct fc_sess *sess)
-{
-#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
-	return spin_is_locked((spinlock_t *) &sess->fs_lock);
-#else
-	return 1;
-#endif /* CONFIG_SMP || CONFIG_DEBUG_SPINLOCK */
-}
-#endif /* DEBUG_ASSERTS */
-
 /*
  * Unlock session.
  * This must handle operations that defer because they can't be done
#4 lore raw

PATCH 4/10 Remove ASSERTs from libfc

In reply to Robert Love

---

 drivers/scsi/ofc/include/fc_frame.h         |   17 +----
 drivers/scsi/ofc/libfc/fc_disc_targ.c       |   25 ++------
 drivers/scsi/ofc/libfc/fc_exch.c            |   89 ++++++++-------------------
 drivers/scsi/ofc/libfc/fc_frame.c           |    1 
 drivers/scsi/ofc/libfc/fc_local_port.c      |   60 ++++--------------
 drivers/scsi/ofc/libfc/fc_local_port_impl.h |    1 
 drivers/scsi/ofc/libfc/fc_port.c            |    9 +--
 drivers/scsi/ofc/libfc/fc_print.c           |    1 
 drivers/scsi/ofc/libfc/fc_remote_port.c     |   21 +++---
 drivers/scsi/ofc/libfc/fc_sess.c            |   63 +++++++------------
 drivers/scsi/ofc/libfc/fc_virt_fab.c        |    1 
 drivers/scsi/ofc/libfc/fcs_attr.c           |    1 
 drivers/scsi/ofc/libfc/fcs_cmd.c            |    7 +-
 drivers/scsi/ofc/libfc/fcs_event.c          |    3 -
 drivers/scsi/ofc/libfc/fcs_state.c          |   25 +++-----
 15 files changed, 103 insertions(+), 221 deletions(-)
drivers/scsi/ofc/include/fc_frame.h +3 -14
index 36e9dce..6f8e85e 100644
@@ -109,7 +109,6 @@ static inline void fc_frame_init_static(struct fc_frame *fp)
  */
 static inline int fc_frame_freed_static(struct fc_frame *fp)
 {
-	ASSERT(fp->fr_flags & FCPHF_STATIC);
 	return (fp->fr_flags & FCPHF_FREED);
 }
 
@@ -127,8 +126,7 @@ struct fc_frame *fc_frame_alloc_fill(struct fc_port *, size_t payload_len);
 static inline struct fc_frame *fc_port_frame_alloc(struct fc_port *port,
 	size_t payload_len)
 {
-	ASSERT(port->np_frame_alloc);
-	ASSERT((payload_len % 4) == 0);
+	WARN_ON((payload_len % 4) != 0);
 	return (*port->np_frame_alloc)(payload_len);
 }
 
@@ -137,8 +135,6 @@ static inline struct fc_frame *fc_frame_alloc_inline(struct fc_port *port,
 {
 	struct fc_frame *fp;
 
-	ASSERT(port);
-
 	/*
 	 * Note: Since len will often be a constant multiple of 4,
 	 * this check will usually be evaluated and eliminated at compile time.
@@ -166,9 +162,6 @@ static inline struct fc_frame *fc_frame_alloc_inline(struct fc_port *port,
  */
 static inline void fc_frame_free(struct fc_frame *fp)
 {
-	ASSERT(fp);
-	ASSERT(fp->fr_free);
-	ASSERT(fp->fr_hdr);
 	FC_FRAME_STAMP(fp);
 	fp->fr_hdr = NULL;
 	(*fp->fr_free)(fp);
@@ -186,8 +179,7 @@ static inline int fc_frame_is_linear(struct fc_frame *fp)
 static inline struct fc_frame_header *fc_frame_header_get(const struct
 							  fc_frame *fp)
 {
-	ASSERT(fp != NULL);
-	ASSERT(fp->fr_len >= sizeof(struct fc_frame_header));
+	WARN_ON(fp->fr_len < sizeof(struct fc_frame_header));
 	return fp->fr_hdr;
 }
 
@@ -206,7 +198,6 @@ static inline void *fc_frame_payload_get(const struct fc_frame *fp,
 {
 	void *pp = NULL;
 
-	ASSERT(fp != NULL);
 	if (fp->fr_len >= sizeof(struct fc_frame_header) + len)
 		pp = fc_frame_header_get(fp) + 1;
 	return pp;
@@ -239,8 +230,7 @@ static inline void fc_frame_setup(struct fc_frame *fp, enum fc_rctl r_ctl,
 	struct fc_frame_header *fh;
 
 	fh = fc_frame_header_get(fp);
-	ASSERT(fh != NULL);
-	ASSERT(r_ctl != 0);
+	WARN_ON(r_ctl == 0);
 	fh->fh_r_ctl = r_ctl;
 	fh->fh_type = type;
 	net32_put(&fh->fh_parm_offset, 0);
@@ -255,7 +245,6 @@ fc_frame_set_offset(struct fc_frame *fp, u_int32_t offset)
 	struct fc_frame_header *fh;
 
 	fh = fc_frame_header_get(fp);
-	ASSERT(fh != NULL);
 	net32_put(&fh->fh_parm_offset, offset);
 }
 
drivers/scsi/ofc/libfc/fc_disc_targ.c +8 -17
index 4906a2b..eb24e52 100644
@@ -26,7 +26,6 @@
 #undef LIST_HEAD
 #include "net_types.h"
 
-#include "sa_assert.h"
 #include "ofc_dbg.h"
 #include "sa_timer.h"
 #include "sa_event.h"
@@ -204,7 +203,6 @@ static int fcdt_new_target(struct fc_local_port *lp,
 	int error = 0;
 
 	if (rp && wwpn) {
-		ASSERT(atomic_read(&rp->rp_refcnt) > 0);
 		if (rp->rp_port_wwn == 0) {
 			/*
 			 * Set WWN and fall through to notify of create.
@@ -258,7 +256,6 @@ static void fcdt_del_target(struct fc_local_port *lp, struct fc_remote_port *rp)
 {
 	struct fc_sess *sess;
 
-	ASSERT(atomic_read(&rp->rp_refcnt) > 0);	/* caller holds rp */
 	sess = rp->rp_sess;
 	if (sess) {
 		rp->rp_sess_ready = 0;
@@ -310,7 +307,7 @@ static void fcdt_done(struct fc_local_port *lp)
 		else
 			held = NULL;
 	}
-	ASSERT(!held);
+	WARN_ON(held);
 	fc_virt_fab_unlock(vp);
 	(*lp->fl_disc_cb) (lp->fl_disc_cb_arg, NULL, FC_EV_NONE);
 	lp->fl_disc_in_prog = 0;
@@ -347,12 +344,10 @@ static void fcdt_gpn_ft_req(struct fc_local_port *lp)
 		error = ENOMEM;
 	} else {
 		rp = fc_frame_payload_get(fp, sizeof(*rp));
-		ASSERT(rp);
 		fcdt_fill_dns_hdr(lp, &rp->ct, FC_NS_GPN_FT, sizeof(rp->gid));
 		rp->gid.fn_fc4_type = lp->fl_disc_type;
 
-		ASSERT(lp->fl_dns_sess);
-		ASSERT(fc_local_port_test_ready(lp));
+		WARN_ON(!fc_local_port_test_ready(lp));
 
 		fc_frame_setup(fp, FC_RCTL_DD_UNSOL_CTL, FC_TYPE_CT);
 		error = fc_sess_send_req(lp->fl_dns_sess, fp, fcdt_gpn_ft_resp,
@@ -406,10 +401,10 @@ static int fcdt_gpn_ft_parse(struct fc_local_port *lp, void *buf, size_t len)
 	np = (struct fc_gpn_ft_resp *)bp;
 	tlen = lp->fl_disc_buf_len;
 	if (tlen) {
-		ASSERT(tlen < sizeof(*np));
+		WARN_ON(tlen >= sizeof(*np));
 		plen = sizeof(*np) - tlen;
-		ASSERT(plen > 0);
-		ASSERT(plen < sizeof(*np));
+		WARN_ON(plen <= 0);
+		WARN_ON(plen >= sizeof(*np));
 		if (plen > len)
 			plen = len;
 		np = &lp->fl_disc_buf;
@@ -492,7 +487,7 @@ static void fcdt_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp,
 	u_int len;
 	int error;
 
-	ASSERT(fc_frame_is_linear(fp));	/* buffer must be contiguous */
+	WARN_ON(!fc_frame_is_linear(fp));	/* buffer must be contiguous */
 	fh = fc_frame_header_get(fp);
 	len = fp->fr_len - sizeof(*fh);;
 	seq_cnt = net16_get(&fh->fh_seq_cnt);
@@ -571,12 +566,10 @@ static int fcdt_gpn_id_req(struct fc_local_port *lp, struct fc_remote_port *rp)
 		error = ENOMEM;
 	} else {
 		cp = fc_frame_payload_get(fp, sizeof(*cp));
-		ASSERT(cp);
 		fcdt_fill_dns_hdr(lp, &cp->ct, FC_NS_GPN_ID, sizeof(cp->fid));
 		net24_put(&cp->fid.fp_fid, rp->rp_fid);
 
-		ASSERT(lp->fl_dns_sess);
-		ASSERT(fc_local_port_test_ready(lp));
+		WARN_ON(!fc_local_port_test_ready(lp));
 
 		fc_frame_setup(fp, FC_RCTL_DD_UNSOL_CTL, FC_TYPE_CT);
 		error = fc_sess_send_req(lp->fl_dns_sess, fp, fcdt_gpn_id_resp,
@@ -601,8 +594,7 @@ static void fcdt_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp,
 	u_int cmd;
 
 	lp = list_first_entry(&rp->rp_vf->vf_local_ports, struct fc_local_port, fl_list);
-	ASSERT(lp);
-	ASSERT(fc_frame_is_linear(fp));	/* buffer must be contiguous */
+	WARN_ON(!fc_frame_is_linear(fp));	/* buffer must be contiguous */
 
 	cp = fc_frame_payload_get(fp, sizeof(cp->ct));
 	if (cp == NULL) {
@@ -652,7 +644,6 @@ static void fcdt_gpn_id_error(enum fc_event event, void *rp_arg)
 	case FC_EV_TIMEOUT:
 	case FC_EV_READY:
 		lp = list_first_entry(&rp->rp_vf->vf_local_ports, struct fc_local_port, fl_list);
-		ASSERT(lp);
 		fc_disc_targ_restart(lp);
 		break;
 	case FC_EV_CLOSED:
drivers/scsi/ofc/libfc/fc_exch.c +28 -61

309 lines not on this page · raw message

drivers/scsi/ofc/libfc/fc_frame.c +0 -1
index c609ebd..34d7a8a 100644
@@ -23,7 +23,6 @@
 
 #include "sa_kernel.h"
 #include "net_types.h"
-#include "sa_assert.h"
 #include "ofc_dbg.h"
 #include "fc_fs.h"
 #include "fc_types.h"
drivers/scsi/ofc/libfc/fc_local_port.c +12 -48

250 lines not on this page · raw message

drivers/scsi/ofc/libfc/fc_local_port_impl.h +0 -1
index d5825f1..4b5f342 100644
@@ -138,7 +138,6 @@ static inline void fc_local_port_unlock(struct fc_local_port *lp)
 static inline void fc_local_port_unlock_send(struct fc_local_port *lp)
 {
 	fc_local_port_unlock(lp);
-	ASSERT(atomic_read(&lp->fl_refcnt) != 0);
 	sa_event_send_deferred(lp->fl_events);
 }
 
drivers/scsi/ofc/libfc/fc_port.c +4 -5
index 191ab4f..c225fed 100644
@@ -18,7 +18,6 @@
  */
 
 #include "sa_kernel.h"
-#include "sa_assert.h"
 #include "sa_error_inject.h"
 #include "ofc_dbg.h"
 #include "sa_event.h"
@@ -88,7 +87,7 @@ void fc_port_free(struct fc_port *port)
 void fc_port_set_max_frame_size(struct fc_port *port, u_int mfs)
 {
 	mfs &= ~3;
-	ASSERT((size_t) mfs >= FC_MIN_MAX_FRAME);
+	WARN_ON((size_t) mfs < FC_MIN_MAX_FRAME);
 	if (mfs > FC_MAX_FRAME)
 		mfs = FC_MAX_FRAME;
 	port->np_max_frame = mfs;
@@ -157,7 +156,7 @@ void fc_port_close_ingress(struct fc_port *port)
  */
 int fc_port_egress(struct fc_port *port, struct fc_frame *fp)
 {
-	ASSERT(port->np_egress);
+	WARN_ON(!port->np_egress);
 	if (SA_ERROR_INJECT) {
 		fc_frame_free(fp);
 		return EBUSY;
@@ -170,8 +169,8 @@ int fc_port_egress(struct fc_port *port, struct fc_frame *fp)
  */
 void fc_port_ingress(struct fc_port *port, struct fc_frame *fp)
 {
-	ASSERT(port != NULL);
-	ASSERT(port->np_ingress != NULL);
+	WARN_ON(!port);
+	WARN_ON(!(port->np_ingress));
 	(*port->np_ingress) (port->np_ingress_arg, fp);
 }
 
drivers/scsi/ofc/libfc/fc_print.c +0 -1
index ae6fa1e..2b51a5b 100644
@@ -22,7 +22,6 @@
  */
 
 #include "sa_kernel.h"
-#include "sa_assert.h"
 #include "net_types.h"
 #include "ofc_dbg.h"
 #include "fc_fs.h"
drivers/scsi/ofc/libfc/fc_remote_port.c +9 -12
index 9a5e62a..b0061f5 100644
@@ -26,7 +26,6 @@
 
 #include "sa_kernel.h"
 #undef LIST_HEAD
-#include "sa_assert.h"
 #include "sa_event.h"
 #include "sa_hash.h"
 #include "ofc_dbg.h"
@@ -89,7 +88,7 @@ int fc_remote_port_table_create(struct fc_virt_fab *vp)
 
 void fc_remote_port_table_destroy(struct fc_virt_fab *vp)
 {
-	ASSERT(list_empty(&vp->vf_remote_ports));
+	WARN_ON(!list_empty(&vp->vf_remote_ports));
 	INIT_LIST_HEAD(&vp->vf_remote_ports);
 	if (vp->vf_rport_by_fid)
 		sa_hash_destroy(vp->vf_rport_by_fid);
@@ -226,8 +225,8 @@ void fc_remote_port_set_name(struct fc_remote_port *rp, fc_wwn_t wwpn,
 	if (old_name) {
 		found_rp = sa_hash_lookup_delete(vp->vf_rport_by_wwpn,
 						 &old_name);
-		ASSERT(found_rp);
-		ASSERT(found_rp == rp);
+		WARN_ON(!found_rp);
+		WARN_ON(found_rp != rp);
 	}
 #endif /* FC_REMOTE_PORT_BY_WWPN */
 	rp->rp_node_wwn = wwnn;
@@ -253,8 +252,8 @@ void fc_remote_port_set_fid(struct fc_remote_port *rp, fc_fid_t fid)
 		if (rp->rp_fid != 0) {
 			found_rp = sa_hash_lookup_delete(vp->vf_rport_by_fid,
 							 &rp->rp_fid);
-			ASSERT(found_rp);
-			ASSERT(found_rp == rp);
+			WARN_ON(!found_rp);
+			WARN_ON(found_rp != rp);
 		}
 		rp->rp_fid = fid;
 		if (fid)
@@ -273,15 +272,15 @@ static void fc_remote_port_delete(struct fc_remote_port *rp)
 	if (rp->rp_fid != 0) {
 		found = sa_hash_lookup_delete(rp->rp_vf->vf_rport_by_fid,
 					      &rp->rp_fid);
-		ASSERT(found);
-		ASSERT(found == rp);
+		WARN_ON(!found);
+		WARN_ON(found != rp);
 	}
 #ifdef FC_REMOTE_PORT_BY_WWPN
 	if (rp->rp_port_wwn) {
 		found = sa_hash_lookup_delete(rp->rp_vf->vf_rport_by_wwpn,
 					      &rp->rp_port_wwn);
-		ASSERT(found);
-		ASSERT(found == rp);
+		WARN_ON(!found);
+		WARN_ON(found != rp);
 	}
 #endif /* FC_REMOTE_PORT_BY_WWPN */
 	list_del(&rp->rp_list);
@@ -293,12 +292,10 @@ static void fc_remote_port_delete(struct fc_remote_port *rp)
 void fc_remote_port_hold(struct fc_remote_port *rp)
 {
 	atomic_inc(&rp->rp_refcnt);
-	ASSERT(atomic_read(&rp->rp_refcnt) > 0);
 }
 
 void fc_remote_port_release(struct fc_remote_port *rp)
 {
-	ASSERT(atomic_read(&rp->rp_refcnt) > 0);
 	if (atomic_dec_and_test(&rp->rp_refcnt))
 		fc_remote_port_delete(rp);
 }
drivers/scsi/ofc/libfc/fc_sess.c +24 -39

247 lines not on this page · raw message

drivers/scsi/ofc/libfc/fc_virt_fab.c +0 -1
index ff87244..dd84628 100644
@@ -26,7 +26,6 @@
 
 #include "sa_kernel.h"
 #undef LIST_HEAD
-#include "sa_assert.h"
 #include "sa_event.h"
 #include "net_types.h"
 
drivers/scsi/ofc/libfc/fcs_attr.c +0 -1
index 5b355de..cc6ad1f 100644
@@ -35,7 +35,6 @@
 #include <scsi/scsi_tcq.h>
 
 #include "sa_kernel.h"
-#include "sa_assert.h"
 #include "ofc_dbg.h"
 #include "sa_event.h"
 #include "net_types.h"
drivers/scsi/ofc/libfc/fcs_cmd.c +3 -4
index 5564f82..fb066bd 100644
@@ -18,7 +18,6 @@
  */
 
 #include "sa_kernel.h"
-#include "sa_assert.h"
 #include "ofc_dbg.h"
 #include "fc_types.h"
 #include "fc_event.h"
@@ -90,7 +89,7 @@ int fcs_cmd_send(struct fcs_state *sp, struct fc_frame *fp,
 	int rc;
 
 	might_sleep();
-	ASSERT(!rfp->fr_sg_len);
+	WARN_ON(rfp->fr_sg_len);
 	lp = sp->fs_local_port;
 	fh = fc_frame_header_get(fp);
 
@@ -198,8 +197,8 @@ static void fcs_cmd_recv(struct fc_seq *seq, struct fc_frame *fp, void *arg)
 	uint32_t len;
 	u_int error = 0;	/* XXX for debugging */
 
-	ASSERT(!fp->fr_sg_len);
-	ASSERT(!(fp->fr_flags & FCPHF_CRC_UNCHECKED));
+	WARN_ON(fp->fr_sg_len);
+	WARN_ON((fp->fr_flags & FCPHF_CRC_UNCHECKED) == FCPHF_CRC_UNCHECKED);
 
 	fh = fc_frame_header_get(fp);
 	if (fh->fh_type != cp->fcc_req_hdr.fh_type)
drivers/scsi/ofc/libfc/fcs_event.c +1 -2
index d6ab9d9..5d5cfa6 100644
@@ -32,7 +32,7 @@
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_transport.h>
 #include <scsi/scsi_transport_fc.h>
-#include "sa_assert.h"
+
 #include "ofc_dbg.h"
 #include "fc_types.h"
 #include "fc_frame.h"
@@ -87,7 +87,6 @@ static struct fcs_ev_elem *fcs_ev_peek(struct fcs_event_queue *qp)
 {
 	struct fcs_ev_elem *fp = NULL;
 
-	ASSERT(spin_is_locked(&qp->fev_lock));
 	if (!list_empty(&qp->fev_list))
 		fp = list_entry(qp->fev_list.next, struct fcs_ev_elem, ev_list);
 	return fp;
drivers/scsi/ofc/libfc/fcs_state.c +11 -14
index 794f440..78dd61a 100644
@@ -18,7 +18,6 @@
  */
 
 #include "sa_kernel.h"
-#include "sa_assert.h"
 #include "ofc_dbg.h"
 #include "fc_types.h"
 #include "fc_frame.h"
@@ -79,8 +78,8 @@ struct fcs_state *fcs_create(struct fcs_create_args *ap)
 	struct fc_port *outer_port;
 	size_t mfs;
 
-	ASSERT(ap->fca_disc_done);
-	ASSERT(ap->fca_port);
+	WARN_ON(!ap->fca_disc_done);
+	WARN_ON(!ap->fca_port);
 
 	sp = sa_malloc(sizeof(*sp));
 	if (!sp)
@@ -145,7 +144,7 @@ void fcs_destroy(struct fcs_state *sp)
 {
 	struct fc_port *port;
 
-	ASSERT(sp->fs_args.fca_port);
+	WARN_ON(!sp->fs_args.fca_port);
 
 	sp->fs_args.fca_disc_done = (void (*)(void *))fcs_nop;
 	sp->fs_args.fca_remote_port_state_change =
@@ -196,7 +195,6 @@ static void fcs_recv_req(void *sp_arg, struct fc_frame *fp)
 	struct fc_frame_header *fh;
 
 	fh = fc_frame_header_get(fp);
-	ASSERT(fh);
 
 	if (fh->fh_type == FC_TYPE_FCP && sp->fs_args.fca_fcp_recv) {
 		(*sp->fs_args.fca_fcp_recv) (fp->fr_seq,
@@ -215,8 +213,8 @@ int fcs_local_port_set(struct fcs_state *sp, fc_wwn_t wwnn, fc_wwn_t wwpn)
 {
 	struct fc_local_port *lp;
 
-	ASSERT(sp->fs_inner_port);
-	ASSERT(!sp->fs_local_port);
+	WARN_ON(!sp->fs_inner_port);
+	WARN_ON(sp->fs_local_port);
 	lp = fc_local_port_create(sp->fs_vf, sp->fs_inner_port, wwpn, wwnn,
 				  sp->fs_args.fca_e_d_tov,
 				  sp->fs_args.fca_plogi_retries);
@@ -236,7 +234,7 @@ int fcs_local_port_set(struct fcs_state *sp, fc_wwn_t wwnn, fc_wwn_t wwpn)
  */
 void fcs_start(struct fcs_state *sp)
 {
-	ASSERT(sp->fs_local_port);
+	WARN_ON(!sp->fs_local_port);
 	fc_local_port_logon(sp->fs_local_port, fcs_local_port_event, sp);
 }
 
@@ -245,7 +243,7 @@ void fcs_start(struct fcs_state *sp)
  */
 void fcs_stop(struct fcs_state *sp)
 {
-	ASSERT(sp->fs_local_port);
+	WARN_ON(!sp->fs_local_port);
 	fc_local_port_logoff(sp->fs_local_port);
 }
 
@@ -259,7 +257,7 @@ void fcs_reset(struct fcs_state *sp)
 {
 	struct fc_local_port *lp;
 
-	ASSERT(sp->fs_local_port);
+	WARN_ON(!sp->fs_local_port);
 	lp = sp->fs_local_port;
 	sp->fs_disc_done = 0;
 	fc_local_port_reset(lp);
@@ -336,10 +334,10 @@ static void fcs_add_remote(void *fcs_arg, struct fc_remote_port *rp,
 	struct fc_sess *sess;
 
 	lp = sp->fs_local_port;
-	ASSERT(lp);
+	WARN_ON(!lp);
 
 	if (event == FC_EV_CLOSED) {
-		ASSERT(rp->rp_sess_ready == 0);
+		WARN_ON(rp->rp_sess_ready != 0);
 		if (fcs_debug)
 			OFC_DBG("removing remote fid %x wwpn %llx ref %d",
 			       rp->rp_fid, rp->rp_port_wwn,
@@ -386,7 +384,6 @@ static void fcs_sess_event(int event, void *rp_arg)
 	void *arg;
 
 	sp = rp->rp_fcs_priv;
-	ASSERT(sp);
 	arg = sp->fs_args.fca_cb_arg;
 
 	switch (event) {
@@ -441,7 +438,7 @@ static void fcs_port_event(int event, void *sp_arg)
 		fcs_ev_add(sp, OFC_EV_LINK_UP, NULL, 0);
 		break;
 	}
-	ASSERT(sp->fs_inner_port);
+	WARN_ON(!sp->fs_inner_port);
 	fc_port_send_event(sp->fs_inner_port, event);
 }
 
#5 lore raw

PATCH 5/10 Remove ASSERTs from libsa.

In reply to Robert Love

---

 drivers/scsi/ofc/libsa/sa_event.c     |   24 ------------------------
 drivers/scsi/ofc/libsa/sa_hash_kern.c |    7 -------
 drivers/scsi/ofc/libsa/sa_timer.c     |    1 -
 3 files changed, 0 insertions(+), 32 deletions(-)
drivers/scsi/ofc/libsa/sa_event.c +0 -24
index cf6596a..7d9850b 100644
@@ -18,7 +18,6 @@
  */
 
 #include "sa_kernel.h"
-#include "sa_assert.h"
 #include "ofc_dbg.h"
 #include "sa_event.h"
 #include "queue.h"
@@ -66,7 +65,6 @@ struct sa_event_list *sa_event_list_alloc(void)
 		TAILQ_INIT(&lp->se_head);
 		atomic_set(&lp->se_refcnt, 1);
 		spin_lock_init(&lp->se_lock);
-		ASSERT(sa_event_list_initialized(lp));
 	}
 	return lp;
 }
@@ -77,7 +75,6 @@ void sa_event_list_free(struct sa_event_list *lp)
 	struct sa_event *next;
 	unsigned long flags;
 
-	ASSERT(sa_event_list_initialized(lp));
 	spin_lock_irqsave(&lp->se_lock, flags);
 	TAILQ_FOREACH_SAFE(ev, &lp->se_head, se_list, next) {
 		if ((ev->se_flags & SEV_MARK) == 0) {
@@ -91,19 +88,16 @@ void sa_event_list_free(struct sa_event_list *lp)
 
 static void sa_event_list_free_int(struct sa_event_list *lp)
 {
-	ASSERT(!atomic_read(&lp->se_refcnt));
 	sa_free(lp);
 }
 
 static void sa_event_list_hold(struct sa_event_list *lp)
 {
 	atomic_inc(&lp->se_refcnt);
-	ASSERT(atomic_read(&lp->se_refcnt));
 }
 
 static void sa_event_list_release(struct sa_event_list *lp)
 {
-	ASSERT(atomic_read(&lp->se_refcnt));
 	if (atomic_dec_and_test(&lp->se_refcnt))
 		sa_event_list_free_int(lp);
 }
@@ -120,8 +114,6 @@ struct sa_event *sa_event_enq(struct sa_event_list *lp,
 	struct sa_event_head *hp;
 	unsigned long flags;
 
-	ASSERT(sa_event_list_initialized(lp));
-	ASSERT(handler != NULL);
 	spin_lock_irqsave(&lp->se_lock, flags);
 	hp = &lp->se_head;
 	TAILQ_FOREACH(ev, &lp->se_head, se_list) {
@@ -147,8 +139,6 @@ void sa_event_deq_ev(struct sa_event_list *lp, struct sa_event *ev)
 	unsigned long flags;
 
 	spin_lock_irqsave(&lp->se_lock, flags);
-	ASSERT(sa_event_list_initialized(lp));
-	ASSERT((ev->se_flags & SEV_MARK) == 0);
 	TAILQ_REMOVE(&lp->se_head, ev, se_list);
 	spin_unlock_irqrestore(&lp->se_lock, flags);
 	sa_free(ev);
@@ -162,7 +152,6 @@ sa_event_deq(struct sa_event_list *lp, void (*handler) (int, void *), void *arg)
 	unsigned long flags;
 
 	spin_lock_irqsave(&lp->se_lock, flags);
-	ASSERT(sa_event_list_initialized(lp));
 
 	TAILQ_FOREACH_SAFE(ev, &lp->se_head, se_list, next) {
 		if (ev->se_handler == handler && ev->se_arg == arg) {
@@ -187,7 +176,6 @@ void sa_event_call(struct sa_event_list *lp, int rc)
 	unsigned long flags;
 
 	spin_lock_irqsave(&lp->se_lock, flags);
-	ASSERT(sa_event_list_initialized(lp));
 	memset(&mark, 0, sizeof(mark));
 	mark.se_flags = SEV_MARK;
 
@@ -202,7 +190,6 @@ void sa_event_call(struct sa_event_list *lp, int rc)
 		TAILQ_INSERT_AFTER(&lp->se_head, ev, &mark, se_list);
 		spin_unlock_irqrestore(&lp->se_lock, flags);
 
-		ASSERT(ev->se_handler != NULL);
 		(*ev->se_handler) (rc, ev->se_arg);
 
 		spin_lock_irqsave(&lp->se_lock, flags);
@@ -218,9 +205,6 @@ void sa_event_call(struct sa_event_list *lp, int rc)
  */
 void sa_event_call_defer(struct sa_event_list *lp, int event)
 {
-	ASSERT(sa_event_list_initialized(lp));
-	ASSERT(event >= 0);
-	ASSERT(event < sizeof(lp->se_pending_events) * 8);
 	atomic_set_mask(1 << event, &lp->se_pending_events);
 }
 
@@ -229,9 +213,6 @@ void sa_event_call_defer(struct sa_event_list *lp, int event)
  */
 void sa_event_call_cancel(struct sa_event_list *lp, int event)
 {
-	ASSERT(sa_event_list_initialized(lp));
-	ASSERT(event >= 0);
-	ASSERT(event < sizeof(lp->se_pending_events) * 8);
 	atomic_clear_mask(1 << event, &lp->se_pending_events);
 }
 
@@ -243,13 +224,8 @@ void sa_event_send_deferred(struct sa_event_list *lp)
 	u_int32_t mask;
 	u_int event;
 
-	ASSERT(sa_event_list_initialized(lp));
-	ASSERT(sizeof(mask) == sizeof(lp->se_pending_events));
-
 	while ((mask = atomic_read(&lp->se_pending_events)) != 0) {
 		event = ffs(mask) - 1;
-		ASSERT(event >= 0);
-		ASSERT(event < sizeof(lp->se_pending_events) * 8);
 		atomic_clear_mask(1 << event, &lp->se_pending_events);
 		sa_event_call(lp, event);
 	}
drivers/scsi/ofc/libsa/sa_hash_kern.c +0 -7
index 6046758..f1103a5 100644
@@ -18,7 +18,6 @@
  */
 
 #include "sa_kernel.h"
-#include "sa_assert.h"
 #include "ofc_dbg.h"
 #include "sa_hash.h"
 
@@ -51,9 +50,6 @@ struct sa_hash *sa_hash_create(const struct sa_hash_type *tp, uint32_t req_size)
 	for (size = 4; size < (1UL << 31); size <<= 1)
 		if (size >= req_size)
 			break;
-	ASSERT(size >= req_size);
-	ASSERT(size < (1UL << 31));
-	ASSERT((size & (size - 1)) == 0);	/* test for a power of 2 */
 
 	len = sizeof(*hp) + size * sizeof(struct hlist_head);
 	hp = sa_malloc(len);
@@ -67,7 +63,6 @@ struct sa_hash *sa_hash_create(const struct sa_hash_type *tp, uint32_t req_size)
 
 void sa_hash_destroy(struct sa_hash *hp)
 {
-	ASSERT(hp->sh_entries == 0);
 	sa_free(hp);
 }
 
@@ -117,7 +112,6 @@ void sa_hash_insert(struct sa_hash *hp, const sa_hash_key_t key, void *ep)
 	hhp = sa_hash_bucket(hp, key);
 	hlist_add_head_rcu(lp, hhp);
 	hp->sh_entries++;
-	ASSERT(hp->sh_entries > 0);	/* check for overflow */
 }
 
 /*
@@ -144,5 +138,4 @@ sa_hash_iterate(struct sa_hash *hp,
 	}
 	if (count != hp->sh_entries)
 		OFC_DBG("sh_entries %d != count %d", hp->sh_entries, count);
-	ASSERT(count == hp->sh_entries);
 }
drivers/scsi/ofc/libsa/sa_timer.c +0 -1
index 0e3d422..df87fbd 100644
@@ -22,7 +22,6 @@
 #include <linux/timer.h>
 #include <linux/jiffies.h>
 
-#include "sa_assert.h"
 #include "ofc_dbg.h"
 #include "sa_timer.h"
 
#6 lore raw

PATCH 6/10 Remove ASSERTs from openfc

In reply to Robert Love

---

 drivers/scsi/ofc/openfc/openfc_attr.c  |    1 -
 drivers/scsi/ofc/openfc/openfc_if.c    |    3 ---
 drivers/scsi/ofc/openfc/openfc_ioctl.c |    1 -
 drivers/scsi/ofc/openfc/openfc_pkt.c   |    4 ----
 drivers/scsi/ofc/openfc/openfc_scsi.c  |   24 +++++++++++-------------
 5 files changed, 11 insertions(+), 22 deletions(-)
drivers/scsi/ofc/openfc/openfc_attr.c +0 -1
index 12b00c3..d2a3b17 100644
@@ -33,7 +33,6 @@
 #include <scsi/scsi_transport_fc.h>
 
 #include "fc_types.h"
-#include "sa_assert.h"
 #include "fc_port.h"
 #include "fc_remote_port.h"
 #include "fcdev.h"
drivers/scsi/ofc/openfc/openfc_if.c +0 -3
index 0b0c782..179f750 100644
@@ -34,7 +34,6 @@
 #include <scsi/scsi_tcq.h>
 
 #include "fc_types.h"
-#include "sa_assert.h"
 #include "fc_port.h"
 #include "fc_event.h"
 #include "fc_remote_port.h"
@@ -277,8 +276,6 @@ static int openfc_queuecommand(struct scsi_cmnd *sc_cmd,
 	int rc = 0;
 	struct fcoe_dev_stats *stats;
 
-	ASSERT(done != NULL);
-
 	openfcp = (struct openfc_softc *)sc_cmd->device->host->hostdata;
 
 	if (openfcp->state != OPENFC_RUNNING) {
drivers/scsi/ofc/openfc/openfc_ioctl.c +0 -1
index d04164b..60662d9 100644
@@ -28,7 +28,6 @@
 #include <scsi/scsi_transport_fc.h>
 #include <scsi/scsi_tcq.h>
 
-#include "sa_assert.h"
 #include "fc_types.h"
 #include "fc_encaps.h"
 #include "fc_frame.h"
drivers/scsi/ofc/openfc/openfc_pkt.c +0 -4
index baaa77f..ecb1aae 100644
@@ -32,7 +32,6 @@
  */
 #include "sa_kernel.h"
 #include "fc_types.h"
-#include "sa_assert.h"
 #include "fc_event.h"
 #include "fc_port.h"
 #include "fc_remote_port.h"
@@ -69,8 +68,6 @@ struct fc_scsi_pkt *openfc_alloc_scsi_pkt(struct openfc_softc *openfcp)
 {
 	struct fc_scsi_pkt *sp;
 
-	ASSERT(openfcp != NULL);
-
 	sp = kmem_cache_alloc(openfcp->openfc_scsi_pkt_cachep,
 			      openfcp->alloc_flags);
 	if (sp) {
@@ -110,7 +107,6 @@ int openfc_free_scsi_pkt(struct fc_scsi_pkt *sp)
 void openfc_scsi_pkt_hold(struct fc_scsi_pkt *sp)
 {
 	atomic_inc(&sp->ref_cnt);
-	ASSERT(atomic_read(&sp->ref_cnt) != 0);
 }
 
 void openfc_scsi_pkt_release(struct fc_scsi_pkt *sp)
drivers/scsi/ofc/openfc/openfc_scsi.c +11 -13
index 9c7f9bb..f4c742f 100644
@@ -34,7 +34,6 @@
  * non linux dot h files
  */
 #include "fc_types.h"
-#include "sa_assert.h"
 #include "fc_event.h"
 #include "fc_port.h"
 #include "fc_remote_port.h"
@@ -268,12 +267,12 @@ static void openfc_scsi_send_data(struct fc_scsi_pkt *fsp, struct fc_seq *sp,
 		}
 	}
 	mfs = fc_seq_mfs(sp);
-	ASSERT(mfs >= FC_MIN_MAX_PAYLOAD);
-	ASSERT(mfs <= FC_MAX_PAYLOAD);
+	WARN_ON(mfs > FC_MAX_PAYLOAD);
+	WARN_ON(mfs < FC_MIN_MAX_PAYLOAD);
 	if (mfs > 512)
 		mfs &= ~(512 - 1);	/* round down to block size */
-	ASSERT(mfs >= FC_MIN_MAX_PAYLOAD);	/* won't go below 256 */
-	ASSERT(len > 0);
+	WARN_ON(mfs < FC_MIN_MAX_PAYLOAD);	/* won't go below 256 */
+	WARN_ON(len <= 0);
 	sc = fsp->cmd;
 	if (sc->use_sg) {
 		sg = (struct scatterlist *)sc->request_buffer;
@@ -288,7 +287,7 @@ static void openfc_scsi_send_data(struct fc_scsi_pkt *fsp, struct fc_seq *sp,
 	frame_offset = offset;
 	tlen = 0;
 	sp = fc_seq_start_next_fctl(sp, FC_FC_REL_OFF);
-	ASSERT(sp);
+	WARN_ON(!sp);
 
 	if (page_count(sg_page(sg)) == 0)
 		using_sg = 0;
@@ -320,7 +319,7 @@ static void openfc_scsi_send_data(struct fc_scsi_pkt *fsp, struct fc_seq *sp,
 			 * because we can unpin the memory when the
 			 * status of this I/O is received
 			 */
-			ASSERT(fp->fr_sg_len < FC_FRAME_SG_LEN);
+			WARN_ON(fp->fr_sg_len > FC_FRAME_SG_LEN);
 			fsg = &fp->fr_sg[fp->fr_sg_len++];
 			sg_set_page(fsg, sg_page(sg),
 				    sg_bytes, sg->offset + offset);
@@ -355,11 +354,11 @@ static void openfc_scsi_send_data(struct fc_scsi_pkt *fsp, struct fc_seq *sp,
 		}
 		fp = NULL;
 
-		ASSERT(!error);
 		if (error) {
 			/*
 			 * we need to handle this case -XXX
 			 */
+			WARN_ON(1);
 			openfc_scsi_retry(fsp);
 			return;
 		}
@@ -440,7 +439,7 @@ static void openfc_scsi_rcv(struct fc_seq *sp, struct fc_frame *fp, void *arg)
 		 * received XFER RDY from the target
 		 * need to send data to the target
 		 */
-		ASSERT(!(fp->fr_flags & FCPHF_CRC_UNCHECKED));
+		WARN_ON(fp->fr_flags & FCPHF_CRC_UNCHECKED);
 		dd = fc_frame_payload_get(fp, sizeof(*dd));
 		WARN_ON(!dd);
 		fsp->state = OPENFC_SRB_IN_DATA_TRANS;
@@ -467,7 +466,7 @@ static void openfc_scsi_rcv(struct fc_seq *sp, struct fc_frame *fp, void *arg)
 		 * received a DATA frame
 		 * next we will copy the data to the system buffer
 		 */
-		ASSERT(fp->fr_len >= sizeof(*fh));	/* len may be 0 */
+		WARN_ON(fp->fr_len < sizeof(*fh));	/* len may be 0 */
 		fsp->state = OPENFC_SRB_IN_DATA_TRANS;
 		openfc_scsi_recv_data(fsp, fp);
 
@@ -478,7 +477,7 @@ static void openfc_scsi_rcv(struct fc_seq *sp, struct fc_frame *fp, void *arg)
 		 */
 		spin_unlock(&qp->scsi_pkt_lock);
 	} else if (r_ctl == FC_RCTL_DD_CMD_STATUS) {
-		ASSERT(!(fp->fr_flags & FCPHF_CRC_UNCHECKED));
+		WARN_ON(fp->fr_flags & FCPHF_CRC_UNCHECKED);
 
 		/*
 		 * NULL out the outstanding cmd pointer.
@@ -725,7 +724,7 @@ static void openfc_scsi_error(enum fc_event event, void *fsp_arg)
 		spin_unlock(&qp->scsi_pkt_lock);
 	}
 	diskp = fsp->disk;
-	ASSERT(fsp != NULL);
+
 	switch (event) {
 	case FC_EV_TIMEOUT:
 		/*
@@ -933,7 +932,6 @@ int openfc_target_reset(struct fcdev *dev, struct fc_scsi_pkt *fsp)
 				goto out;
 			}
 			sc_cmd = (struct scsi_cmnd *)ofsp->cmd;
-			ASSERT(sc_cmd != NULL);
 			opid = pid;
 			otid = sc_cmd->device->id;
 			olun = sc_cmd->device->lun;
#7 lore raw

PATCH 7/10 Remove ASSERTs from fcoe

In reply to Robert Love

---

 drivers/scsi/ofc/fcoe/fcoe_def.h  |    1 -
 drivers/scsi/ofc/fcoe/fcoe_dev.c  |   16 ++++++----------
 drivers/scsi/ofc/fcoe/fcoe_if.c   |    4 ----
 drivers/scsi/ofc/fcoe/fcoeinit.c  |    1 -
 drivers/scsi/ofc/fcoe/fcoeioctl.c |    1 -
 5 files changed, 6 insertions(+), 17 deletions(-)
drivers/scsi/ofc/fcoe/fcoe_def.h +0 -1
index 22c5934..867ae55 100644
@@ -93,7 +93,6 @@ struct fcoe_rcv_info {
  */
 static inline struct fcoe_rcv_info *fcoe_dev_from_skb(struct sk_buff *skb)
 {
-        ASSERT(sizeof(struct fcoe_rcv_info) <= sizeof(skb->cb));
         return ((struct fcoe_rcv_info *) skb->cb);
 }
 
drivers/scsi/ofc/fcoe/fcoe_dev.c +6 -10
index f37bd2c..0beb78e 100644
@@ -36,7 +36,6 @@
 #include <scsi/scsi_transport_fc.h>
 #include <net/rtnetlink.h>
 
-#include "sa_assert.h"
 #include "fc_types.h"
 #include "fc_frame.h"
 #include "fc_print.h"
@@ -178,7 +177,7 @@ static void fcoe_skb_destroy(struct sk_buff *skb)
 	struct fcdev *fdev = (struct fcdev *)fp->fr_dev;
 	struct fcoe_softc *fc = NULL;
 
-	ASSERT(fp->fr_free_priv == skb);
+	WARN_ON(fp->fr_free_priv != skb);
 
 	if (fdev)
 		fc = (struct fcoe_softc *)fdev->drv_priv;
@@ -201,7 +200,7 @@ struct fc_frame *fcoe_frame_alloc(size_t len)
 	struct fc_frame *fp;
 	struct sk_buff *skb;
 
-	ASSERT((len % sizeof(uint32_t)) == 0);
+	WARN_ON((len % sizeof(uint32_t)) != 0);
 	len += sizeof(struct fc_frame_header);
 	skb = dev_alloc_skb(len + sizeof(*fp) +
 			    FC_FRAME_HEADROOM + FC_FRAME_TAILROOM);
@@ -245,7 +244,7 @@ int fcoe_xmit(struct fcdev *fc_dev, struct fc_frame *fp)
 	if (unlikely(debug_fcoe))
 		fc_print_frame_hdr("fcoe_xmit", fp);
 
-	ASSERT((fp->fr_len % sizeof(uint32_t)) == 0);
+	WARN_ON((fp->fr_len % sizeof(uint32_t)) != 0);
 
 	fc = (struct fcoe_softc *)fc_dev->drv_priv;
 	/*
@@ -272,9 +271,9 @@ int fcoe_xmit(struct fcdev *fc_dev, struct fc_frame *fp)
 		}
 	}
 
-	ASSERT(fp->fr_free == fcoe_frame_free);	/* allocated by us */
+	WARN_ON(fp->fr_free != fcoe_frame_free);	/* allocated by us */
 	skb = (struct sk_buff *)fp->fr_free_priv;
-	ASSERT(skb->data == (unsigned char *)fp->fr_hdr);
+	WARN_ON(skb->data != (unsigned char *)fp->fr_hdr);
 
 	sof = fp->fr_sof;
 	eof = fp->fr_eof;
@@ -394,7 +393,6 @@ int fcoe_xmit(struct fcdev *fc_dev, struct fc_frame *fp)
 	} else {
 		struct fcoe_hdr_old *ohp;
 
-		ASSERT(hlen == sizeof(*ohp));
 		ohp = (struct fcoe_hdr_old *)(eh + 1);
 		net16_put(&ohp->fcoe_plen, FC_FCOE_ENCAPS_LEN_SOF(wlen, sof));
 	}
@@ -502,7 +500,6 @@ int fcoe_percpu_receive_thread(void *arg)
 			struct fcoe_hdr_old *fchp;
 			u_int len;
 
-			ASSERT(hlen == sizeof(*fchp));
 			fchp = (struct fcoe_hdr_old *)skb->data;
 			len = net16_get(&fchp->fcoe_plen);
 			skb_pull(skb, sizeof(*fchp));
@@ -548,7 +545,6 @@ int fcoe_percpu_receive_thread(void *arg)
 		 * and it'll be more cache-efficient.
 		 */
 		fh = fc_frame_header_get(fp);
-		ASSERT(fh);
 		if (fh->fh_r_ctl == FC_RCTL_DD_SOL_DATA &&
 		    fh->fh_type == FC_TYPE_FCP) {
 			fp->fr_flags |= FCPHF_CRC_UNCHECKED;
@@ -568,7 +564,7 @@ int fcoe_percpu_receive_thread(void *arg)
 			stats->ErrorFrames++;
 			fc_frame_free(fp);
 		}
-		ASSERT(fc_frame_freed_static(fp));
+		WARN_ON(!fc_frame_freed_static(fp));
 		kfree_skb(skb);
 	}
 	return 0;
drivers/scsi/ofc/fcoe/fcoe_if.c +0 -4
index 9963593..f3e323d 100644
@@ -40,7 +40,6 @@
 /*
  * Non Linux header definitions
  */
-#include "sa_assert.h"
 #include "fc_types.h"
 #include "fc_frame.h"
 #include "fc_print.h"
@@ -102,8 +101,6 @@ int fcoe_destroy_interface(struct fcdev *fd)
 	net8_t flogi_maddr[ETH_ALEN];
 #endif
 
-	ASSERT(fd != NULL);
-
 	openfc_unregister(fd);
 
 	fc = (struct fcoe_softc *)fd->drv_priv;
@@ -222,7 +219,6 @@ int fcoe_create_interface(struct fcoe_info *fci, void *ptr)
 	net8_t flogi_maddr[ETH_ALEN];
 #endif
 
-	ASSERT(fci != NULL);
 	fdev = openfc_alloc_dev(&fcoe_port_ops, sizeof(struct fcoe_softc));
 	if (unlikely(!fdev)) {
 		OFC_DBG("couldn't allocate space for hba struct");
drivers/scsi/ofc/fcoe/fcoeinit.c +0 -1
index 1ac7d69..a39f451 100644
@@ -29,7 +29,6 @@
 #include <linux/if_ether.h>
 #include <linux/fs.h>
 
-#include "sa_assert.h"
 #include "fc_types.h"
 #include "fc_frame.h"
 #include "fcdev.h"
drivers/scsi/ofc/fcoe/fcoeioctl.c +0 -1
index a2f8a25..8621cff 100644
@@ -22,7 +22,6 @@
 #include <linux/kernel.h>
 #include <linux/fs.h>
 
-#include "sa_assert.h"
 #include "fc_types.h"
 #include "fc_frame.h"
 #include "fcdev.h"
#8 lore raw

PATCH 8/10 Remove ASSERTs from frame headers.

In reply to Robert Love

---

 drivers/scsi/ofc/include/fc_frame.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/scsi/ofc/include/fc_frame.h +0 -1
index 6f8e85e..3fce700 100644
@@ -126,7 +126,6 @@ struct fc_frame *fc_frame_alloc_fill(struct fc_port *, size_t payload_len);
 static inline struct fc_frame *fc_port_frame_alloc(struct fc_port *port,
 	size_t payload_len)
 {
-	WARN_ON((payload_len % 4) != 0);
 	return (*port->np_frame_alloc)(payload_len);
 }
 
#9 lore raw

PATCH 9/10 Remove sa_assert files

In reply to Robert Love

---

 drivers/scsi/ofc/include/sa_assert.h |   85 ----------------------------------
 drivers/scsi/ofc/libsa/Makefile      |    1 
 drivers/scsi/ofc/libsa/sa_assert.c   |   50 --------------------
 3 files changed, 0 insertions(+), 136 deletions(-)
 delete mode 100644 drivers/scsi/ofc/include/sa_assert.h
 delete mode 100644 drivers/scsi/ofc/libsa/sa_assert.c
drivers/scsi/ofc/include/sa_assert.h deleted +0 -85
deleted file mode 100644
index 16224d7..0000000
@@ -1,85 +0,0 @@
-/*
- * Copyright(c) 2007 Intel Corporation. All rights reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- * 
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- * 
- * Maintained at www.Open-FCoE.org
- */
-
-#ifndef _LIBSA_ASSERT_H_
-#define _LIBSA_ASSERT_H_
-
-extern void assert_failed(const char *s, ...)
-    __attribute__ ((format(printf, 1, 2)));
-
-#ifndef UNLIKELY
-#define UNLIKELY(_x) (_x)
-#endif /* UNLIKELY */
-
-/*
- * ASSERT macros
- *
- * ASSERT(expr) - this calls assert_failed() if expr is false.  This variant
- * is not present in production code or if DEBUG_ASSERTS is not defined.
- * Be careful not to rely on expr being evaluated.
- */
-#if defined(DEBUG_ASSERTS)
-#define ASSERT(_x) do {                                                 \
-                if (UNLIKELY(!(_x))) {                                  \
-                        assert_failed("ASSERT FAILED (%s) @ %s:%d\n",   \
-                          "" #_x, __FILE__, __LINE__);                  \
-                }                                                       \
-        } while (0)
-#else
-#define ASSERT(_x)
-#endif /* DEBUG_ASSERTS */
-
-/*
- * ASSERT_NOTIMPL(expr) - this calls assert_failed() if expr is false.
- * The implication is that the condition is not handled by the current
- * implementation, and work should be done eventually to handle this.
- */
-#define ASSERT_NOTIMPL(_x) do {                                         \
-                if (UNLIKELY(!(_x))) {                                  \
-                        assert_failed("ASSERT (NOT IMPL) (%s) @ %s:%d\n", \
-                          "" #_x, __FILE__, __LINE__);                  \
-                }                                                       \
-        } while (0)
-
-/*
- * ASSERT_NOTREACHED - this is the same as ASSERT_NOTIMPL(0).
- */
-#define ASSERT_NOTREACHED do {                                          \
-                assert_failed("ASSERT (NOT REACHED) @ %s:%d\n",         \
-                    __FILE__, __LINE__);                                \
-        } while (0)
-
-/*
- * ASSERT_BUG(bugno, expr).  This variant is used when a bug number has
- * been assigned to any one of the other assertion failures.  It is always
- * present in code.  It gives the bug number which helps locate
- * documentation and helps prevent duplicate bug filings.
- */
-#define ASSERT_BUG(_bugNr, _x) do {                                     \
-                if (UNLIKELY(!(_x))) {                                  \
-                        assert_failed("ASSERT (BUG %d) (%s) @ %s:%d\n", \
-                            (_bugNr), #_x, __FILE__, __LINE__);         \
-                }                                                       \
-        } while (0)
-
-#ifndef LIBSA_USE_DANGEROUS_ROUTINES
-#define gets   DONT_USE_gets
-#endif /* LIBSA_USE_DANGEROUS_ROUTINES */
-
-#endif /* _LIBSA_ASSERT_H_ */
drivers/scsi/ofc/libsa/Makefile +0 -1
index 42b8733..6206b78 100644
@@ -5,7 +5,6 @@ EXTRA_CFLAGS += -I$(OFC_DIR)/include
 obj-y += libsa.o
 
 libsa-y := \
-	sa_assert.o \
 	sa_event.o \
 	sa_hash_kern.o \
 	sa_timer.o
drivers/scsi/ofc/libsa/sa_assert.c deleted +0 -50

50 lines not on this page · raw message

#10 lore raw

PATCH 10/10 Removing unused defines

In reply to Robert Love

These defines were used with the DEBUG_ASSERT code that has been removed.

Removed defines are,

FC_ELS_CSP_LEN
FC_ELS_CSSP_LEN
FC_ELS_FLOGI_LEN
FC_ELS_SPP_LEN
FC_ELS_RRQ_LEN
FC_ELS_PRLI_LEN
FC_ELS_LOGO_LEN

---

 drivers/scsi/ofc/include/fc_els.h |   14 --------------
 1 files changed, 0 insertions(+), 14 deletions(-)
drivers/scsi/ofc/include/fc_els.h +0 -14
index 6bff73e..502f0c5 100644
@@ -232,8 +232,6 @@ struct fc_els_csp {
 #define	sp_rel_off	sp_u.sp_plogi._sp_rel_off
 #define	sp_r_a_tov	sp_u.sp_flogi_acc._sp_r_a_tov
 
-#define	FC_ELS_CSP_LEN	16	/* expected size of struct */
-
 #define	FC_SP_BB_DATA_MASK 0xfff /* mask for data field size in sp_bb_data */
 
 /*
@@ -278,8 +276,6 @@ struct fc_els_cssp {
 	u_int8_t	_cp_resv2[2];	/* reserved */
 };
 
-#define	FC_ELS_CSSP_LEN 16	/* expected size of struct */
-
 /*
  * cp_class flags.
  */
@@ -314,8 +310,6 @@ struct fc_els_flogi {
 	net8_t		fl_vend[16];	/* vendor version level */
 };
 
-#define	FC_ELS_FLOGI_LEN (7 * 16 + 4)	/* expected size of flogi struct */
-
 /*
  * Process login service parameter page.
  */
@@ -329,8 +323,6 @@ struct fc_els_spp {
 	net32_t		spp_params;	/* service parameters */
 };
 
-#define	FC_ELS_SPP_LEN	    16	/* expected length of struct */
-
 /*
  * spp_flags.
  */
@@ -365,8 +357,6 @@ struct fc_els_rrq {
 	net16_t		rrq_rx_id;	/* responders exchange ID */
 };
 
-#define	FC_ELS_RRQ_LEN	    12	/* expected length of struct */
-
 /*
  * ELS_REC - Read exchange concise.
  */
@@ -405,8 +395,6 @@ struct fc_els_prli {
 	/* service parameter pages follow */
 };
 
-#define	FC_ELS_PRLI_LEN     4	/* expected length of struct */
-
 /*
  * ELS_LOGO - process or fabric logout.
  */
@@ -418,8 +406,6 @@ struct fc_els_logo {
 	net64_t		fl_n_port_wwn;	/* port name */
 };
 
-#define	FC_ELS_LOGO_LEN     16	/* expected length of struct */
-
 /*
  * ELS_RTV - read timeout value.
  */