Ticket #8990: 0003-Minor-code-cleaning-for-checking-conditions-.patch

File 0003-Minor-code-cleaning-for-checking-conditions-.patch, 2.0 KB (added by kushalsingh007, 10 years ago)

Making the conditions more readable by changing the "if" conditions and adding comments.

  • src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp

    From 5f4ee39d143e50c5e879fee25cdcd3ce255a965f Mon Sep 17 00:00:00 2001
    From: Kushal Singh <kushal.singh@students.iiit.ac.in>
    Date: Wed, 18 Feb 2015 22:37:04 +0530
    Subject: [PATCH] * Minor code cleaning to make the checking conditions easier
     to understand.
    
    ---
     .../disk_systems/intel/PartitionMapAddOn.cpp       | 37 +++++++++++++---------
     1 file changed, 22 insertions(+), 15 deletions(-)
    
    diff --git a/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp b/src/add-ons/disk_systems/intel/PartitionMapAddOn.cpp
    index aaa9264..1480528 100644
    a b status_t  
    106106PartitionMapAddOn::ValidateInitialize(const BMutablePartition* partition,
    107107    BString* name, const char* parameters)
    108108{
    109     if (!CanInitialize(partition)
    110         || (parameters != NULL && parameters[0] != '\0')) {
     109    if (!CanInitialize(partition))
    111110        return B_BAD_VALUE;
    112     }
    113 
    114     // we don't support a content name
    115     if (name != NULL)
    116         name->Truncate(0);
    117 
    118     return B_OK;
     111 
     112    // Disk System does not suppport setting parameters.
     113    if (parameters != NULL && parameters[0] != '\0')
     114        return B_BAD_VALUE;
     115 
     116    // Disk System does not support a content name.
     117    if (name != NULL)
     118        name->Truncate(0);
     119 
     120    return B_OK;
    119121}
    120 
    121 
     122 
     123 
    122124status_t
    123125PartitionMapAddOn::Initialize(BMutablePartition* partition, const char* name,
    124126    const char* parameters, BPartitionHandle** _handle)
    125127{
    126     if (!CanInitialize(partition)
    127         || (name != NULL && name[0] != '\0')
    128         || (parameters != NULL && parameters[0] != '\0')) {
     128    if (!CanInitialize(partition))
     129        return B_BAD_VALUE;
     130 
     131    // Disk System does not suppport setting parameters.
     132    if (parameters != NULL && parameters[0] != '\0')
     133        return B_BAD_VALUE;
     134
     135    // Disk System does not support a content name.
     136    if (name != NULL && name[0] != '\0')
    129137        return B_BAD_VALUE;
    130     }
    131138
    132139    // create the handle
    133140    PartitionMapHandle* handle = new(nothrow) PartitionMapHandle(partition);