Coding style when using atomic_dec_and_test

Camila Alvarez Inostroza <[email protected]>
Newsgroups org.kernelnewbies.kernelnewbies
Message-ID <[email protected]>
I understand that atomic_dec_and_test returns 1 when the result of the
operation is 0, and 0 otherwise.
I've seen two ways of handling the resulting operation, below are a couple
of examples:
(1) if (!atomic_dec_and_test(&rd->refcount))
           return;
      call_rcu(&rd->rcu, free_rootdomain);

(2)  if (atomic64_dec_and_test(&map->refcnt)) {
           /* bpf_map_free_id() must be called first */
           ...
        }

Is it prefered to use one option over the other? Or is it just personal
preference?

Thanks in advance!
Camila Alvarez

_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.