Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • char *path;
    sprintf( path, "%s/%s/%s", x, y, z );
    mysub( key, path );
    • That's some pretty hazardous example code right there.
      • Agreed. And it isn't complete code. The flaw I was highlighting was that the sprintf syntax is different between Perl and C.
    • I really hope this isn't for work :-)
      • It is, but it isn't the code I was using. It was my misunderstanding of sprintf syntax that I was highlighting :)
    • So, you want to poke some random part of your program with a m/d/y string? Whoo hoo! I think you wanted:
      char path[1024];
      sprintf ( path ... );
      And yes, the fixed size buffer there is the root of all evilness of C programs.
      --
      • Randal L. Schwartz
      • Stonehenge
      • I'm in the UK, so it would have been a d/m/y string if that was the case ;) I only use x/y/z just as an example, that doesn't resemble the real string I was formatting. You are quite right about fixed size buffers, I was only using a pointer to indicate a string. Makes me realise how lucky we are programming Perl :)
    • char *path;
      if( asprintf( &path, "%s/%s/%s", x, y, z ) == -1 )
          errx( "Memory allocation error" );
      mysub( key, path );
      free( path );

      That assumes you have errx and asprintf of course, but they’re reasonably portable.

  • Splint [wikipedia.org] is one lint.

    The gcc folks reckon that -Wall should be good enough though.

    -Dom

    • Neat. Thanks. I've not really used gcc actively (accept under the covers of library installs and make), so I guess I ought to look at what all the options mean. But Splint looks to be exactly what I was after, so I'll be giving that a try in future :)
      • You'll probably go mad before you understand all of gcc's options. :-)

        In practise, I just compile with "-g -pipe -Wall", and it complains about quite a lot. The "-pipe" probably isn't necessary these days, but I'm a creature of habit.

        -Dom

  • As far as Ubuntu goes, you're absolutely right. The Ubuntu repo doesn't seem to have a copy.

    The thing to do then (he said, confidently) is to add more repositories to your list. Namely, a few Debian repositories. Now, I probably should tell you that this step isn't recommended (and people on the forums actively advise against it). The reason is that it's easy to upgrade something "core" and bork the system.

    splint doesn't fall into this category, however. I added Marillat's archive (http://ubuntuguide.or [ubuntuguide.org]

    • I have a load of debian repositories (9 in all) and none of them had lint or splint. However, now that I've added your suggested repository, I found splint straight away. Thanks :)