AFS For Linux 5.1 Would Have Pleased Firefox/SQLite But Was Rejected As Untested Crap

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • cybertraveler
    Senior Member
    • Nov 2017
    • 1102

    #21
    Ahhh! I just noticed the you haven't used curly braces for the for loop either!

    Give this a read if you fancy:



    It might bring you to the same conclusion as I did about the value of the curlies.

    Just because you can do something with a language, doesn't mean you should do it. This saying probably applies to C more than any other popular language.

    Comment

    • George99
      Senior Member
      • Mar 2017
      • 225

      #22
      Well this was just a quick n dirty example, not a copy from some real code. Besides I recommend the use of "indent -linux -l160 example.c" to visualize faulty indented statements for more complex code...

      Comment

      • cybertraveler
        Senior Member
        • Nov 2017
        • 1102

        #23
        Originally posted by George99 View Post
        Well this was just a quick n dirty example, not a copy from some real code. Besides I recommend the use of "indent -linux -l160 example.c" to visualize faulty indented statements for more complex code...
        No problem.

        For fun I rewrote an improved (IMO) version of the function:

        Code:
        size_t find_min_improved(unsigned a[ELEMS])
        {
            size_t i_min = 0;
            unsigned min = a[0];
          
            assert(ELEMS > 2);
        
            for (size_t i = 1; i < ELEMS; i++) {
                if (a[i] < min) {
                    min = a[i];
                    i_min = i;
                }
            }
        
            return i_min;
        }
        i_min and min are both instantiated, so no compiler warnings.

        size_t instead of int, because it's guaranteed to be a type that can hold the maximum possible array size that C can handle. It is also a nice additional visual clue that we are probably dealing with an array index.

        The assert is there to catch mis-use of the function. It may also be useful to catch a bug in another part of the program that may otherwise have been hard to detect. Though: because "ELEMS" is (probably) a macro, it's a bit redundant. In practise, I think ELEMS would probably be a size_t argument to the function, thus making the assert() useful.

        Curly braces around the for loop for the reasons I gave. However I do note your suggested use of the "indent -linux -l160 example.c" command. If that was an enforced style practise, that may be a nice, alternative or complementary way of catching bugs like that Apple SSL bug I linked.

        Comment

        • PuckPoltergeist
          Senior Member
          • Jan 2009
          • 474

          #24
          Originally posted by George99 View Post
          Well I don't know the part of the code Linus rejected, but an "uninitialized" warning doesn't always mean the code is buggy:
          So why don't you inspect the code that is criticized? Most kernel devs are aware of false positives and silence those. So if Linus writes "And yes, it's _trivially_ and obviously uninitialized.", he's pretty sure it is.

          Comment

          • mike456
            Phoronix Member
            • Oct 2018
            • 54

            #25
            I saw someday code that's using variables, functions etc. from another shared lib. Could someone explain me how this was done? Thanks

            Comment

            • cybertraveler
              Senior Member
              • Nov 2017
              • 1102

              #26
              Originally posted by mike456 View Post
              I saw someday code that's using variables, functions etc. from another shared lib. Could someone explain me how this was done? Thanks
              Simply put: When the "code" (program) is started, it gets linked together with the shared libraries it needs by the operating system. The code can then access the features (variables & functions etc) from that shared library.

              You can find shared libraries on GNU/Linux here: /usr/lib/

              Comment

              • Guest

                #27
                I think the point would go across better if he suggested that people who wrote these patches should be retroactively aborted. His attitude back in the day built a meritocratic community, where you could just tell what you think.

                I wonder whether CoC could get Torvalds banned if he breached it.

                Comment

                • starshipeleven
                  Premium Supporter
                  • Dec 2015
                  • 14568

                  #28
                  Originally posted by DoMiNeLa10 View Post
                  I think the point would go across better if he suggested that people who wrote these patches should be retroactively aborted. His attitude back in the day built a meritocratic community, where you could just tell what you think.
                  Try telling random people that piss you off that they should have been retroactively aborted and see how long you last before someone (rightfully) smashes your fuckface in.

                  Comment

                  • Guest

                    #29
                    Originally posted by starshipeleven View Post
                    Try telling random people that piss you off that they should have been retroactively aborted and see how long you last before someone (rightfully) smashes your fuckface in.
                    I tend to shit talk people IRL, even as they're trying to beat the crap out of me. Acting like that reduces the amount of interactions with people who aren't worth your time.

                    Comment

                    • Brisse
                      Senior Member
                      • Aug 2017
                      • 908

                      #30
                      Originally posted by DoMiNeLa10 View Post

                      I tend to shit talk people IRL, even as they're trying to beat the crap out of me. Acting like that reduces the amount of interactions with people who aren't worth your time.
                      Then you are a psychopath and clearly not worth anyone else's time. You are the type of person that destroys work environments so that productivity plummets into an abyss. This is why CoC is necessary, to prevent people like you ruining both the mental state of colleagues and your entire workplaces productivity.

                      Comment

                      Working...
                      X