Patchwork boot-directdisk: avoid loop in MBR disk signature generation

login
register
mail settings
Submitter Jonathan Liu
Date Oct. 2, 2013, 10:47 a.m.
Message ID <1380710831-10855-1-git-send-email-net147@gmail.com>
Download mbox | patch
Permalink /patch/59181/
State Accepted
Commit d299444adcc02b9a40ba0651059d0ba283108231
Headers show

Comments

Jonathan Liu - Oct. 2, 2013, 10:47 a.m.
Instead of looping until the generated signature is non-zero, just
return 'ffffffff' if it's zero. This avoids an infinite loop if the
generated signature is always zero.

Signed-off-by: Jonathan Liu <net147@gmail.com>
---
 meta/classes/boot-directdisk.bbclass | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Patch

diff --git a/meta/classes/boot-directdisk.bbclass b/meta/classes/boot-directdisk.bbclass
index 0f64b44..5535728 100644
--- a/meta/classes/boot-directdisk.bbclass
+++ b/meta/classes/boot-directdisk.bbclass
@@ -148,11 +148,12 @@  python do_bootdirectdisk() {
 def generate_disk_signature():
     import uuid
 
-    while True:
-        signature = str(uuid.uuid4())[:8]
+    signature = str(uuid.uuid4())[:8]
 
-        if signature != '00000000':
-            return signature
+    if signature != '00000000':
+        return signature
+    else:
+        return 'ffffffff'
 
 def validate_disk_signature(d):
     import re