On 05/05/2016 09:40 PM, Douglas Gilbert wrote:
  static bool stop_queued_cmnd(struct scsi_cmnd *cmnd)
  {
        unsigned long iflags;
-       int k, qmax, r_qmax;
+       int j, k, qmax, r_qmax;
+       struct sdebug_queue *sqp;
        struct sdebug_queued_cmd *sqcp;
        struct sdebug_dev_info *devip;
        struct sdebug_defer *sd_dp;

-       [ ... ]
+       for (j = 0, sqp = sdebug_q_arr; j < submit_queues; ++j, ++sqp) {
+               spin_lock_irqsave(&sqp->qc_lock, iflags);
+               qmax = sdebug_max_queue;
+               r_qmax = atomic_read(&retired_max_queue);
+               if (r_qmax > qmax)
+                       qmax = r_qmax;
+               for (k = 0; k < qmax; ++k) {
+                       if (test_bit(k, sqp->in_use_bm)) {
+                               sqcp = &sqp->qc_arr[k];
+                               if (cmnd != sqcp->a_cmnd)
+                                       continue;
+                               /* found */
+                               [ ... ]

It is not clear to me why a for-loop is used in this function to look up the sqp pointer instead of calling get_queue() or using sqa_idx?

  static const char * scsi_debug_info(struct Scsi_Host * shp)
  {
-       sprintf(sdebug_info,
-               "scsi_debug, version %s [%s], dev_size_mb=%d, opts=0x%x",
-               SDEBUG_VERSION, sdebug_version_date, sdebug_dev_size_mb,
-               sdebug_opts);
+       int k;
+
+       k = scnprintf(sdebug_info, sizeof(sdebug_info),
+                     "%s: version %s [%s], dev_size_mb=%d, opts=0x%x\n",
+                     my_name, SDEBUG_VERSION, sdebug_version_date,
+                     sdebug_dev_size_mb, sdebug_opts);
+       if (k >= (sizeof(sdebug_info) - 1))
+               return sdebug_info;
+       scnprintf(sdebug_info + k, sizeof(sdebug_info) - k,
+                 "%s: submit_queues=%d, statistics=%d\n", my_name,
+                 submit_queues, (int)sdebug_statistics);
        return sdebug_info;
  }

From the comment above the definition of scnprintf(): "The return value is the number of characters written into @buf not including the trailing '\0'". Maybe you need snprintf() instead of scnprintf()?

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to