Ticket #1861 (closed defect: duplicate)

Opened 14 years ago

Last modified 14 years ago

just a try to simplify

Reported by: vit_r Owned by: vit_r
Priority: trivial Milestone: 4.7
Component: mc-skin Version: 4.7.0-pre4
Keywords: Cc:
Blocked By: Blocking:
Branch state: Votes for changeset:

Description


just a try to simplify what is it about
(keeping in the mind: the upper judge is the Author)

    if (groups == NULL || *groups == NULL) {
        if (groups != NULL)
            g_strfreev (groups);
        return FALSE;
    }

preserving and clarifying the most possible meaning
with practical result as upper judge

Attachments

1861-rearranging-some-lines-in-src_skin_colors.c.patch (1.3 KB) - added by vit_r 14 years ago.

Change History

comment:1 follow-up: ↓ 2 Changed 14 years ago by andrew_b

No need 'else' after 'return' or 'continue'.

comment:2 in reply to: ↑ 1 ; follow-up: ↓ 3 Changed 14 years ago by vit_r

Replying to andrew_b:

No need 'else' after 'return' or 'continue'.

If it is a question then my answer is such:

"Original lines have no more checks

Rewritten lines should perform exactly the same checks but in more stable way.
Would be in next line "*groups == NULL' checked before 'groups == NULL'

  if (groups == NULL || *groups == NULL) {

a crash(seg.fault) would happen.
But in rearranged(new) version such crash can _NOT_ happen because

'groups == NULL' is firstly checked always.

So: If there is compiler checking from right to left

(i don't know such compiler really)
cited line can crash.

isn't so?

One more advantage(if i will not say may be nobody will say..)

Now they are much more beautiful ... , aren't they ?"

comment:3 in reply to: ↑ 2 ; follow-up: ↓ 4 Changed 14 years ago by andrew_b

Replying to vit_r:

So: If there is compiler checking from right to left

(i don't know such compiler really)
cited line can crash.

isn't so?

The ISO/IEC 9899:1999 standard:

6.5.13.
Unlike the bitwise binary & operator, the && operator guarantees left-to-right evaluation;
there is a sequence point after the evaluation of the first operand. If the first operand
compares equal to 0, the second operand is not evaluated.


6.5.14
Unlike the bitwise | operator, the || operator guarantees left-to-right evaluation; there is
a sequence point after the evaluation of the first operand. If the first operand compares
unequal to 0, the second operand is not evaluated.

comment:4 in reply to: ↑ 3 Changed 14 years ago by vit_r

Replying to andrew_b:

The ISO/IEC 9899:1999 standard:

Thanks for one more lesson !

New  version  is  much  more  in  the  spirit  of  Open  Source,  isn't  it?  

comment:5 Changed 14 years ago by andrew_b

  • Blocking 1845 added

comment:6 Changed 14 years ago by slavazanko

  • Status changed from new to closed
  • Resolution set to duplicate
  • Blocking 1845 removed

Will applied into #1845

Note: See TracTickets for help on using tickets.