]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
utils: Don't set or clear flags that don't need setting or clearing
authorSean Bright <sean.bright@gmail.com>
Tue, 11 Dec 2018 15:06:15 +0000 (10:06 -0500)
committerSean Bright <sean.bright@gmail.com>
Tue, 11 Dec 2018 15:07:27 +0000 (10:07 -0500)
Change-Id: I0e7fb507ac09b15e45e1ff8501ecfca67afa5217

main/utils.c

index c82ecb9bed84c5ed6e073accc51ebcb9246398a3..3d3750bf053703e90c8c5f1bd0c4efd067a6182a 100644 (file)
@@ -2813,9 +2813,17 @@ int __ast_fd_set_flags(int fd, int flags, enum ast_fd_flag_operation op,
 
        switch (op) {
        case AST_FD_FLAG_SET:
+               if ((f & flags) == flags) {
+                       /* There is nothing to set */
+                       return 0;
+               }
                f |= flags;
                break;
        case AST_FD_FLAG_CLEAR:
+               if (!(f & flags)) {
+                       /* There is nothing to clear */
+                       return 0;
+               }
                f &= ~flags;
                break;
        default: