svn commit: r241935 - stable/9/sys/cam

Alexander Motin mav at FreeBSD.org
Tue Oct 23 15:15:17 UTC 2012


Author: mav
Date: Tue Oct 23 15:15:16 2012
New Revision: 241935
URL: http://svn.freebsd.org/changeset/base/241935

Log:
  MFC r241028:
  Change queue overflow checks from DIAGNOSTIC+panic() to KASSERT() to make
  them enabled on HEAD by default. It is probably better to do single compare
  then hunt for unexpected memory corruption.

Modified:
  stable/9/sys/cam/cam_queue.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/cam/cam_queue.c
==============================================================================
--- stable/9/sys/cam/cam_queue.c	Tue Oct 23 15:03:25 2012	(r241934)
+++ stable/9/sys/cam/cam_queue.c	Tue Oct 23 15:15:16 2012	(r241935)
@@ -121,11 +121,9 @@ camq_resize(struct camq *queue, int new_
 {
 	cam_pinfo **new_array;
 
-#ifdef DIAGNOSTIC
-	if (new_size < queue->entries)
-		panic("camq_resize: New queue size can't accomodate "
-		      "queued entries.");
-#endif
+	KASSERT(new_size >= queue->entries, ("camq_resize: "
+	    "New queue size can't accomodate queued entries (%d < %d).",
+	    new_size, queue->entries));
 	new_array = (cam_pinfo **)malloc(new_size * sizeof(cam_pinfo *),
 					 M_CAMQ, M_NOWAIT);
 	if (new_array == NULL) {
@@ -156,10 +154,10 @@ camq_resize(struct camq *queue, int new_
 void
 camq_insert(struct camq *queue, cam_pinfo *new_entry)
 {
-#ifdef DIAGNOSTIC
-	if (queue->entries >= queue->array_size)
-		panic("camq_insert: Attempt to insert into a full queue");
-#endif
+
+	KASSERT(queue->entries < queue->array_size,
+	    ("camq_insert: Attempt to insert into a full queue (%d >= %d)",
+	    queue->entries, queue->array_size));
 	queue->entries++;
 	queue->queue_array[queue->entries] = new_entry;
 	new_entry->index = queue->entries;


More information about the svn-src-stable-9 mailing list