Merge lp://qastaging/~compiz-team/compiz/compiz.tests_1042537.1 into lp://qastaging/compiz/0.9.8

Proposed by Sam Spilsbury
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 3330
Proposed branch: lp://qastaging/~compiz-team/compiz/compiz.tests_1042537.1
Merge into: lp://qastaging/compiz/0.9.8
Diff against target: 835 lines (+487/-164)
7 files modified
compizconfig/libcompizconfig/include/CMakeLists.txt (+1/-0)
compizconfig/libcompizconfig/src/CMakeLists.txt (+10/-1)
compizconfig/libcompizconfig/src/ccs_settings_upgrade_internal.c (+168/-0)
compizconfig/libcompizconfig/src/ccs_settings_upgrade_internal.h (+41/-0)
compizconfig/libcompizconfig/src/main.c (+184/-163)
compizconfig/libcompizconfig/tests/CMakeLists.txt (+13/-0)
compizconfig/libcompizconfig/tests/compizconfig_test_ccs_settings_upgrade_internal.cpp (+70/-0)
To merge this branch: bzr merge lp://qastaging/~compiz-team/compiz/compiz.tests_1042537.1
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
Review via email: mp+121641@code.qastaging.launchpad.net

Commit message

Refactors a little bit of the upgrade code and gets it under test to prepare to fix (LP: #1042537).

1. Split up ccsCheckForSettingsUpgrade into a few smaller functions
2. Consolidate some duplicate functions
3. Get those duplicate functions involving a bit of logic under test
4. Fix some invalid code in the settings upgrade function (found by manual testing)

Description of the change

Refactors a little bit of the upgrade code and gets it under test to prepare to fix (LP: #1042537).

1. Split up ccsCheckForSettingsUpgrade into a few smaller functions
2. Consolidate some duplicate functions
3. Get those duplicate functions involving a bit of logic under test

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

And I am not sure where all those whitespace changes came from .... WIP.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I fixed a conflict and there are no obvious bugs, but:

1. Copyrights on new files should have your name, not someone else's(?)
2. if (p) / while (p) on pointers is invalid C code. Should use: p != NULL
3. Variables in the middle of a block are not allowed in C, until very recently. But best to be compatible.
4. FIXME needs fixing:
      numTmp = strtol (bit, &end, 10);
   should be something like:
      if ( sscanf(bit, "%ld", &numTmp) == 1 )
5. Still some pointless whitespace changes.

review: Needs Fixing
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

> I fixed a conflict and there are no obvious bugs, but:
>
> 1. Copyrights on new files should have your name, not someone else's(?)

Fixed.

> 2. if (p) / while (p) on pointers is invalid C code. Should use: p != NULL

I've changed this to use != NULL, although this one comes as a surprise to me. Isn't NULL by definition zero and thus if (n < 0 < max) is a good null check?

> 3. Variables in the middle of a block are not allowed in C, until very
> recently. But best to be compatible.

Fixed (though I wonder if we should prefer C99, as we're not using MSVC)

> 4. FIXME needs fixing:
> numTmp = strtol (bit, &end, 10);
> should be something like:
> if ( sscanf(bit, "%ld", &numTmp) == 1 )

Fixed, thanks for the tip.

> 5. Still some pointless whitespace changes.

Fixed.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

isUpgrade looks way overcomplicated. There's no reason for it to be 5 lines. It should be more canonical:
     return !strncmp (tokenThree, "upgrade", 7);
It's a minor point, but something to think about every time you write code. Code should always be canonical, in the simplest form possible.

Also, style-wise, upper-case means "this is a macro that is not an addressable function or variable". That's a part of history that I don't think we should try to change. So if it's not a macro, then probably use lower case:
     static const int myconstant = 7;

Tests: Since CCSSettingsUpgradeInternalTest is empty, so is it actually a fixture? If not, then TEST_F should just be TEST.

That all said, I'm tired of all the revisions too. So approved.

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I think this is pointless:

else if (errno)
    perror ("sscanf");

Still, don't care.

review: Approve
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

That's fine I've got another branch based on this in progress and will implement your suggestions there.

Generally I prefer keeping constants in uppercase in the tests so that I know that the testing value is the preferred one when coming back to it.

Sent from Samsung Mobile

 Daniel van Vugt <email address hidden> wrote:

Review: Approve

isUpgrade looks way overcomplicated. There's no reason for it to be 5 lines. It should be more canonical:
     return !strncmp (tokenThree, "upgrade", 7);
It's a minor point, but something to think about every time you write code. Code should always be canonical, in the simplest form possible.

Also, style-wise, upper-case means "this is a macro that is not an addressable function or variable". That's a part of history that I don't think we should try to change. So if it's not a macro, then probably use lower case:
     static const int myconstant = 7;

Tests: Since CCSSettingsUpgradeInternalTest is empty, so is it actually a fixture? If not, then TEST_F should just be TEST.

That all said, I'm tired of all the revisions too. So approved.
--
https://code.launchpad.net/~compiz-team/compiz/compiz.tests_1042537.1/+merge/121641
Your team Compiz Maintainers is subscribed to branch lp:compiz.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches