damon_stop() has no reason to fail. It returns an error code only for possible future changes that can make it fail. Such a change has not been made yet, and this only makes the error handling complicated and confusing. Ensure it returns no error.
Unified · Split
| @@ -1926,10 +1926,8 @@ int damon_start(struct damon_ctx **ctxs, int nr_ctxs, bool exclusive) · 1925 unmodified lines | ||
| 1926 | 1926 | /* |
| 1927 | 1927 | * __damon_stop() - Stops monitoring of a given context. |
| 1928 | 1928 | * @ctx: monitoring context |
| 1929 | − * | |
| 1930 | − * Return: 0 on success, negative error code otherwise. | |
| 1931 | 1929 | */ |
| 1932 | −static int __damon_stop(struct damon_ctx *ctx) | |
| 1930 | +static void __damon_stop(struct damon_ctx *ctx) | |
| 1933 | 1931 | { |
| 1934 | 1932 | struct task_struct *tsk; |
| 1935 | 1933 | |
| @@ -1939,31 +1937,24 @@ static int __damon_stop(struct damon_ctx *ctx) · 3 unmodified lines | ||
| 1939 | 1937 | get_task_struct(tsk); |
| 1940 | 1938 | mutex_unlock(&ctx->kdamond_lock); |
| 1941 | 1939 | kthread_stop_put(tsk); |
| 1942 | − return 0; | |
| 1940 | + return; | |
| 1943 | 1941 | } |
| 1944 | 1942 | mutex_unlock(&ctx->kdamond_lock); |
| 1945 | − | |
| 1946 | − return -EPERM; | |
| 1947 | 1943 | } |
| 1948 | 1944 | |
| 1949 | 1945 | /** |
| 1950 | 1946 | * damon_stop() - Stops the monitorings for a given group of contexts. |
| 1951 | 1947 | * @ctxs: an array of the pointers for contexts to stop monitoring |
| 1952 | 1948 | * @nr_ctxs: size of @ctxs |
| 1953 | − * | |
| 1954 | − * Return: 0 on success, negative error code otherwise. | |
| 1955 | 1949 | */ |
| 1956 | 1950 | int damon_stop(struct damon_ctx **ctxs, int nr_ctxs) |
| 1957 | 1951 | { |
| 1958 | − int i, err = 0; | |
| 1952 | + int i; | |
| 1959 | 1953 | |
| 1960 | − for (i = 0; i < nr_ctxs; i++) { | |
| 1954 | + for (i = 0; i < nr_ctxs; i++) | |
| 1961 | 1955 | /* nr_running_ctxs is decremented in kdamond_fn */ |
| 1962 | − err = __damon_stop(ctxs[i]); | |
| 1963 | − if (err) | |
| 1964 | − break; | |
| 1965 | − } | |
| 1966 | − return err; | |
| 1956 | + __damon_stop(ctxs[i]); | |
| 1957 | + return 0; | |
| 1967 | 1958 | } |
| 1968 | 1959 | |
| 1969 | 1960 | /** |