Coding style when using atomic_dec_and_test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux