Print this page
5047 don't use atomic_*_nv if you discard the return value


1096                 rw_exit(&tip->ti_rwlock);
1097 }
1098 
1099 static void
1100 trill_node_free(trill_node_t *nick_entry)
1101 {
1102         trill_nickinfo_t *tni;
1103 
1104         tni = nick_entry->tn_ni;
1105         kmem_free(tni, TNI_TOTALSIZE(tni));
1106         kmem_free(nick_entry, sizeof (trill_node_t));
1107 }
1108 
1109 static void
1110 trill_node_unref(trill_inst_t *tip, trill_node_t *tnp)
1111 {
1112         if (atomic_dec_uint_nv(&tnp->tn_refs) == 0) {
1113                 if (tnp->tn_tsp != NULL)
1114                         trill_sock_unref(tnp->tn_tsp);
1115                 trill_node_free(tnp);
1116                 (void) atomic_dec_uint_nv(&tip->ti_nodecount);
1117         }
1118 }
1119 
1120 static trill_node_t *
1121 trill_node_lookup(trill_inst_t *tip, uint16_t nick)
1122 {
1123         trill_node_t *nick_entry;
1124 
1125         if (!VALID_NICK(nick))
1126                 return (NULL);
1127         rw_enter(&tip->ti_rwlock, RW_READER);
1128         nick_entry = tip->ti_nodes[nick];
1129         if (nick_entry != NULL) {
1130                 atomic_inc_uint(&nick_entry->tn_refs);
1131         }
1132         rw_exit(&tip->ti_rwlock);
1133         return (nick_entry);
1134 }
1135 
1136 static int




1096                 rw_exit(&tip->ti_rwlock);
1097 }
1098 
1099 static void
1100 trill_node_free(trill_node_t *nick_entry)
1101 {
1102         trill_nickinfo_t *tni;
1103 
1104         tni = nick_entry->tn_ni;
1105         kmem_free(tni, TNI_TOTALSIZE(tni));
1106         kmem_free(nick_entry, sizeof (trill_node_t));
1107 }
1108 
1109 static void
1110 trill_node_unref(trill_inst_t *tip, trill_node_t *tnp)
1111 {
1112         if (atomic_dec_uint_nv(&tnp->tn_refs) == 0) {
1113                 if (tnp->tn_tsp != NULL)
1114                         trill_sock_unref(tnp->tn_tsp);
1115                 trill_node_free(tnp);
1116                 atomic_dec_uint(&tip->ti_nodecount);
1117         }
1118 }
1119 
1120 static trill_node_t *
1121 trill_node_lookup(trill_inst_t *tip, uint16_t nick)
1122 {
1123         trill_node_t *nick_entry;
1124 
1125         if (!VALID_NICK(nick))
1126                 return (NULL);
1127         rw_enter(&tip->ti_rwlock, RW_READER);
1128         nick_entry = tip->ti_nodes[nick];
1129         if (nick_entry != NULL) {
1130                 atomic_inc_uint(&nick_entry->tn_refs);
1131         }
1132         rw_exit(&tip->ti_rwlock);
1133         return (nick_entry);
1134 }
1135 
1136 static int