Topic: Bugs on carry_code wallpaper

Wallpaper http://bsdnexus.com/wallpapers/carry_code.jpg (& carry_code_single.jpg version)
contains shameful bug on need_coffee() function -
expression "sizeof(coffee)" ALWAYS equal to sizeof(void*) value, i.e. 4, 8, or 2 depending of platform.

   I would be ashamed to use so buggy wallpaper.

   I suppose, you should use "sizeof(mug)" instead of "sizeof(coffee)" i.e. :

char * need_coffee(int sugar)
{
   char  * coffee = malloc(sizeof(mug));

   strlcpy(coffee, water + sugar, sizeof(mug));
   strlcat(coffee, grind(beans), sizeof(mug));

   return (coffee);
}

or use static "coffee" implementation, i.e. :

char  coffee[sizeof(mug)];

char * need_coffee(int sugar)
{
   strlcpy(coffee, water + sugar, sizeof(coffee));
   strlcat(coffee, grind(beans), sizeof(coffee));

   return (coffee);
}

Thank you.

P.S. Maybe there is need for "boil(coffee);" before return ? smile

Last edited by shadow (2005-10-04 17:29:16)

Re: Bugs on carry_code wallpaper

I like your thinking shadow, but why do you think it is buggy?

if "coffee" is the same size as "mug" then why would "sizeof(coffee)" be any worse than "sizeof(mug)" ?

"UBER" means I don't drink the coffee... I chew the beans instead
             -- Copyright BSDnexus

Re: Bugs on carry_code wallpaper

if (sizeof(coffee) == sizeof(mug)) then clean_overflow()

Re: Bugs on carry_code wallpaper

WIntellect wrote:

I like your thinking shadow, but why do you think it is buggy?

if "coffee" is the same size as "mug" then why would "sizeof(coffee)" be any worse than "sizeof(mug)" ?

You are kidding ?
"coffee" and "mug" can't have same sizeof(), because they have different types - coffee is pointer (to char), but mug is not (should not, as far as I understand).

Have you ever write on C ?

lucas wrote:

if (sizeof(coffee) == sizeof(mug)) then clean_overflow()

better, something like this:

if (sizeof(coffee) == sizeof(mug) && sizeof(mug) != sizeof(void*))
   abort("ABORT: Bogus compiler");

Last edited by shadow (2005-10-04 18:50:37)

Re: Bugs on carry_code wallpaper

Better yet:

if( entertainment_value( shadow ) < entertainment_value( wall ) ) {
     printf( "KILLJOY\n" );
     return -1;
}
May Science bless you.

Re: Bugs on carry_code wallpaper

come on.. i'm diggin' this bro

Re: Bugs on carry_code wallpaper

We're just having fun, too. sad

It's not serious or anything.

May Science bless you.

Re: Bugs on carry_code wallpaper

come on.. his first post was greatness

Re: Bugs on carry_code wallpaper

shadow wrote:

You are kidding ?
"coffee" and "mug" can't have same sizeof(), because they have different types - coffee is pointer (to char), but mug is not (should not, as far as I understand).

Have you ever write on C ?

Dude - there was no need to get shirty with me. So I made a mistake - you telling me you write perfect code EVERY time ?

Yes, I see the error I made, yes, I will fix it as soon as possible. Thank you for pointing it out. I don't claim to be perfect, I am still learning and am happy to admit it!

A little politeness wouldn't go a miss

"UBER" means I don't drink the coffee... I chew the beans instead
             -- Copyright BSDnexus

Re: Bugs on carry_code wallpaper

I'm not an expert but I took a look at the code we can get from your site and it's very clean.

You'll soon be the C rulor !! smile

<wintellect> NetBSD users are smart enough to accept that there's no 3D support tongue

Re: Bugs on carry_code wallpaper

dynek wrote:

I'm not an expert but I took a look at the code we can get from your site and it's very clean.

You'll soon be the C rulor !! smile

Thank you - that means a lot to me. My intention is always to write good, clean code and you're not the first to tell me either.

As I said, I don't profess to be perfect / brilliant - I'm still learning and am happy to  admit errors or to be aided in my learning

smile

"UBER" means I don't drink the coffee... I chew the beans instead
             -- Copyright BSDnexus

Re: Bugs on carry_code wallpaper

WIntellect wrote:

Dude - there was no need to get shirty with me.

