Re: svn commit: r329866 - head/sys/cam

2018-02-23 Thread Ian Lepore
On Fri, 2018-02-23 at 16:06 +, Warner Losh wrote:
> -static inline int
> +static inline bool
>  cam_iosched_has_flagged_work(struct cam_iosched_softc *isc)
>  {
> return !!(isc->flags & CAM_IOSCHED_FLAG_WORK_FLAGS);
>  }

There should be no need for the ugly !! here, conversion to bool in C99
is like it is for c++, it converts to zero if the expression being
converted has a value of zero, or to one otherwise.

-- Ian
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r329866 - head/sys/cam

2018-02-23 Thread Warner Losh
Author: imp
Date: Fri Feb 23 16:06:54 2018
New Revision: 329866
URL: https://svnweb.freebsd.org/changeset/base/329866

Log:
  Use bool instead of int for predicate functions relating to work
  available.

Modified:
  head/sys/cam/cam_iosched.c

Modified: head/sys/cam/cam_iosched.c
==
--- head/sys/cam/cam_iosched.c  Fri Feb 23 16:04:44 2018(r329865)
+++ head/sys/cam/cam_iosched.c  Fri Feb 23 16:06:54 2018(r329866)
@@ -718,22 +718,22 @@ cam_iosched_io_metric_update(struct cam_iosched_softc 
 sbintime_t sim_latency, int cmd, size_t size);
 #endif
 
-static inline int
+static inline bool
 cam_iosched_has_flagged_work(struct cam_iosched_softc *isc)
 {
return !!(isc->flags & CAM_IOSCHED_FLAG_WORK_FLAGS);
 }
 
-static inline int
+static inline bool
 cam_iosched_has_io(struct cam_iosched_softc *isc)
 {
 #ifdef CAM_IOSCHED_DYNAMIC
if (do_dynamic_iosched) {
struct bio *rbp = bioq_first(>bio_queue);
struct bio *wbp = bioq_first(>write_queue);
-   int can_write = wbp != NULL &&
+   bool can_write = wbp != NULL &&
cam_iosched_limiter_caniop(>write_stats, wbp) == 0;
-   int can_read = rbp != NULL &&
+   bool can_read = rbp != NULL &&
cam_iosched_limiter_caniop(>read_stats, rbp) == 0;
if (iosched_debug > 2) {
printf("can write %d: pending_writes %d max_writes 
%d\n", can_write, isc->write_stats.pending, isc->write_stats.max);
@@ -746,7 +746,7 @@ cam_iosched_has_io(struct cam_iosched_softc *isc)
return bioq_first(>bio_queue) != NULL;
 }
 
-static inline int
+static inline bool
 cam_iosched_has_more_trim(struct cam_iosched_softc *isc)
 {
return !(isc->flags & CAM_IOSCHED_FLAG_TRIM_ACTIVE) &&
@@ -757,7 +757,7 @@ cam_iosched_has_more_trim(struct cam_iosched_softc *is
 (isc)->sort_io_queue : cam_sort_io_queues)
 
 
-static inline int
+static inline bool
 cam_iosched_has_work(struct cam_iosched_softc *isc)
 {
 #ifdef CAM_IOSCHED_DYNAMIC
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"