Page 4 of 10 FirstFirst ... 23456 ... LastLast
Results 31 to 40 of 99

Thread: How NOT to write a shared library

  1. #31
    Join Date
    Feb 2007
    Beans
    236

    Re: How NOT to write a shared library

    Quote Originally Posted by winch View Post
    Why do you think the project has a public issue tracker?
    That's irrelevant to this thread. The thread has nothing to do with Pulse Audio bug reporting, and everything to do with how not to design a shared lib. Pulse Audio is simply an example I recently found that demonstrates what I'm talking about. See the thread title, and original post for details.
    Last edited by j_g; November 16th, 2007 at 08:20 AM.

  2. #32
    Join Date
    May 2007
    Location
    Basildon, England
    Beans
    339
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How NOT to write a shared library

    I know it is some 15 years since I last wrote code but I would have thought that the code posted as

    void pa_xfree(void *p) {
    if (!p)
    return;

    free(p);
    }

    would be better written
    void pa_xfree(void *p)
    {
    if (p)
    { free(p);
    }
    return;
    }

    the essence is not the way I do braces but I always work of having only one route out of a function. The function as originally written has an implied return at the bottom of the function and therefore as I have written it will reduce the number of instructions the code generates and have the advantage that you only ever have to trace one exit path and it allows to to do any tidying up if you need.
    If I am wrong I am happy to be corrected by those who are writing code today rather than old fogies like me who stopped writing code a long time ago.

    Ugh. Sorry chaps and chapesses, things have happened to my formatting. You should be able to get the sense of what I have said.
    Last edited by SteveHillier; November 16th, 2007 at 11:53 AM. Reason: to explain stripped out white space
    Mick 'n Keef rock, Chas beats time and Ronnie is the new boy
    Registered as user 466848 with the Linux Counter. Registered Ubuntu User 22858. Our company website or our new venture

  3. #33
    Join Date
    Aug 2006
    Location
    60°27'48"N 24°48'18"E
    Beans
    3,458

    Re: How NOT to write a shared library

    The total code size issue should be completely irrelevant, and even when it comes to executed instruction count, you aren't really saving anything...

    When it comes to the multiple returns in function question, I actually got into quite a debate on this with as an undergrad with one teaching assistant (who actually was "on loan" from business school... no wonder she had the "wrong" opinion ) ... she felt strongly that there should be only one return at the end of the function.

    It's probably essentially a matter of taste, but I prefer having my functions quit whenever they "can", because after that you no longer need to keep on following how and where the return state is saved and finally returned at the end, after some supposedly orderly (and unneccessary) unwinding of your branches, loops... it's just somehow easier to just "stop" reading the function's logic whenever a returnable state comes around...
    Last edited by CptPicard; November 16th, 2007 at 12:19 PM.
    LambdaGrok. | #ubuntu-programming on FreeNode

  4. #34
    Join Date
    May 2007
    Location
    Paris, France
    Beans
    927
    Distro
    Kubuntu 7.04 Feisty Fawn

    Re: How NOT to write a shared library

    Quote Originally Posted by CptPicard View Post
    It's probably essentially a matter of taste, but I prefer having my functions quit whenever they "can", because after that you no longer need to keep on following how and where the return state is saved and finally returned at the end, after some supposedly orderly (and unneccessary) unwinding of your branches, loops... it's just somehow easier to just "stop" reading the function's logic whenever a returnable state comes around...

    +1

    Moreover, any decent optimizing compiler will probably rewrite *both* "styles" anyway depending on the optimization flags.
    Not even tinfoil can save us now...

  5. #35
    Join Date
    Jun 2006
    Location
    CT, USA
    Beans
    5,267
    Distro
    Ubuntu 6.10 Edgy

    Re: How NOT to write a shared library

    Quote Originally Posted by j_g View Post
    I'm curious why you waste so much time repeatedly claiming that all I'm doing is "complaining and whining" when my messages obviously have a great deal of very detailed, specific, technical supporting evidence to back up each and every "complaint" (read: legitimate point) I've made.
    You don't need to "make detailed point" here, you should report a bug. Do you want to have it fixed?

    OK, I do it for you. I assume you are talking about http://en.wikipedia.org/wiki/Pulse_audio == http://pulseaudio.org/ ?

    I reported it as a http://pulseaudio.org/ticket/158

  6. #36
    Join Date
    Dec 2006
    Location
    Uk
    Beans
    109

    Re: How NOT to write a shared library

    Quote Originally Posted by j_g View Post
    That's irrelevant to this thread. The thread has nothing to do with Pulse Audio bug reporting, and everything to do with how not to design a shared lib. Pulse Audio is simply an example I recently found that demonstrates what I'm talking about. See the thread title, and original post for details.
    So if this thread is nothing to do with trying to get the situation improved and warning other distros about the problem why say it is?

    If you claim to be acting under a motive and your actions don't back it up people will question all your motives. As seen in this thread after just four posts. Then the thread gets hijacked and whatever your real motive was gets lost in the noise.
    OpenStreetMap - Free editable map of the whole world

  7. #37
    Join Date
    Jun 2006
    Location
    CT, USA
    Beans
    5,267
    Distro
    Ubuntu 6.10 Edgy

    Re: How NOT to write a shared library

    FYI, bug http://pulseaudio.org/ticket/158 was closed as invalid.

    "Also note that due to overcommiting on Linux OOM errors are generally not handled by malloc() returning NULL, but by killing processes via the OOM killer. So spending much time thinking about handling malloc() returning NULL is generally a waste of it."

    If you want to know what those experts (real experts, with names and project) think about OP, you need to follow the link - I cannot post it here, I would be banned. But looks like it was not complete waste of time - they had a good laugh out of it

  8. #38
    Join Date
    Feb 2007
    Beans
    236

    Re: How NOT to write a shared library

    Quote Originally Posted by winch View Post
    So if this thread is nothing to do with trying to get the situation improved and warning other distros about the problem why say it is?
    I have no idea why you're saying that is what the thread is about. I can't read your mind. I know only that I've already explicitly explained what the thread is about (in a previous post), and I'm quite sure that the title I chose for the thread, and the content of my original post, made it quite clear that it isn't what you mistakenly think it's about. You should already know that your above statement is incorrect.

    If you claim to be acting under a motive and your actions don't back it up
    Non sequitor. I don't claim to be acting under any motive other than those I've already identified, and my actions are in accordance with those claims.

    Please stop making unfounded accusations about my "motives" and "actions".

    As seen in this thread after just four posts. Then the thread gets hijacked and whatever your real motive was gets lost in the noise.
    Yes. The first person to post a totally off-topic reply in this thread was "skeeterbug", after a couple others posted on-topic. His post had nothing to do with "How NOT to write a shared library", nor the point of any preceding posts, nor even about programming. It was a post about bug reporting. If he wanted to know whether anyone had reported a particular bug to Pulse Audio authors, then he should have posted a thread "Has anyone reported a bug to the Pulse Audio mail list?" in a forum about Pulse Audio, or bug reports.

    Nevertheless, I think that the whole first page of replies was ontopic, and a good discussion (even from people who may have been expressing views contrary to mine. At least they were ontopic and making actual arguments about programming).

    On the second page, a few people repeated the mistake of skeeterbug (probably because his message got that started -- that's how it goes) by continuing to post messages about bug reports, in a thread about "How Not to write shared libs" in a programming forum. The moderators should be moving those posts to an appropriate forum (including your message). And one person even used those offtopic posts as an excuse to launch his usual personal attacks. But the fact this happened is definitely not my fault. It's the fault of the people who posted those messages (and the moderators who left the messages there).

    Now the thread has taken another turn into discussing a particular optimization. Mind you, unlike the posts about bug reporting and the personal attacks, this is a legitimate programming discussion, and should be persued in this forum. I just wish that someone had spun it off into a new thread (by the OP, or by moderators doing their job) so this one could remain ontopic, and if someone visiting this forum wanted to get info about either shared libs, or optimizations, he could more quickly and easily find the info without it being buried within a thread that has no relevance to the info he seeks.

    I'm moderator of a support forum, and the vast majority of my activity is not spent censoring posts, but rather, organizing and updating posts on the board. I spend the overwhelming majority of my time going through archives to make sure information in old posts is uptodate advice in accordance with the latest developments. And I spend equal amounts of time organizing posts into threads so that info is easily perusable for endusers. The readers of the forum unanimously tell me that, due to these actions, they consider this forum the best source of info on the given topic, and one of the very best forums they've used. I'm pretty sure they wouldn't be nearly as enamored with the way that some folks have been allowed to twist this here thread, even in a quest to post messages that have nothing whatsoever to do with the topic of this forum (ie, programming).

  9. #39
    Join Date
    Jun 2006
    Location
    CT, USA
    Beans
    5,267
    Distro
    Ubuntu 6.10 Edgy

    Re: How NOT to write a shared library

    There is no bug, as explained by pulseaudio experts. Nothing to report to anyone. Just hot air, IIUC.

    If it is your word against theirs, I take expert opinions from a person with a name from known project against anonymous poster every time.

  10. #40
    Join Date
    Oct 2007
    Beans
    115
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: How NOT to write a shared library

    Nice, now I know a little more about exits.

    Also, I think in this forum there is no core developer of Ubuntu, perhaps from time to time, but if you really want to complain about something in a code, you should look for mailing list, bug list... or in the case of Ubuntu launchpad...
    me ||
    Las cosas que no se comparten se pierden. || Todo es lo que aparenta ser hasta que se descubre lo que en realidad es.
    How to become a hacker?

Page 4 of 10 FirstFirst ... 23456 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •