Skip to contentSkip to conversation

block/backup: drop dead code from backup_job_create

PATCH Applied Vladimir Sementsov-Ogievskiy 3 participants 3 messages Oct 17, 2019 – Oct 18, 2019 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block/backup: drop dead code from backup_job_create

After commit 00e30f05de1d195, there is no more "goto error" points after job creation, so after "error:" @job is always NULL and we don't need roll-back job creation.

Reported-by Coverity (CID 1406402)
---
 block/backup.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
block/backup.c +1 -4
index 46978c1785..6e1497f7bb 100644
@@ -474,10 +474,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
     if (sync_bitmap) {
         bdrv_reclaim_dirty_bitmap(bs, sync_bitmap, NULL);
     }
-    if (job) {
-        backup_clean(&job->common.job);
-        job_early_fail(&job->common.job);
-    } else if (backup_top) {
+    if (backup_top) {
         bdrv_backup_top_drop(backup_top);
     }
 
Signature · 1 line
2.21.0
Acked-by on v1 1/1
#1 lore raw

Hi Vladimir,

Quoted 3 lines · Vladimir Sementsov-Ogievskiy

After commit 00e30f05de1d195, there is no more "goto error" points after job creation, so after "error:" @job is always NULL and we don't need roll-back job creation.

I don't know this code very well, but IIUC only block_job_add_bdrv() could fail after the job creation, but this shouldn't happen because "Required permissions are already taken by backup-top target", so it seems safe for me:

Thanks,
Stefano

Quoted 27 lines
Reported-by Coverity (CID 1406402)
---
 block/backup.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
block/backup.c +1 -4
index 46978c1785..6e1497f7bb 100644
@@ -474,10 +474,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
     if (sync_bitmap) {
         bdrv_reclaim_dirty_bitmap(bs, sync_bitmap, NULL);
     }
-    if (job) {
-        backup_clean(&job->common.job);
-        job_early_fail(&job->common.job);
-    } else if (backup_top) {
+    if (backup_top) {
         bdrv_backup_top_drop(backup_top);
     }
 
Signature · 1 line
2.21.0