osu: Fix to return non-zero if upgrade is failed 26/313226/1
authorSangYoun Kwak <sy.kwak@samsung.com>
Thu, 20 Jun 2024 06:39:05 +0000 (15:39 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Thu, 20 Jun 2024 06:47:09 +0000 (15:47 +0900)
In the previous code, osu returned 0 even if upgrade is failed, due to
the deinitialization code. Previously, if error occured during the
upgrade, aborted the rest works and called the deinitialization function
'update_control_deinitialize' and returned its return value.
This caused osu to return 0 even an error is occured, which is invalid
behavior.
To fix this issue, the return value of deinitialization function is
treated as a different variable.

Change-Id: Ie536bafc5bb4e31f461cf1df98db496d77a24664
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
tools/osu/update.c

index 458bb9057082d1c40735ee64b3efbe8297c72cfb..3df4c15f96047e2eb9fe232aedb80648e1e45d15 100644 (file)
@@ -6,6 +6,8 @@
 int do_update(void)
 {
        int ret = 0;
+       int ret_deinit = 0;
+
        ret = update_control_initialize();
        if (ret != UPDATE_CONTROL_ERROR_NONE) {
                printf("Failed to initialize: %d\n", ret);
@@ -35,9 +37,11 @@ int do_update(void)
        printf("Succeed to trigger update: %d\n", ret);
 
 cleanup:
-       ret = update_control_deinitialize();
-       if (ret != UPDATE_CONTROL_ERROR_NONE)
-               printf("Failed to deinitialize: %d\n", ret);
+       ret_deinit = update_control_deinitialize();
+       if (ret_deinit != UPDATE_CONTROL_ERROR_NONE) {
+               printf("Failed to deinitialize: %d\n", ret_deinit);
+               return ret_deinit;
+       }
 
        return ret;
 }