Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*

@@ -132,11 +132,11 @@
                 return (NULL);
 
         mutex_enter(&nts->nts_lock);
         nd = net_find(protocol, nts);
         if (nd != NULL)
-                atomic_add_32((uint_t *)&nd->netd_refcnt, 1);
+                atomic_inc_32((uint_t *)&nd->netd_refcnt);
         mutex_exit(&nts->nts_lock);
         return (nd);
 }
 
 /*

@@ -155,11 +155,11 @@
          * of net_protocol_release() is going to free this structure then
          * it is now the only owner (refcnt==1) and it will have been
          * removed from the nts_netd_head list on the neti_stack_t from a
          * call to net_protocol_unregister already, so it is thus an orphan.
          */
-        if (atomic_add_32_nv((uint_t *)&info->netd_refcnt, -1) == 0) {
+        if (atomic_dec_32_nv((uint_t *)&info->netd_refcnt) == 0) {
                 ASSERT(info->netd_hooks == NULL);
                 ASSERT(info->netd_stack == NULL);
                 kmem_free(info, sizeof (struct net_data));
         }
 

@@ -199,11 +199,11 @@
 
         if (info != NULL)
                 (void) net_protocol_release(info);
 
         if (n != NULL)
-                atomic_add_32((uint_t *)&n->netd_refcnt, 1);
+                atomic_inc_32((uint_t *)&n->netd_refcnt);
 
         mutex_exit(&nts->nts_lock);
 
         return (n);
 }