| 1489 | #endif |
| 1490 | |
| 1491 | static inline int |
| 1492 | chglimit(struct uidinfo *uip, long *limit, int diff, rlim_t max, const char *name) |
| 1493 | { |
| 1494 | long new; |
| 1495 | |
| 1496 | /* Don't allow them to exceed max, but allow subtraction. */ |
| 1497 | new = atomic_fetchadd_long(limit, (long)diff) + diff; |
| 1498 | if (diff > 0 && max != 0) { |
| 1499 | if (new < 0 || new > max) { |
| 1500 | atomic_subtract_long(limit, (long)diff); |
| 1501 | return (0); |
| 1502 | } |
| 1503 | } else if (new < 0) |
| 1504 | printf("negative %s for uid = %d\n", name, uip->ui_uid); |
| 1505 | return (1); |
| 1506 | } |
| 1507 | |
| 1508 | /* |
| 1509 | * Change the count associated with number of processes |
no test coverage detected