Print this page
Reduce lint


 172         };
 173 
 174         if (str == NULL) {
 175                 return (EINVAL);
 176         }
 177         c = str;
 178 
 179         /*
 180          * Convert the initial numeric portion of the input string.
 181          */
 182         if (ddi_strtoull(str, &c, 10, &num) != 0) {
 183                 return (EINVAL);
 184         }
 185 
 186         /*
 187          * Handle a size in percent. Anything other than a single percent
 188          * modifier is invalid. We use either the zone's swap limit or the
 189          * system's total available swap size as the initial value. Perform the
 190          * intermediate calculation in pages to avoid overflow.
 191          */
 192         if (*c == '\%') {
 193                 u_longlong_t cap;
 194 
 195                 if (*(c + 1) != '\0')
 196                         return (EINVAL);
 197 
 198                 if (num > 100)
 199                         return (EINVAL);
 200 
 201                 cap = (u_longlong_t)curproc->p_zone->zone_max_swap_ctl;
 202                 if (cap == UINT64_MAX) {
 203                         /*
 204                          * Use the amount of available physical and memory swap
 205                          */
 206                         mutex_enter(&anoninfo_lock);
 207                         cap = TOTAL_AVAILABLE_SWAP;
 208                         mutex_exit(&anoninfo_lock);
 209                 } else {
 210                         cap = btop(cap);
 211                 }
 212 




 172         };
 173 
 174         if (str == NULL) {
 175                 return (EINVAL);
 176         }
 177         c = str;
 178 
 179         /*
 180          * Convert the initial numeric portion of the input string.
 181          */
 182         if (ddi_strtoull(str, &c, 10, &num) != 0) {
 183                 return (EINVAL);
 184         }
 185 
 186         /*
 187          * Handle a size in percent. Anything other than a single percent
 188          * modifier is invalid. We use either the zone's swap limit or the
 189          * system's total available swap size as the initial value. Perform the
 190          * intermediate calculation in pages to avoid overflow.
 191          */
 192         if (*c == '%') {
 193                 u_longlong_t cap;
 194 
 195                 if (*(c + 1) != '\0')
 196                         return (EINVAL);
 197 
 198                 if (num > 100)
 199                         return (EINVAL);
 200 
 201                 cap = (u_longlong_t)curproc->p_zone->zone_max_swap_ctl;
 202                 if (cap == UINT64_MAX) {
 203                         /*
 204                          * Use the amount of available physical and memory swap
 205                          */
 206                         mutex_enter(&anoninfo_lock);
 207                         cap = TOTAL_AVAILABLE_SWAP;
 208                         mutex_exit(&anoninfo_lock);
 209                 } else {
 210                         cap = btop(cap);
 211                 }
 212