]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PM: hibernate: Remove size arguments when calling strscpy()
authorThorsten Blum <thorsten.blum@linux.dev>
Tue, 18 Mar 2025 08:07:55 +0000 (09:07 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 9 Apr 2025 18:11:46 +0000 (20:11 +0200)
The size parameter is optional and strscpy() automatically determines
the length of the destination buffer using sizeof() if the argument is
omitted. This makes the explicit sizeof() calls unnecessary. Remove
them to shorten and simplify the code.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20250318080755.61126-2-thorsten.blum@linux.dev
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
kernel/power/hibernate.c

index 23c0f4e6cb2ffee2dffbae6fb3c5c947e12ca24f..f0db9d1896e8025a5d6b86f16a007454a2095b01 100644 (file)
@@ -757,7 +757,7 @@ int hibernate(void)
         * Query for the compression algorithm support if compression is enabled.
         */
        if (!nocompress) {
-               strscpy(hib_comp_algo, hibernate_compressor, sizeof(hib_comp_algo));
+               strscpy(hib_comp_algo, hibernate_compressor);
                if (!crypto_has_acomp(hib_comp_algo, 0, CRYPTO_ALG_ASYNC)) {
                        pr_err("%s compression is not available\n", hib_comp_algo);
                        return -EOPNOTSUPP;
@@ -1006,9 +1006,9 @@ static int software_resume(void)
         */
        if (!(swsusp_header_flags & SF_NOCOMPRESS_MODE)) {
                if (swsusp_header_flags & SF_COMPRESSION_ALG_LZ4)
-                       strscpy(hib_comp_algo, COMPRESSION_ALGO_LZ4, sizeof(hib_comp_algo));
+                       strscpy(hib_comp_algo, COMPRESSION_ALGO_LZ4);
                else
-                       strscpy(hib_comp_algo, COMPRESSION_ALGO_LZO, sizeof(hib_comp_algo));
+                       strscpy(hib_comp_algo, COMPRESSION_ALGO_LZO);
                if (!crypto_has_acomp(hib_comp_algo, 0, CRYPTO_ALG_ASYNC)) {
                        pr_err("%s compression is not available\n", hib_comp_algo);
                        error = -EOPNOTSUPP;
@@ -1456,8 +1456,7 @@ static int hibernate_compressor_param_set(const char *compressor,
        if (index >= 0) {
                ret = param_set_copystring(comp_alg_enabled[index], kp);
                if (!ret)
-                       strscpy(hib_comp_algo, comp_alg_enabled[index],
-                               sizeof(hib_comp_algo));
+                       strscpy(hib_comp_algo, comp_alg_enabled[index]);
        } else {
                ret = index;
        }