Mustbe, I'm too rough, sorry, I should not judge you just as would myself.
Specially on reply - your post appear to be too perfunctory for practical programmer.
Sometimes, I'm spending much time to find my own bugs, like this, so it is just striking my eyes and making me angry.

So I made a mistake - you telling me you write perfect code EVERY time ?

Of course, no. Only strive to.

dynek wrote:

I'm not an expert but I took a look at the code we can get from your site and it's very clean.

That's why such errors are often difficult for finding.

It's funny, to discuss so seriously about, actually, frivolous things, isn't it ?

Last edited by shadow (2005-10-04 17:23:26)

Re: Bugs on carry_code wallpaper

Indeed.

Like I said, I find people's suggestions helpful and useful, but I don't like it when people are rude; there's really no need for it.
Like I said - you were absolutely right about my code and I will change it  smile

Ironically - you failed to notice the other bug in the code which I was aware about, AND you created a new bug when you replicated the code:

  char  * coffee = malloc(sizeof(mug));

   strlcpy(coffee, water + sugar, sizeof(mug));
   strlcpy(coffee, grind(beans), sizeof(mug));

I still need to write the test for the malloc()  - my bug wink

And you used strlcpy() twice,  it should be strlcpy() then strlcat() - you're bug  wink

No one's perfect, and we're all learners.

As Maxlor once told me - though we all try to run before we can walk, not many of us get to "running" anyway

"UBER" means I don't drink the coffee... I chew the beans instead
             -- Copyright BSDnexus

Re: Bugs on carry_code wallpaper

How can a bug harm the wallpaper? tongue

| There's no place like /home | There's no place like /home | There's no place like /home |

Re: Bugs on carry_code wallpaper

You never know what can happen !

<wintellect> NetBSD users are smart enough to accept that there's no 3D support tongue

Re: Bugs on carry_code wallpaper

WIntellect wrote:

...AND you created a new bug when you replicated the code ...

damn! smile

I still need to write the test for the malloc()  - my bug wink

I don't think you should start dig deeper smile. Because you can dig too much. For example:

[] you have memory leak - "coffee" is allocated every time by need_coffee() but never freed (on main())
[] "throat" assumed to be never fopen()-ed smile
[] mug overflow is prevented, but never checked smile
[] "water" assumed to be char pointer, "sugar" is integer start position in "water" smile
[] water, sugar, beans assumed to be unlimited (or recycled; quite probable variant, because water w/ grinded beans seems to be never boiled) smile
[] where is work(), actually ? Just sleep() & drink coffee wink
...

So, you see ... program improvement cannot be finished, but can be stopped.

bmk1st wrote:

How can a bug harm the wallpaper? tongue

It can be exploited by malicious hackers smile

Best medicine ever is water. Use 2 drops on glass of pure alcohol.

Last edited by shadow (2005-10-05 03:32:49)

Re: Bugs on carry_code wallpaper

At least he didn't accuse you of writing shoddy code ;-)

Re: Bugs on carry_code wallpaper

that was weird.. it was like a pissing contest with some smileys thrown in

Re: Bugs on carry_code wallpaper

lucas wrote:

that was weird.. it was like a pissing contest with some smileys thrown in

I disagree. It's good to critique code in a bid to make it better - how else do you learn?

I just don't like it when people are unnecessarily rude.

"UBER" means I don't drink the coffee... I chew the beans instead
             -- Copyright BSDnexus

Re: Bugs on carry_code wallpaper

i found you both roughly equally rude. but it was all downplayed with some smilies.

but, yeah, i thought it was all funny and i hope everyone learned something. smile

Re: Bugs on carry_code wallpaper

by-the-way, I have made changes to the wallpapers...

Let's see what more bugs appear tongue

"UBER" means I don't drink the coffee... I chew the beans instead
             -- Copyright BSDnexus

Re: Bugs on carry_code wallpaper

Yeah I never thought this post would come back!

When I read the first message it appeared to me like it was written a day ago. I didn't even remember I already read it :-)

<wintellect> NetBSD users are smart enough to accept that there's no 3D support tongue

Re: Bugs on carry_code wallpaper

Damn, that's some great spam, it copies a previous posts and adds a sneaky link.
Respect to the spammer guy who thought that up ... Now let's bust his balls, smash his face, and choke him with his dick.

Anyway, I can't recall reading this before, but I'm fairly sure my neighbors heard me laughing ... I may just have found a new wallpaper for my machine at work wink

Last edited by Carpetsmoker (2010-09-17 23:50:56)

Trust me, I know what I'm doing.