(attribute_is_recent): Use MU_ATTRIBUTE_IS_UNSEEN.
(attribute_set_flags): If the required bits are already set, do not modify anything (attribute_unset_flags): If the required bits are already cleared, do not modify anything
Showing
1 changed file
with
17 additions
and
5 deletions
... | @@ -101,8 +101,16 @@ int | ... | @@ -101,8 +101,16 @@ int |
101 | attribute_set_flags (attribute_t attr, int flags) | 101 | attribute_set_flags (attribute_t attr, int flags) |
102 | { | 102 | { |
103 | int status = 0; | 103 | int status = 0; |
104 | int oflags = 0; | ||
105 | |||
104 | if (attr == NULL) | 106 | if (attr == NULL) |
105 | return EINVAL; | 107 | return EINVAL; |
108 | |||
109 | /* If the required bits are already set, do not modify anything */ | ||
110 | attribute_get_flags (attr, &oflags); | ||
111 | if ((oflags & flags) == flags) | ||
112 | return 0; | ||
113 | |||
106 | if (attr->_set_flags) | 114 | if (attr->_set_flags) |
107 | status = attr->_set_flags (attr, flags); | 115 | status = attr->_set_flags (attr, flags); |
108 | else | 116 | else |
... | @@ -116,8 +124,16 @@ int | ... | @@ -116,8 +124,16 @@ int |
116 | attribute_unset_flags (attribute_t attr, int flags) | 124 | attribute_unset_flags (attribute_t attr, int flags) |
117 | { | 125 | { |
118 | int status = 0; | 126 | int status = 0; |
127 | int oflags = 0; | ||
128 | |||
119 | if (attr == NULL) | 129 | if (attr == NULL) |
120 | return EINVAL; | 130 | return EINVAL; |
131 | |||
132 | /* If the required bits are already cleared, do not modify anything */ | ||
133 | attribute_get_flags (attr, &oflags); | ||
134 | if ((oflags & flags) == 0) | ||
135 | return 0; | ||
136 | |||
121 | if (attr->_unset_flags) | 137 | if (attr->_unset_flags) |
122 | status = attr->_unset_flags (attr, flags); | 138 | status = attr->_unset_flags (attr, flags); |
123 | else | 139 | else |
... | @@ -286,11 +302,7 @@ attribute_is_recent (attribute_t attr) | ... | @@ -286,11 +302,7 @@ attribute_is_recent (attribute_t attr) |
286 | { | 302 | { |
287 | int flags = 0; | 303 | int flags = 0; |
288 | if (attribute_get_flags (attr, &flags) == 0) | 304 | if (attribute_get_flags (attr, &flags) == 0) |
289 | { | 305 | return MU_ATTRIBUTE_IS_UNSEEN(flags); |
290 | /* something is recent when it is not read and not seen. */ | ||
291 | return (flags == 0 || ! ((flags & MU_ATTRIBUTE_SEEN) | ||
292 | || (flags & MU_ATTRIBUTE_READ))); | ||
293 | } | ||
294 | return 0; | 306 | return 0; |
295 | } | 307 | } |
296 | 308 | ... | ... |
-
Please register or sign in to post a comment